
import unittest

from parameterized import parameterized

from transformers import OpenLlamaConfig, is_torch_available, set_seed
from transformers.testing_utils import require_torch, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch

   from transformers import OpenLlamaForCausalLM, OpenLlamaForSequenceClassification, OpenLlamaModel





class     __UpperCamelCase :






     """simple docstring"""







     def __init__(				self							:							Optional[Any]     ,						_A							:							Optional[Any]     ,						_A							:							str=13     ,						_A							:							Optional[int]=7     ,						_A							:							Any=True     ,						_A							:							Tuple=True     ,						_A							:							Any=False     ,						_A							:							Optional[Any]=True     ,						_A							:							Optional[int]=99     ,						_A							:							Dict=32     ,						_A							:							Any=5     ,						_A							:							int=4     ,						_A							:							Tuple=37     ,						_A							:							Optional[Any]="gelu"     ,						_A							:							Tuple=0.1     ,						_A							:							str=0.1     ,						_A							:							str=512     ,						_A							:							Tuple=16     ,						_A							:							Any=2     ,						_A							:							Dict=0.02     ,						_A							:							Union[str, Any]=3     ,						_A							:							Optional[Any]=4     ,						_A							:							str=None     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	List[str]					=		parent
       __SCREAMING_SNAKE_CASE      :	str					=		batch_size
       __SCREAMING_SNAKE_CASE      :	str					=		seq_length
       __SCREAMING_SNAKE_CASE      :	str					=		is_training
       __SCREAMING_SNAKE_CASE      :	Tuple					=		use_input_mask
       __SCREAMING_SNAKE_CASE      :	List[str]					=		use_token_type_ids
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		use_labels
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		vocab_size
       __SCREAMING_SNAKE_CASE      :	Any					=		hidden_size
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		num_hidden_layers
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		num_attention_heads
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		intermediate_size
       __SCREAMING_SNAKE_CASE      :	str					=		hidden_act
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		hidden_dropout_prob
       __SCREAMING_SNAKE_CASE      :	List[str]					=		attention_probs_dropout_prob
       __SCREAMING_SNAKE_CASE      :	str					=		max_position_embeddings
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		type_vocab_size
       __SCREAMING_SNAKE_CASE      :	int					=		type_sequence_label_size
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		initializer_range
       __SCREAMING_SNAKE_CASE      :	List[str]					=		num_labels
       __SCREAMING_SNAKE_CASE      :	Tuple					=		num_choices
       __SCREAMING_SNAKE_CASE      :	str					=		scope



     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	int					=		ids_tensor([self.batch_size, self.seq_length]     ,						self.vocab_size )

       __SCREAMING_SNAKE_CASE      :	List[Any]					=		None
       if self.use_input_mask:
         __SCREAMING_SNAKE_CASE      :	Tuple					=		random_attention_mask([self.batch_size, self.seq_length] )

       __SCREAMING_SNAKE_CASE      :	str					=		None
       if self.use_token_type_ids:
         __SCREAMING_SNAKE_CASE      :	List[str]					=		ids_tensor([self.batch_size, self.seq_length]     ,						self.type_vocab_size )

       __SCREAMING_SNAKE_CASE      :	str					=		None
       __SCREAMING_SNAKE_CASE      :	Dict					=		None
       __SCREAMING_SNAKE_CASE      :	List[str]					=		None
       if self.use_labels:
         __SCREAMING_SNAKE_CASE      :	List[str]					=		ids_tensor([self.batch_size]     ,						self.type_sequence_label_size )
         __SCREAMING_SNAKE_CASE      :	List[str]					=		ids_tensor([self.batch_size, self.seq_length]     ,						self.num_labels )
         __SCREAMING_SNAKE_CASE      :	List[Any]					=		ids_tensor([self.batch_size]     ,						self.num_choices )

       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		self.get_config()

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels



     def  UpperCAmelCase__							(				self							:							str ):







       """simple docstring"""




       return OpenLlamaConfig(
           vocab_size=self.vocab_size     ,						hidden_size=self.hidden_size     ,						num_hidden_layers=self.num_hidden_layers     ,						num_attention_heads=self.num_attention_heads     ,						intermediate_size=self.intermediate_size     ,						hidden_act=self.hidden_act     ,						hidden_dropout_prob=self.hidden_dropout_prob     ,						attention_probs_dropout_prob=self.attention_probs_dropout_prob     ,						max_position_embeddings=self.max_position_embeddings     ,						type_vocab_size=self.type_vocab_size     ,						is_decoder=_A     ,						initializer_range=self.initializer_range     ,						use_stable_embedding=_A     ,						)



     def  UpperCAmelCase__							(				self							:							str     ,						_A							:							str     ,						_A							:							Optional[int]     ,						_A							:							Dict     ,						_A							:							Optional[int]     ,						_A							:							Dict     ,						_A							:							List[Any]     ,						_A							:							Optional[int] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		OpenLlamaModel(config=_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		model(_A     ,						attention_mask=_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		model(_A )
       self.parent.assertEqual(result.last_hidden_state.shape     ,						(self.batch_size, self.seq_length, self.hidden_size) )



     def  UpperCAmelCase__							(				self							:							List[str]     ,						_A							:							Optional[Any]     ,						_A							:							Any     ,						_A							:							Dict     ,						_A							:							Union[str, Any]     ,						_A							:							Dict     ,						_A							:							str     ,						_A							:							List[str]     ,						_A							:							Optional[Any]     ,						_A							:							int     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	int					=		True
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		OpenLlamaModel(_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Tuple					=		model(
           _A     ,						attention_mask=_A     ,						encoder_hidden_states=_A     ,						encoder_attention_mask=_A     ,						)
       __SCREAMING_SNAKE_CASE      :	Tuple					=		model(
           _A     ,						attention_mask=_A     ,						encoder_hidden_states=_A     ,						)
       __SCREAMING_SNAKE_CASE      :	Tuple					=		model(_A     ,						attention_mask=_A )
       self.parent.assertEqual(result.last_hidden_state.shape     ,						(self.batch_size, self.seq_length, self.hidden_size) )



     def  UpperCAmelCase__							(				self							:							Union[str, Any]     ,						_A							:							Dict     ,						_A							:							Any     ,						_A							:							Optional[int]     ,						_A							:							Optional[Any]     ,						_A							:							str     ,						_A							:							List[str]     ,						_A							:							int     ,						_A							:							Union[str, Any]     ,						_A							:							Tuple     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	int					=		OpenLlamaForCausalLM(config=_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Dict					=		model(_A     ,						attention_mask=_A     ,						labels=_A )
       self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.seq_length, self.vocab_size) )



     def  UpperCAmelCase__							(				self							:							List[str]     ,						_A							:							List[Any]     ,						_A							:							Tuple     ,						_A							:							Tuple     ,						_A							:							Optional[Any]     ,						_A							:							List[str]     ,						_A							:							Dict     ,						_A							:							List[str]     ,						_A							:							Tuple     ,						_A							:							Any     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	int					=		True
       __SCREAMING_SNAKE_CASE      :	List[str]					=		True
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		OpenLlamaForCausalLM(config=_A )
       model.to(_A )
       model.eval()

       # first forward pass
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		model(
           _A     ,						attention_mask=_A     ,						encoder_hidden_states=_A     ,						encoder_attention_mask=_A     ,						use_cache=_A     ,						)
       __SCREAMING_SNAKE_CASE      :	int					=		outputs.past_key_values

       # create hypothetical multiple next token and extent to next_input_ids
       __SCREAMING_SNAKE_CASE      :	Tuple					=		ids_tensor((self.batch_size, 3)     ,						config.vocab_size )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		ids_tensor((self.batch_size, 3)     ,						vocab_size=2 )

       # append to next input_ids and
       __SCREAMING_SNAKE_CASE      :	int					=		torch.cat([input_ids, next_tokens]     ,						dim=-1 )
       __SCREAMING_SNAKE_CASE      :	Any					=		torch.cat([input_mask, next_mask]     ,						dim=-1 )

       __SCREAMING_SNAKE_CASE      :	List[str]					=		model(
           _A     ,						attention_mask=_A     ,						encoder_hidden_states=_A     ,						encoder_attention_mask=_A     ,						output_hidden_states=_A     ,						)['''hidden_states'''][0]
       __SCREAMING_SNAKE_CASE      :	str					=		model(
           _A     ,						attention_mask=_A     ,						encoder_hidden_states=_A     ,						encoder_attention_mask=_A     ,						past_key_values=_A     ,						output_hidden_states=_A     ,						)['''hidden_states'''][0]

       # select random slice
       __SCREAMING_SNAKE_CASE      :	Any					=		ids_tensor((1,)     ,						output_from_past.shape[-1] ).item()
       __SCREAMING_SNAKE_CASE      :	Any					=		output_from_no_past[:, -3:, random_slice_idx].detach()
       __SCREAMING_SNAKE_CASE      :	Dict					=		output_from_past[:, :, random_slice_idx].detach()

       self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1] )

       # test that outputs are equal for slice
       self.parent.assertTrue(torch.allclose(_A     ,						_A     ,						atol=1e-3 ) )




     def  UpperCAmelCase__							(				self							:							List[str] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		self.prepare_config_and_inputs()
       (
           (
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		(
           __SCREAMING_SNAKE_CASE
       ),		
       )      :	int					=		config_and_inputs
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		{'''input_ids''': input_ids, '''attention_mask''': input_mask}
       return config, inputs_dict






@require_torch
class     __UpperCamelCase (							lowerCAmelCase__ ,						lowerCAmelCase__ ,						lowerCAmelCase__ ,						unittest.TestCase       ):






     """simple docstring"""







     lowerCAmelCase_							   =			(
         (OpenLlamaModel, OpenLlamaForCausalLM, OpenLlamaForSequenceClassification) if is_torch_available() else ()
     )
     lowerCAmelCase_							   =			(OpenLlamaForCausalLM,) if is_torch_available() else ()
     lowerCAmelCase_							   =			(
         {
             '''feature-extraction''': OpenLlamaModel,
             '''text-classification''': OpenLlamaForSequenceClassification,
             '''text-generation''': OpenLlamaForCausalLM,
             '''zero-shot''': OpenLlamaForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     lowerCAmelCase_							   =			False
     lowerCAmelCase_							   =			False



     def  UpperCAmelCase__							(				self							:							int ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		OpenLlamaModelTester(self )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		ConfigTester(self     ,						config_class=_A     ,						hidden_size=37 )



     def  UpperCAmelCase__							(				self							:							List[str] ):







       """simple docstring"""




       self.config_tester.run_common_tests()



     def  UpperCAmelCase__							(				self							:							int ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*_A )



     def  UpperCAmelCase__							(				self							:							str ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		self.model_tester.prepare_config_and_inputs()
       for type in ["absolute", "relative_key", "relative_key_query"]:
         __SCREAMING_SNAKE_CASE      :	Optional[int]					=		type
         self.model_tester.create_and_check_model(*_A )



     def  UpperCAmelCase__							(				self							:							Dict ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE      :	str					=		self.model_tester.prepare_config_and_inputs_for_common()
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		3
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		input_dict['''input_ids''']
       __SCREAMING_SNAKE_CASE      :	Dict					=		input_ids.ne(1 ).to(_A )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		ids_tensor([self.model_tester.batch_size]     ,						self.model_tester.type_sequence_label_size )
       __SCREAMING_SNAKE_CASE      :	int					=		OpenLlamaForSequenceClassification(_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Any					=		model(_A     ,						attention_mask=_A     ,						labels=_A )
       self.assertEqual(result.logits.shape     ,						(self.model_tester.batch_size, self.model_tester.num_labels) )



     def  UpperCAmelCase__							(				self							:							Optional[int] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE      :	List[str]					=		self.model_tester.prepare_config_and_inputs_for_common()
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		3
       __SCREAMING_SNAKE_CASE      :	int					=		'''single_label_classification'''
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		input_dict['''input_ids''']
       __SCREAMING_SNAKE_CASE      :	Tuple					=		input_ids.ne(1 ).to(_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		ids_tensor([self.model_tester.batch_size]     ,						self.model_tester.type_sequence_label_size )
       __SCREAMING_SNAKE_CASE      :	int					=		OpenLlamaForSequenceClassification(_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Dict					=		model(_A     ,						attention_mask=_A     ,						labels=_A )
       self.assertEqual(result.logits.shape     ,						(self.model_tester.batch_size, self.model_tester.num_labels) )



     def  UpperCAmelCase__							(				self							:							List[str] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		self.model_tester.prepare_config_and_inputs_for_common()
       __SCREAMING_SNAKE_CASE      :	List[str]					=		3
       __SCREAMING_SNAKE_CASE      :	Dict					=		'''multi_label_classification'''
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		input_dict['''input_ids''']
       __SCREAMING_SNAKE_CASE      :	Any					=		input_ids.ne(1 ).to(_A )
       __SCREAMING_SNAKE_CASE      :	Any					=		ids_tensor(
           [self.model_tester.batch_size, config.num_labels]     ,						self.model_tester.type_sequence_label_size ).to(torch.float )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		OpenLlamaForSequenceClassification(_A )
       model.to(_A )
       model.eval()
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		model(_A     ,						attention_mask=_A     ,						labels=_A )
       self.assertEqual(result.logits.shape     ,						(self.model_tester.batch_size, self.model_tester.num_labels) )



     @unittest.skip('''Open-Llama buffers include complex numbers, which breaks this test''' )
     def  UpperCAmelCase__							(				self							:							Any ):







       """simple docstring"""




       pass




     @parameterized.expand([('''linear''',), ('''dynamic''',)] )
     def  UpperCAmelCase__							(				self							:							int     ,						_A							:							int ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE      :	List[str]					=		self.model_tester.prepare_config_and_inputs_for_common()
       __SCREAMING_SNAKE_CASE      :	str					=		ids_tensor([1, 10]     ,						config.vocab_size )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		ids_tensor([1, int(config.max_position_embeddings * 1.5 )]     ,						config.vocab_size )

       set_seed(42 )  # Fixed seed at init time so the two models get the same random weights
       __SCREAMING_SNAKE_CASE      :	Any					=		OpenLlamaModel(_A )
       original_model.to(_A )
       original_model.eval()
       __SCREAMING_SNAKE_CASE      :	int					=		original_model(_A ).last_hidden_state
       __SCREAMING_SNAKE_CASE      :	Dict					=		original_model(_A ).last_hidden_state

       set_seed(42 )  # Fixed seed at init time so the two models get the same random weights
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		{'''type''': scaling_type, '''factor''': 10.0}
       __SCREAMING_SNAKE_CASE      :	Any					=		OpenLlamaModel(_A )
       scaled_model.to(_A )
       scaled_model.eval()
       __SCREAMING_SNAKE_CASE      :	Any					=		scaled_model(_A ).last_hidden_state
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		scaled_model(_A ).last_hidden_state

       # Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
       # maximum sequence length, so the outputs for the short input should match.
       if scaling_type == "dynamic":
         self.assertTrue(torch.allclose(_A     ,						_A     ,						atol=1e-5 ) )
       else:
         self.assertFalse(torch.allclose(_A     ,						_A     ,						atol=1e-5 ) )

       # The output should be different for long inputs
       self.assertFalse(torch.allclose(_A     ,						_A     ,						atol=1e-5 ) )







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

import sentencepiece as spm

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


SCREAMING_SNAKE_CASE__							:      Tuple         =    logging.get_logger(__name__)


SCREAMING_SNAKE_CASE__							:      int         =    """▁"""

SCREAMING_SNAKE_CASE__							:      Union[str, Any]         =    {"""vocab_file""": """spiece.model"""}

SCREAMING_SNAKE_CASE__							:      Optional[int]         =    {
    """vocab_file""": {
        """google/reformer-crime-and-punishment""": (
            """https://huggingface.co/google/reformer-crime-and-punishment/resolve/main/spiece.model"""
        )
    }
}

SCREAMING_SNAKE_CASE__							:      Optional[Any]         =    {
    """google/reformer-crime-and-punishment""": 5_2_4_2_8_8,
}







class 	__lowerCAmelCase      (       _UpperCamelCase	):
   _UpperCamelCase			:    List[Any]  		=					VOCAB_FILES_NAMES
   _UpperCamelCase			:    Any  		=					PRETRAINED_VOCAB_FILES_MAP
   _UpperCamelCase			:    Any  		=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _UpperCamelCase			:    Tuple  		=					["""input_ids""", """attention_mask"""]





   def __init__(			self       ,      snake_case       ,      snake_case="</s>"       ,      snake_case="<unk>"       ,      snake_case=[]       ,      snake_case = None       ,      **snake_case       ,      )					->	None:
      """simple docstring"""





      a__						:    Optional[Any]   		=	{} if sp_model_kwargs is None else sp_model_kwargs

      super().__init__(
          eos_token=snake_case       ,      unk_token=snake_case       ,      additional_special_tokens=snake_case       ,      sp_model_kwargs=self.sp_model_kwargs       ,      **snake_case       ,      )

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





   @property
   def 						_snake_case			(			self   )					->	str:
      """simple docstring"""





      return self.sp_model.get_piece_size()





   def 						_snake_case			(			self   )					->	Dict[str, int]:
      """simple docstring"""





      a__						:    Dict   		=	{self.convert_ids_to_tokens(snake_case   ): i for i in range(self.vocab_size   )}
      vocab.update(self.added_tokens_encoder   )
      return vocab





   def __getstate__(			self   )					->	Any:
      """simple docstring"""





      a__						:    Tuple   		=	self.__dict__.copy()
      a__						:    Optional[int]   		=	None
      return state





   def __setstate__(			self       ,      snake_case   )					->	Union[str, Any]:
      """simple docstring"""





      a__						:    List[Any]   		=	d

      # for backward compatibility
      if not hasattr(self       ,      "sp_model_kwargs"   ):
         a__						:    List[Any]   		=	{}

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





   def 						_snake_case			(			self       ,      snake_case   )					->	List[str]:
      """simple docstring"""





      return self.sp_model.encode(snake_case       ,      out_type=snake_case   )





   def 						_snake_case			(			self       ,      snake_case   )					->	Union[str, Any]:
      """simple docstring"""





      return self.sp_model.piece_to_id(snake_case   )





   def 						_snake_case			(			self       ,      snake_case   )					->	Any:
      """simple docstring"""





      if index < self.sp_model.get_piece_size():
         a__						:    Optional[Any]   		=	self.sp_model.IdToPiece(snake_case   )
      return token





   def 						_snake_case			(			self       ,      snake_case   )					->	Any:
      """simple docstring"""





      a__						:    int   		=	[]
      a__						:    Dict   		=	""
      for token in tokens:
         # make sure that special tokens are not decoded using sentencepiece model
         if token in self.all_special_tokens:
            out_string += self.sp_model.decode(snake_case   ) + token
            a__						:    Dict   		=	[]
         else:
            current_sub_tokens.append(snake_case   )
      out_string += self.sp_model.decode(snake_case   )
      return out_string.strip()





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case = None   )					->	Tuple[str]:
      """simple docstring"""





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

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

      return (out_vocab_file,)

