




'''simple docstring'''





from dataclasses import dataclass
from typing import Any, Dict, Optional

import torch
import torch.nn.functional as F
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..models.embeddings import ImagePositionalEmbeddings
from ..utils import BaseOutput, deprecate
from .attention import BasicTransformerBlock
from .embeddings import PatchEmbed
from .modeling_utils import ModelMixin






@dataclass
class 						lowercase     (   a_):
      __lowercase 		=  42






class 						lowercase     (   a_				,			a_):






      @register_to_config
      def __init__(self ,  a__ = 1_6 ,  a__ = 8_8 ,  a__ = None ,  a__ = None ,  a__ = 1 ,  a__ = 0.0 ,  a__ = 3_2 ,  a__ = None ,  a__ = False ,  a__ = None ,  a__ = None ,  a__ = None ,  a__ = "geglu" ,  a__ = None ,  a__ = False ,  a__ = False ,  a__ = False ,  a__ = "layer_norm" ,  a__ = True ,  )       ->   int:
         super().__init__()
         SCREAMING_SNAKE_CASE__			:				Tuple       						= use_linear_projection
         SCREAMING_SNAKE_CASE__			:				Tuple       						= num_attention_heads
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= attention_head_dim
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= num_attention_heads * attention_head_dim

         # 1. Transformer2DModel can process both standard continuous images of shape `(batch_size, num_channels, width, height)` as well as quantized image embeddings of shape `(batch_size, num_image_vectors)`
         # Define whether input is continuous or discrete depending on configuration
         SCREAMING_SNAKE_CASE__			:				int       						= (in_channels is not None) and (patch_size is None)
         SCREAMING_SNAKE_CASE__			:				Tuple       						= num_vector_embeds is not None
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= in_channels is not None and patch_size is not None

         if norm_type == "layer_norm" and num_embeds_ada_norm is not None:
            SCREAMING_SNAKE_CASE__			:				int       						= (
                f"""The configuration file of this model: {self.__class__} is outdated. `norm_type` is either not set or"""
                ''' incorrectly set to `\'layer_norm\'`.Make sure to set `norm_type` to `\'ada_norm\'` in the config.'''
                ''' Please make sure to update the config accordingly as leaving `norm_type` might led to incorrect'''
                ''' results in future versions. If you have downloaded this checkpoint from the Hugging Face Hub, it'''
                ''' would be very nice if you could open a Pull request for the `transformer/config.json` file'''
            )
            deprecate('''norm_type!=num_embeds_ada_norm''' ,  '''1.0.0''' ,  _snake_case ,  standard_warn=_snake_case					)
            SCREAMING_SNAKE_CASE__			:				List[str]       						= '''ada_norm'''

         if self.is_input_continuous and self.is_input_vectorized:
            raise ValueError(
                f"""Cannot define both `in_channels`: {in_channels} and `num_vector_embeds`: {num_vector_embeds}. Make"""
                ''' sure that either `in_channels` or `num_vector_embeds` is None.'''					)
         elif self.is_input_vectorized and self.is_input_patches:
            raise ValueError(
                f"""Cannot define both `num_vector_embeds`: {num_vector_embeds} and `patch_size`: {patch_size}. Make"""
                ''' sure that either `num_vector_embeds` or `num_patches` is None.'''					)
         elif not self.is_input_continuous and not self.is_input_vectorized and not self.is_input_patches:
            raise ValueError(
                f"""Has to define `in_channels`: {in_channels}, `num_vector_embeds`: {num_vector_embeds}, or patch_size:"""
                f""" {patch_size}. Make sure that `in_channels`, `num_vector_embeds` or `num_patches` is not None."""					)

         # 2. Define input layers
         if self.is_input_continuous:
            SCREAMING_SNAKE_CASE__			:				List[str]       						= in_channels

            SCREAMING_SNAKE_CASE__			:				Dict       						= torch.nn.GroupNorm(num_groups=_snake_case ,  num_channels=_snake_case ,  eps=1E-6 ,  affine=_snake_case					)
            if use_linear_projection:
               SCREAMING_SNAKE_CASE__			:				Dict       						= nn.Linear(_snake_case ,  _snake_case					)
            else:
               SCREAMING_SNAKE_CASE__			:				Tuple       						= nn.Convad(_snake_case ,  _snake_case ,  kernel_size=1 ,  stride=1 ,  padding=0					)
         elif self.is_input_vectorized:
            assert sample_size is not None, "Transformer2DModel over discrete input must provide sample_size"
            assert num_vector_embeds is not None, "Transformer2DModel over discrete input must provide num_embed"

            SCREAMING_SNAKE_CASE__			:				Dict       						= sample_size
            SCREAMING_SNAKE_CASE__			:				Any       						= sample_size
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= num_vector_embeds
            SCREAMING_SNAKE_CASE__			:				Tuple       						= self.height * self.width

            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= ImagePositionalEmbeddings(
                num_embed=_snake_case ,  embed_dim=_snake_case ,  height=self.height ,  width=self.width					)
         elif self.is_input_patches:
            assert sample_size is not None, "Transformer2DModel over patched input must provide sample_size"

            SCREAMING_SNAKE_CASE__			:				List[Any]       						= sample_size
            SCREAMING_SNAKE_CASE__			:				Any       						= sample_size

            SCREAMING_SNAKE_CASE__			:				List[Any]       						= patch_size
            SCREAMING_SNAKE_CASE__			:				Any       						= PatchEmbed(
                height=_snake_case ,  width=_snake_case ,  patch_size=_snake_case ,  in_channels=_snake_case ,  embed_dim=_snake_case ,  )

         # 3. Define transformers blocks
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= nn.ModuleList(
             [
                 BasicTransformerBlock(
                     _snake_case ,  _snake_case ,  _snake_case ,  dropout=_snake_case ,  cross_attention_dim=_snake_case ,  activation_fn=_snake_case ,  num_embeds_ada_norm=_snake_case ,  attention_bias=_snake_case ,  only_cross_attention=_snake_case ,  upcast_attention=_snake_case ,  norm_type=_snake_case ,  norm_elementwise_affine=_snake_case ,  )
                 for d in range(_snake_case					)
             ]					)

         # 4. Define output layers
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= in_channels if out_channels is None else out_channels
         if self.is_input_continuous:
            # TODO: should use out_channels for continuous projections
            if use_linear_projection:
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= nn.Linear(_snake_case ,  _snake_case					)
            else:
               SCREAMING_SNAKE_CASE__			:				Dict       						= nn.Convad(_snake_case ,  _snake_case ,  kernel_size=1 ,  stride=1 ,  padding=0					)
         elif self.is_input_vectorized:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= nn.LayerNorm(_snake_case					)
            SCREAMING_SNAKE_CASE__			:				List[str]       						= nn.Linear(_snake_case ,  self.num_vector_embeds - 1					)
         elif self.is_input_patches:
            SCREAMING_SNAKE_CASE__			:				Dict       						= nn.LayerNorm(_snake_case ,  elementwise_affine=_snake_case ,  eps=1E-6					)
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= nn.Linear(_snake_case ,  2 * inner_dim					)
            SCREAMING_SNAKE_CASE__			:				Tuple       						= nn.Linear(_snake_case ,  patch_size * patch_size * self.out_channels					)






      def    A__(self ,  a__ ,  a__ = None ,  a__ = None ,  a__ = None ,  a__ = None ,  a__ = None ,  a__ = None ,  a__ = True ,  )       ->   Any:
         # ensure attention_mask is a bias, and give it a singleton query_tokens dimension.
         #   we may have done this conversion already, e.g. if we came here via UNet2DConditionModel#forward.
         #   we can tell by counting dims; if ndim == 2: it's a mask rather than a bias.
         # expects mask of shape:
         #   [batch, key_tokens]
         # adds singleton query_tokens dimension:
         #   [batch,                    1, key_tokens]
         # this helps to broadcast it as a bias over attention scores, which will be in one of the following shapes:
         #   [batch,  heads, query_tokens, key_tokens] (e.g. torch sdp attn)
         #   [batch * heads, query_tokens, key_tokens] (e.g. xformers or classic attn)
         if attention_mask is not None and attention_mask.ndim == 2:
            # assume that mask is expressed as:
            #   (1 = keep,      0 = discard)
            # convert mask into a bias that can be added to attention scores:
            #       (keep = +0,     discard = -10000.0)
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= (1 - attention_mask.to(hidden_states.dtype					)) * -1_0_0_0_0.0
            SCREAMING_SNAKE_CASE__			:				List[str]       						= attention_mask.unsqueeze(1					)

         # convert encoder_attention_mask to a bias the same way we do for attention_mask
         if encoder_attention_mask is not None and encoder_attention_mask.ndim == 2:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= (1 - encoder_attention_mask.to(hidden_states.dtype					)) * -1_0_0_0_0.0
            SCREAMING_SNAKE_CASE__			:				Any       						= encoder_attention_mask.unsqueeze(1					)

         # 1. Input
         if self.is_input_continuous:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= hidden_states.shape
            SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_states

            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= self.norm(_snake_case					)
            if not self.use_linear_projection:
               SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.proj_in(_snake_case					)
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= hidden_states.shape[1]
               SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= hidden_states.permute(0 ,  2 ,  3 ,  1					).reshape(_snake_case ,  height * width ,  _snake_case					)
            else:
               SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= hidden_states.shape[1]
               SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_states.permute(0 ,  2 ,  3 ,  1					).reshape(_snake_case ,  height * width ,  _snake_case					)
               SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.proj_in(_snake_case					)
         elif self.is_input_vectorized:
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.latent_image_embedding(_snake_case					)
         elif self.is_input_patches:
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.pos_embed(_snake_case					)

         # 2. Blocks
         for block in self.transformer_blocks:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= block(
                _snake_case ,  attention_mask=_snake_case ,  encoder_hidden_states=_snake_case ,  encoder_attention_mask=_snake_case ,  timestep=_snake_case ,  cross_attention_kwargs=_snake_case ,  class_labels=_snake_case ,  )

         # 3. Output
         if self.is_input_continuous:
            if not self.use_linear_projection:
               SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= hidden_states.reshape(_snake_case ,  _snake_case ,  _snake_case ,  _snake_case					).permute(0 ,  3 ,  1 ,  2					).contiguous()
               SCREAMING_SNAKE_CASE__			:				Dict       						= self.proj_out(_snake_case					)
            else:
               SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.proj_out(_snake_case					)
               SCREAMING_SNAKE_CASE__			:				List[str]       						= hidden_states.reshape(_snake_case ,  _snake_case ,  _snake_case ,  _snake_case					).permute(0 ,  3 ,  1 ,  2					).contiguous()

            SCREAMING_SNAKE_CASE__			:				str       						= hidden_states + residual
         elif self.is_input_vectorized:
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= self.norm_out(_snake_case					)
            SCREAMING_SNAKE_CASE__			:				Any       						= self.out(_snake_case					)
            # (batch, self.num_vector_embeds - 1, self.num_latent_pixels)
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= logits.permute(0 ,  2 ,  1					)

            # log(p(x_0))
            SCREAMING_SNAKE_CASE__			:				List[str]       						= F.log_softmax(logits.double() ,  dim=1					).float()
         elif self.is_input_patches:
            # TODO: cleanup!
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.transformer_blocks[0].norma.emb(
                _snake_case ,  _snake_case ,  hidden_dtype=hidden_states.dtype					)
            SCREAMING_SNAKE_CASE__			:				List[str]       						= self.proj_out_a(F.silu(_snake_case					)					).chunk(2 ,  dim=1					)
            SCREAMING_SNAKE_CASE__			:				List[str]       						= self.norm_out(_snake_case					) * (1 + scale[:, None]) + shift[:, None]
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.proj_out_a(_snake_case					)

            # unpatchify
            SCREAMING_SNAKE_CASE__			:				Optional[int]       						= int(hidden_states.shape[1] ** 0.5					)
            SCREAMING_SNAKE_CASE__			:				Dict       						= hidden_states.reshape(
                shape=(-1, height, width, self.patch_size, self.patch_size, self.out_channels)					)
            SCREAMING_SNAKE_CASE__			:				str       						= torch.einsum('''nhwpqc->nchpwq''' ,  _snake_case					)
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= hidden_states.reshape(
                shape=(-1, self.out_channels, height * self.patch_size, width * self.patch_size)					)

         if not return_dict:
            return (output,)

         return TransformeraDModelOutput(sample=_snake_case					)







