



import torch
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss

from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.bert.modeling_bert import (
    BERT_INPUTS_DOCSTRING,
    BERT_START_DOCSTRING,
    BertEmbeddings,
    BertLayer,
    BertPooler,
    BertPreTrainedModel,
)





def 		a__			(		_UpperCamelCase			: Any							):
   __lowerCamelCase													=    torch.exp(_UpperCamelCase							)
   __lowerCamelCase													=    torch.sum(_UpperCamelCase ,dim=1							)  # sum of exp(x_i)
   __lowerCamelCase													=    torch.sum(x * exp_x ,dim=1							)  # sum of x_i * exp(x_i)
   return torch.log(_UpperCamelCase							) - B / A



class  __lowerCAmelCase     (	nn.Module   ):




 def __init__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    super().__init__()
    __lowerCamelCase													=    config.output_attentions
    __lowerCamelCase													=    config.output_hidden_states
    __lowerCamelCase													=    nn.ModuleList([BertLayer(__UpperCAmelCase				) for _ in range(config.num_hidden_layers				)]				)
    __lowerCamelCase													=    nn.ModuleList([BertHighway(__UpperCAmelCase				) for _ in range(config.num_hidden_layers				)]				)

    __lowerCamelCase													=    [-1 for _ in range(config.num_hidden_layers				)]




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    if (type(__UpperCAmelCase				) is float) or (type(__UpperCAmelCase				) is int):
       for i in range(len(self.early_exit_entropy				)				):
          __lowerCamelCase													=    x
    else:
       __lowerCamelCase													=    x




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    pooler.state_dict()
    for highway in self.highway:
       for name, param in highway.pooler.state_dict().items():
          param.copy_(loaded_model[name]				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				):



    '''simple docstring'''
    __lowerCamelCase													=    ()
    __lowerCamelCase													=    ()
    __lowerCamelCase													=    ()
    for i, layer_module in enumerate(self.layer				):
       if self.output_hidden_states:
          __lowerCamelCase													=    all_hidden_states + (hidden_states,)

       __lowerCamelCase													=    layer_module(
           __UpperCAmelCase	,				__UpperCAmelCase	,				head_mask[i]	,				__UpperCAmelCase	,				__UpperCAmelCase				)
       __lowerCamelCase													=    layer_outputs[0]

       if self.output_attentions:
          __lowerCamelCase													=    all_attentions + (layer_outputs[1],)

       __lowerCamelCase													=    (hidden_states,)
       if self.output_hidden_states:
          __lowerCamelCase													=    current_outputs + (all_hidden_states,)
       if self.output_attentions:
          __lowerCamelCase													=    current_outputs + (all_attentions,)

       __lowerCamelCase													=    self.highway[i](__UpperCAmelCase				)
       # logits, pooled_output

       if not self.training:
          __lowerCamelCase													=    highway_exit[0]
          __lowerCamelCase													=    entropy(__UpperCAmelCase				)
          __lowerCamelCase													=    highway_exit + (highway_entropy,)  # logits, hidden_states(?), entropy
          __lowerCamelCase													=    all_highway_exits + (highway_exit,)

          if highway_entropy < self.early_exit_entropy[i]:
             __lowerCamelCase													=    (highway_logits,) + current_outputs[1:] + (all_highway_exits,)
             raise HighwayException(__UpperCAmelCase	,				i + 1				)
       else:
          __lowerCamelCase													=    all_highway_exits + (highway_exit,)

        # Add last layer
    if self.output_hidden_states:
       __lowerCamelCase													=    all_hidden_states + (hidden_states,)

    __lowerCamelCase													=    (hidden_states,)
    if self.output_hidden_states:
       __lowerCamelCase													=    outputs + (all_hidden_states,)
    if self.output_attentions:
       __lowerCamelCase													=    outputs + (all_attentions,)

    __lowerCamelCase													=    outputs + (all_highway_exits,)
    return outputs  # last-layer hidden state, (all hidden states), (all attentions), all highway exits



@add_start_docstrings(
    """The Bert Model transformer with early exiting (DeeBERT). """  ,	lowerCAmelCase__  ,	)
class  __lowerCAmelCase     (	lowerCAmelCase__   ):




 def __init__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    super().__init__(__UpperCAmelCase				)
    __lowerCamelCase													=    config

    __lowerCamelCase													=    BertEmbeddings(__UpperCAmelCase				)
    __lowerCamelCase													=    DeeBertEncoder(__UpperCAmelCase				)
    __lowerCamelCase													=    BertPooler(__UpperCAmelCase				)

    self.init_weights()




 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    self.encoder.init_highway_pooler(self.pooler				)




 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    return self.embeddings.word_embeddings




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    value




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    for layer, heads in heads_to_prune.items():
       self.encoder.layer[layer].attention.prune_heads(__UpperCAmelCase				)




 @add_start_docstrings_to_model_forward(__UpperCAmelCase				)
 def        lowerCamelCase      (						self	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				):



    '''simple docstring'''
    if input_ids is not None and inputs_embeds is not None:
       raise ValueError('''You cannot specify both input_ids and inputs_embeds at the same time'''				)
    elif input_ids is not None:
       __lowerCamelCase													=    input_ids.size()
    elif inputs_embeds is not None:
       __lowerCamelCase													=    inputs_embeds.size()[:-1]
    else:
       raise ValueError('''You have to specify either input_ids or inputs_embeds'''				)

    __lowerCamelCase													=    input_ids.device if input_ids is not None else inputs_embeds.device

    if attention_mask is None:
       __lowerCamelCase													=    torch.ones(__UpperCAmelCase	,				device=__UpperCAmelCase				)
    if encoder_attention_mask is None:
       __lowerCamelCase													=    torch.ones(__UpperCAmelCase	,				device=__UpperCAmelCase				)
    if token_type_ids is None:
       __lowerCamelCase													=    torch.zeros(__UpperCAmelCase	,				dtype=torch.long	,				device=__UpperCAmelCase				)

    # We can provide a self-attention mask of dimensions [batch_size, from_seq_length, to_seq_length]
    # ourselves in which case we just need to make it broadcastable to all heads.
    __lowerCamelCase													=    self.get_extended_attention_mask(__UpperCAmelCase	,				__UpperCAmelCase	,				__UpperCAmelCase				)

    # If a 2D ou 3D attention mask is provided for the cross-attention
    # we need to make broadcastable to [batch_size, num_heads, seq_length, seq_length]
    if encoder_attention_mask.dim() == 3:
       __lowerCamelCase													=    encoder_attention_mask[:, None, :, :]
    if encoder_attention_mask.dim() == 2:
       __lowerCamelCase													=    encoder_attention_mask[:, None, None, :]

    __lowerCamelCase													=    encoder_extended_attention_mask.to(
        dtype=next(self.parameters()				).dtype				)  # fp16 compatibility
    __lowerCamelCase													=    (1.0 - encoder_extended_attention_mask) * -10_000.0

    # Prepare head mask if needed
    # 1.0 in head_mask indicate we keep the head
    # attention_probs has shape bsz x n_heads x N x N
    # input head_mask has shape [num_heads] or [num_hidden_layers x num_heads]
    # and head_mask is converted to shape [num_hidden_layers x batch x num_heads x seq_length x seq_length]
    __lowerCamelCase													=    self.get_head_mask(__UpperCAmelCase	,				self.config.num_hidden_layers				)

    __lowerCamelCase													=    self.embeddings(
        input_ids=__UpperCAmelCase	,				position_ids=__UpperCAmelCase	,				token_type_ids=__UpperCAmelCase	,				inputs_embeds=__UpperCAmelCase				)
    __lowerCamelCase													=    self.encoder(
        __UpperCAmelCase	,				attention_mask=__UpperCAmelCase	,				head_mask=__UpperCAmelCase	,				encoder_hidden_states=__UpperCAmelCase	,				encoder_attention_mask=__UpperCAmelCase	,				)
    __lowerCamelCase													=    encoder_outputs[0]
    __lowerCamelCase													=    self.pooler(__UpperCAmelCase				)

    __lowerCamelCase													=    (
        sequence_output,
        pooled_output,
    ) + encoder_outputs[
        1:
    ]  # add hidden_states and attentions if they are here
    return outputs  # sequence_output, pooled_output, (hidden_states), (attentions), highway exits