'''simple docstring'''





import os
import re
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


lowercase__			=	logging.get_logger(__name__)
lowercase__			=	{'''vocab_file''': '''spiece.model'''}

lowercase__			=	{
    '''vocab_file''': {
        '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/spiece.model''',
        '''google/fnet-large''': '''https://huggingface.co/google/fnet-large/resolve/main/spiece.model''',
    },
}

lowercase__			=	{
    '''google/fnet-base''': 5_1_2,
    '''google/fnet-large''': 5_1_2,
}

lowercase__			=	'''▁'''






class 						lowercase     (   UpperCAmelCase_):
      __lowercase 		=  VOCAB_FILES_NAMES
      __lowercase 		=  PRETRAINED_VOCAB_FILES_MAP
      __lowercase 		=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      __lowercase 		=  ['''input_ids''', '''token_type_ids''']






      def __init__(self ,  a__ ,  a__=False ,  a__=True ,  a__=True ,  a__="<unk>" ,  a__="[SEP]" ,  a__="<pad>" ,  a__="[CLS]" ,  a__="[MASK]" ,  a__ = None ,  **a__ ,  )       ->   None:
         # 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.
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= (
             AddedToken(a__ ,  lstrip=a__ ,  rstrip=a__ ,  normalized=a__					)
             if isinstance(a__ ,  a__					)
             else mask_token
         )

         SCREAMING_SNAKE_CASE__			:				Any       						= {} if sp_model_kwargs is None else sp_model_kwargs

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

         SCREAMING_SNAKE_CASE__			:				Dict       						= do_lower_case
         SCREAMING_SNAKE_CASE__			:				Tuple       						= remove_space
         SCREAMING_SNAKE_CASE__			:				List[str]       						= keep_accents
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= vocab_file

         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= spm.SentencePieceProcessor(**self.sp_model_kwargs					)
         self.sp_model.Load(a__					)






      @property
      def    A__(self					)       ->   Union[str, Any]:
         return len(self.sp_model					)






      def    A__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				int       						= {self.convert_ids_to_tokens(a__					): i for i in range(self.vocab_size					)}
         vocab.update(self.added_tokens_encoder					)
         return vocab






      def __getstate__(self					)       ->   Any:
         SCREAMING_SNAKE_CASE__			:				List[str]       						= self.__dict__.copy()
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= None
         return state






      def __setstate__(self ,  a__					)       ->   int:
         SCREAMING_SNAKE_CASE__			:				Any       						= d

         # for backward compatibility
         if not hasattr(self ,  '''sp_model_kwargs'''					):
            SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= {}

         SCREAMING_SNAKE_CASE__			:				int       						= spm.SentencePieceProcessor(**self.sp_model_kwargs					)
         self.sp_model.Load(self.vocab_file					)






      def    A__(self ,  a__					)       ->   str:
         if self.remove_space:
            SCREAMING_SNAKE_CASE__			:				List[str]       						= ''' '''.join(inputs.strip().split()					)
         else:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= inputs
         SCREAMING_SNAKE_CASE__			:				Dict       						= outputs.replace('''``''' ,  '''"'''					).replace('''\'\'''' ,  '''"'''					)

         if not self.keep_accents:
            SCREAMING_SNAKE_CASE__			:				Dict       						= unicodedata.normalize('''NFKD''' ,  a__					)
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= ''''''.join([c for c in outputs if not unicodedata.combining(a__					)]					)
         if self.do_lower_case:
            SCREAMING_SNAKE_CASE__			:				str       						= outputs.lower()

         return outputs






      def    A__(self ,  a__					)       ->   List[str]:
         SCREAMING_SNAKE_CASE__			:				Dict       						= self.preprocess_text(a__					)
         SCREAMING_SNAKE_CASE__			:				List[str]       						= self.sp_model.encode(a__ ,  out_type=a__					)
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= []
         for piece in pieces:
            if len(a__					) > 1 and piece[-1] == str(''','''					) and piece[-2].isdigit():
               SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= self.sp_model.EncodeAsPieces(piece[:-1].replace(a__ ,  ''''''					)					)
               if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
                  if len(cur_pieces[0]					) == 1:
                     SCREAMING_SNAKE_CASE__			:				List[str]       						= cur_pieces[1:]
                  else:
                     SCREAMING_SNAKE_CASE__			:				str       						= cur_pieces[0][1:]
               cur_pieces.append(piece[-1]					)
               new_pieces.extend(a__					)
            else:
               new_pieces.append(a__					)

         return new_pieces






      def    A__(self ,  a__					)       ->   str:
         return self.sp_model.PieceToId(a__					)






      def    A__(self ,  a__					)       ->   Optional[int]:
         return self.sp_model.IdToPiece(a__					)






      def    A__(self ,  a__					)       ->   Optional[Any]:
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= []
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= ''''''
         SCREAMING_SNAKE_CASE__			:				Any       						= 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(a__					) + token
               SCREAMING_SNAKE_CASE__			:				List[Any]       						= True
               SCREAMING_SNAKE_CASE__			:				int       						= []
            else:
               current_sub_tokens.append(a__					)
               SCREAMING_SNAKE_CASE__			:				Dict       						= False
         out_string += self.sp_model.decode(a__					)
         return out_string.strip()






      def    A__(self ,  a__ ,  a__ = False ,  a__ = None ,  a__ = True ,  **a__ ,  )       ->   str:
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= kwargs.pop('''use_source_tokenizer''' ,  a__					)

         SCREAMING_SNAKE_CASE__			:				int       						= self.convert_ids_to_tokens(a__ ,  skip_special_tokens=a__					)

         # To avoid mixing byte-level and unicode for byte-level BPT
         # we need to build string separately for added tokens and byte-level tokens
         # cf. https://github.com/huggingface/transformers/issues/1133
         SCREAMING_SNAKE_CASE__			:				Dict       						= []
         SCREAMING_SNAKE_CASE__			:				List[str]       						= []
         for token in filtered_tokens:
            if skip_special_tokens and token in self.all_special_ids:
               continue
            if token in self.added_tokens_encoder:
               if current_sub_text:
                  sub_texts.append(self.convert_tokens_to_string(a__					)					)
                  SCREAMING_SNAKE_CASE__			:				List[str]       						= []
               sub_texts.append(a__					)
            else:
               current_sub_text.append(a__					)
         if current_sub_text:
            sub_texts.append(self.convert_tokens_to_string(a__					)					)

         # Mimic the behavior of the Rust tokenizer:
         # No space after <unk>
         if spaces_between_special_tokens:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= re.sub(R'''(<unk>) ''' ,  R'''\1''' ,  ''' '''.join(a__					)					)
         else:
            SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= ''''''.join(a__					)

         SCREAMING_SNAKE_CASE__			:				int       						= (
             clean_up_tokenization_spaces
             if clean_up_tokenization_spaces is not None
             else self.clean_up_tokenization_spaces
         )
         if clean_up_tokenization_spaces:
            SCREAMING_SNAKE_CASE__			:				str       						= self.clean_up_tokenization(a__					)
            return clean_text
         else:
            return text






      def    A__(self ,  a__ ,  a__ = None					)       ->   List[int]:
         SCREAMING_SNAKE_CASE__			:				str       						= [self.sep_token_id]
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= [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    A__(self ,  a__ ,  a__ = None ,  a__ = False					)       ->   List[int]:

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

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






      def    A__(self ,  a__ ,  a__ = None					)       ->   List[int]:
         SCREAMING_SNAKE_CASE__			:				List[str]       						= [self.sep_token_id]
         SCREAMING_SNAKE_CASE__			:				Tuple       						= [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    A__(self ,  a__ ,  a__ = None					)       ->   Tuple[str]:
         if not os.path.isdir(a__					):
            logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""					)
            return
         SCREAMING_SNAKE_CASE__			:				str       						= os.path.join(
             a__ ,  (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']					)

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

         return (out_vocab_file,)