class  __lowerCAmelCase     (	lowerCAmelCase__   ):




 def __init__(						self	,				__UpperCAmelCase	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    message
    __lowerCamelCase													=    exit_layer  # start from 1!



class  __lowerCAmelCase     (	nn.Module   ):




 def __init__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    super().__init__()
    __lowerCamelCase													=    BertPooler(__UpperCAmelCase				)
    __lowerCamelCase													=    nn.Dropout(config.hidden_dropout_prob				)
    __lowerCamelCase													=    nn.Linear(config.hidden_size	,				config.num_labels				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    # Pooler
    __lowerCamelCase													=    encoder_outputs[0]
    __lowerCamelCase													=    self.pooler(__UpperCAmelCase				)
    # "return" pooler_output

    # BertModel
    __lowerCamelCase													=    (pooler_input, pooler_output) + encoder_outputs[1:]
    # "return" bmodel_output

    # Dropout and classification
    __lowerCamelCase													=    bmodel_output[1]

    __lowerCamelCase													=    self.dropout(__UpperCAmelCase				)
    __lowerCamelCase													=    self.classifier(__UpperCAmelCase				)

    return logits, pooled_output



@add_start_docstrings(
    """Bert Model (with early exiting - DeeBERT) with a classifier on top,
    also takes care of multi-layer training. """  ,	lowerCAmelCase__  ,	)
class  __lowerCAmelCase     (	lowerCAmelCase__   ):




 def __init__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    super().__init__(__UpperCAmelCase				)
    __lowerCamelCase													=    config.num_labels
    __lowerCamelCase													=    config.num_hidden_layers

    __lowerCamelCase													=    DeeBertModel(__UpperCAmelCase				)
    __lowerCamelCase													=    nn.Dropout(config.hidden_dropout_prob				)
    __lowerCamelCase													=    nn.Linear(config.hidden_size	,				self.config.num_labels				)

    self.init_weights()




 @add_start_docstrings_to_model_forward(__UpperCAmelCase				)
 def        lowerCamelCase      (						self	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=-1	,				__UpperCAmelCase=False	,				):



    '''simple docstring'''
    __lowerCamelCase													=    self.num_layers
    try:
       __lowerCamelCase													=    self.bert(
           __UpperCAmelCase	,				attention_mask=__UpperCAmelCase	,				token_type_ids=__UpperCAmelCase	,				position_ids=__UpperCAmelCase	,				head_mask=__UpperCAmelCase	,				inputs_embeds=__UpperCAmelCase	,				)
       # sequence_output, pooled_output, (hidden_states), (attentions), highway exits

       __lowerCamelCase													=    outputs[1]

       __lowerCamelCase													=    self.dropout(__UpperCAmelCase				)
       __lowerCamelCase													=    self.classifier(__UpperCAmelCase				)
       __lowerCamelCase													=    (logits,) + outputs[2:]  # add hidden states and attention if they are here
    except HighwayException as e:
       __lowerCamelCase													=    e.message
       __lowerCamelCase													=    e.exit_layer
       __lowerCamelCase													=    outputs[0]

    if not self.training:
       __lowerCamelCase													=    entropy(__UpperCAmelCase				)
       __lowerCamelCase													=    []
       __lowerCamelCase													=    []
    if labels is not None:
       if self.num_labels == 1:
          #  We are doing regression
          __lowerCamelCase													=    MSELoss()
          __lowerCamelCase													=    loss_fct(logits.view(-1				)	,				labels.view(-1				)				)
       else:
          __lowerCamelCase													=    CrossEntropyLoss()
          __lowerCamelCase													=    loss_fct(logits.view(-1	,				self.num_labels				)	,				labels.view(-1				)				)

       # work with highway exits
       __lowerCamelCase													=    []
       for highway_exit in outputs[-1]:
          __lowerCamelCase													=    highway_exit[0]
          if not self.training:
             highway_logits_all.append(__UpperCAmelCase				)
             highway_entropy.append(highway_exit[2]				)
          if self.num_labels == 1:
             #  We are doing regression
             __lowerCamelCase													=    MSELoss()
             __lowerCamelCase													=    loss_fct(highway_logits.view(-1				)	,				labels.view(-1				)				)
          else:
             __lowerCamelCase													=    CrossEntropyLoss()
             __lowerCamelCase													=    loss_fct(highway_logits.view(-1	,				self.num_labels				)	,				labels.view(-1				)				)
          highway_losses.append(__UpperCAmelCase				)

       if train_highway:
          __lowerCamelCase													=    (sum(highway_losses[:-1]				),) + outputs
          # exclude the final highway, of course
       else:
          __lowerCamelCase													=    (loss,) + outputs
    if not self.training:
       __lowerCamelCase													=    outputs + ((original_entropy, highway_entropy), exit_layer)
       if output_layer >= 0:
          __lowerCamelCase													=    (
              (outputs[0],) + (highway_logits_all[output_layer],) + outputs[2:]
          )  # use the highway of the last layer

    return outputs  # (loss), logits, (hidden_states), (attentions), (highway_exits)











import os
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


a_			=					logging.get_logger(__name__)
a_			=					{"""vocab_file""": """spiece.model"""}

a_			=					{
    """vocab_file""": {
        """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/spiece.model""",
        """albert-large-v1""": """https://huggingface.co/albert-large-v1/resolve/main/spiece.model""",
        """albert-xlarge-v1""": """https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model""",
        """albert-xxlarge-v1""": """https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model""",
        """albert-base-v2""": """https://huggingface.co/albert-base-v2/resolve/main/spiece.model""",
        """albert-large-v2""": """https://huggingface.co/albert-large-v2/resolve/main/spiece.model""",
        """albert-xlarge-v2""": """https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model""",
        """albert-xxlarge-v2""": """https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model""",
    }
}

a_			=					{
    """albert-base-v1""": 512,
    """albert-large-v1""": 512,
    """albert-xlarge-v1""": 512,
    """albert-xxlarge-v1""": 512,
    """albert-base-v2""": 512,
    """albert-large-v2""": 512,
    """albert-xlarge-v2""": 512,
    """albert-xxlarge-v2""": 512,
}

a_			=					"""▁"""



class  __lowerCAmelCase     (	lowerCAmelCase__   ):
 lowerCAmelCase__       					=  VOCAB_FILES_NAMES
 lowerCAmelCase__       					=  PRETRAINED_VOCAB_FILES_MAP
 lowerCAmelCase__       					=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




 def __init__(						self	,				__UpperCAmelCase	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=False	,				__UpperCAmelCase="[CLS]"	,				__UpperCAmelCase="[SEP]"	,				__UpperCAmelCase="<unk>"	,				__UpperCAmelCase="[SEP]"	,				__UpperCAmelCase="<pad>"	,				__UpperCAmelCase="[CLS]"	,				__UpperCAmelCase="[MASK]"	,				__UpperCAmelCase = None	,				**__UpperCAmelCase	,				):



    '''simple docstring'''
    # Mask token behave like a normal word, i.e. include the space before it and
    # is included in the raw text, there should be a match in a non-normalized sentence.
    __lowerCamelCase													=    (
        AddedToken(__UpperCAmelCase	,				lstrip=__UpperCAmelCase	,				rstrip=__UpperCAmelCase	,				normalized=__UpperCAmelCase				)
        if isinstance(__UpperCAmelCase	,				__UpperCAmelCase				)
        else mask_token
    )

    __lowerCamelCase													=    {} if sp_model_kwargs is None else sp_model_kwargs

    super().__init__(
        do_lower_case=__UpperCAmelCase	,				remove_space=__UpperCAmelCase	,				keep_accents=__UpperCAmelCase	,				bos_token=__UpperCAmelCase	,				eos_token=__UpperCAmelCase	,				unk_token=__UpperCAmelCase	,				sep_token=__UpperCAmelCase	,				pad_token=__UpperCAmelCase	,				cls_token=__UpperCAmelCase	,				mask_token=__UpperCAmelCase	,				sp_model_kwargs=self.sp_model_kwargs	,				**__UpperCAmelCase	,				)

    __lowerCamelCase													=    do_lower_case
    __lowerCamelCase													=    remove_space
    __lowerCamelCase													=    keep_accents
    __lowerCamelCase													=    vocab_file

    __lowerCamelCase													=    spm.SentencePieceProcessor(**self.sp_model_kwargs				)
    self.sp_model.Load(__UpperCAmelCase				)




 @property
 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    return len(self.sp_model				)




 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    __lowerCamelCase													=    {self.convert_ids_to_tokens(__UpperCAmelCase				): i for i in range(self.vocab_size				)}
    vocab.update(self.added_tokens_encoder				)
    return vocab




 def __getstate__(						self				):



    '''simple docstring'''
    __lowerCamelCase													=    self.__dict__.copy()
    __lowerCamelCase													=    None
    return state




 def __setstate__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    d

    # for backward compatibility
    if not hasattr(self	,				'''sp_model_kwargs'''				):
       __lowerCamelCase													=    {}

    __lowerCamelCase													=    spm.SentencePieceProcessor(**self.sp_model_kwargs				)
    self.sp_model.Load(self.vocab_file				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    if self.remove_space:
       __lowerCamelCase													=    ''' '''.join(inputs.strip().split()				)
    else:
       __lowerCamelCase													=    inputs
    __lowerCamelCase													=    outputs.replace('''``'''	,				'''"'''				).replace('''\'\''''	,				'''"'''				)

    if not self.keep_accents:
       __lowerCamelCase													=    unicodedata.normalize('''NFKD'''	,				__UpperCAmelCase				)
       __lowerCamelCase													=    ''''''.join([c for c in outputs if not unicodedata.combining(__UpperCAmelCase				)]				)
    if self.do_lower_case:
       __lowerCamelCase													=    outputs.lower()

    return outputs




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    self.preprocess_text(__UpperCAmelCase				)
    __lowerCamelCase													=    self.sp_model.encode(__UpperCAmelCase	,				out_type=__UpperCAmelCase				)
    __lowerCamelCase													=    []
    for piece in pieces:
       if len(__UpperCAmelCase				) > 1 and piece[-1] == str(''','''				) and piece[-2].isdigit():
          __lowerCamelCase													=    self.sp_model.EncodeAsPieces(piece[:-1].replace(__UpperCAmelCase	,				''''''				)				)
          if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
             if len(cur_pieces[0]				) == 1:
                __lowerCamelCase													=    cur_pieces[1:]
             else:
                __lowerCamelCase													=    cur_pieces[0][1:]
          cur_pieces.append(piece[-1]				)
          new_pieces.extend(__UpperCAmelCase				)
       else:
          new_pieces.append(__UpperCAmelCase				)

    return new_pieces




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    return self.sp_model.PieceToId(__UpperCAmelCase				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    return self.sp_model.IdToPiece(__UpperCAmelCase				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    []
    __lowerCamelCase													=    ''''''
    __lowerCamelCase													=    False
    for token in tokens:
       # make sure that special tokens are not decoded using sentencepiece model
       if token in self.all_special_tokens:
          if not prev_is_special:
             out_string += " "
          out_string += self.sp_model.decode(__UpperCAmelCase				) + token
          __lowerCamelCase													=    True
          __lowerCamelCase													=    []
       else:
          current_sub_tokens.append(__UpperCAmelCase				)
          __lowerCamelCase													=    False
    out_string += self.sp_model.decode(__UpperCAmelCase				)
    return out_string.strip()




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None				):



    '''simple docstring'''
    __lowerCamelCase													=    [self.sep_token_id]
    __lowerCamelCase													=    [self.cls_token_id]
    if token_ids_a is None:
       return cls + token_ids_a + sep
    return cls + token_ids_a + sep + token_ids_a + sep




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None	,				__UpperCAmelCase = False				):



    '''simple docstring'''

    if already_has_special_tokens:
       return super().get_special_tokens_mask(
           token_ids_a=__UpperCAmelCase	,				token_ids_a=__UpperCAmelCase	,				already_has_special_tokens=__UpperCAmelCase				)

    if token_ids_a is not None:
       return [1] + ([0] * len(__UpperCAmelCase				)) + [1] + ([0] * len(__UpperCAmelCase				)) + [1]
    return [1] + ([0] * len(__UpperCAmelCase				)) + [1]




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None				):



    '''simple docstring'''
    __lowerCamelCase													=    [self.sep_token_id]
    __lowerCamelCase													=    [self.cls_token_id]

    if token_ids_a is None:
       return len(cls + token_ids_a + sep				) * [0]
    return len(cls + token_ids_a + sep				) * [0] + len(token_ids_a + sep				) * [1]




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None				):



    '''simple docstring'''
    if not os.path.isdir(__UpperCAmelCase				):
       logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""				)
       return
    __lowerCamelCase													=    os.path.join(
        __UpperCAmelCase	,				(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']				)

    if os.path.abspath(self.vocab_file				) != os.path.abspath(__UpperCAmelCase				) and os.path.isfile(self.vocab_file				):
       copyfile(self.vocab_file	,				__UpperCAmelCase				)
    elif not os.path.isfile(self.vocab_file				):
       with open(__UpperCAmelCase	,				'''wb'''				) as fi:
          __lowerCamelCase													=    self.sp_model.serialized_model_proto()
          fi.write(__UpperCAmelCase				)

    return (out_vocab_file,)






