






'''simple docstring'''







from __future__ import annotations

import unittest

from transformers import EsmConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import numpy
		import tensorflow as tf

		from transformers.models.esm.modeling_tf_esm import (
		    TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFEsmForMaskedLM,
		    TFEsmForSequenceClassification,
		    TFEsmForTokenClassification,
		    TFEsmModel,
		)





class 	SCREAMING_SNAKE_CASE					:






			def __init__( self      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			List[Any]  ,						)			->			Optional[int]:
							a_		:  Dict											=      parent
							a_		:  Union[str, Any]											=      13
							a_		:  int											=      7
							a_		:  List[Any]											=      True
							a_		:  Optional[Any]											=      True
							a_		:  Union[str, Any]											=      True
							a_		:  Union[str, Any]											=      99
							a_		:  Tuple											=      32
							a_		:  Dict											=      2
							a_		:  Optional[Any]											=      4
							a_		:  Union[str, Any]											=      37
							a_		:  Dict											=      '''gelu'''
							a_		:  Union[str, Any]											=      0.1
							a_		:  int											=      0.1
							a_		:  Dict											=      512
							a_		:  Optional[Any]											=      16
							a_		:  List[Any]											=      2
							a_		:  Optional[Any]											=      0.02
							a_		:  Any											=      3
							a_		:  Tuple											=      4
							a_		:  Union[str, Any]											=      None






			def 			SCREAMING_SNAKE_CASE      ( self      :			Tuple					)			->			Union[str, Any]:
							a_		:  Dict											=      ids_tensor([self.batch_size, self.seq_length]  ,						self.vocab_size					)

							a_		:  int											=      None
							if self.use_input_mask:
											a_		:  str											=      random_attention_mask([self.batch_size, self.seq_length]					)

							a_		:  Union[str, Any]											=      None
							a_		:  Union[str, Any]											=      None
							a_		:  Optional[Any]											=      None
							if self.use_labels:
											a_		:  str											=      ids_tensor([self.batch_size]  ,						self.type_sequence_label_size					)
											a_		:  Union[str, Any]											=      ids_tensor([self.batch_size, self.seq_length]  ,						self.num_labels					)
											a_		:  int											=      ids_tensor([self.batch_size]  ,						self.num_choices					)

							a_		:  Optional[Any]											=      EsmConfig(
							    vocab_size=self.vocab_size  ,						hidden_size=self.hidden_size  ,						num_hidden_layers=self.num_hidden_layers  ,						pad_token_id=1  ,						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  ,						initializer_range=self.initializer_range  ,						)

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






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[Any]					)			->			Optional[int]:
							(
							    (
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			
							)		:  int											=      self.prepare_config_and_inputs()

							a_		:  int											=      True
							a_		:  Optional[Any]											=      floats_tensor([self.batch_size, self.seq_length, self.hidden_size]					)
							a_		:  Optional[Any]											=      ids_tensor([self.batch_size, self.seq_length]  ,						vocab_size=2					)

							return (
							    config,
							    input_ids,
							    input_mask,
							    sequence_labels,
							    token_labels,
							    choice_labels,
							    encoder_hidden_states,
							    encoder_attention_mask,
							)






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[Any]  ,						__SCREAMING_SNAKE_CASE      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]  ,						__SCREAMING_SNAKE_CASE      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			int					)			->			List[Any]:
							a_		:  str											=      TFEsmModel(config=__SCREAMING_SNAKE_CASE					)
							a_		:  Optional[int]											=      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
							a_		:  Union[str, Any]											=      model(__SCREAMING_SNAKE_CASE					)

							a_		:  int											=      [input_ids, input_mask]
							a_		:  Optional[int]											=      model(__SCREAMING_SNAKE_CASE					)

							a_		:  Optional[Any]											=      model(__SCREAMING_SNAKE_CASE					)

							self.parent.assertEqual(result.last_hidden_state.shape  ,						(self.batch_size, self.seq_length, self.hidden_size)					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			List[Any]  ,						__SCREAMING_SNAKE_CASE      :			Any  ,						__SCREAMING_SNAKE_CASE      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			Any  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]  ,						__SCREAMING_SNAKE_CASE      :			List[Any]  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			Optional[int]  ,						)			->			int:
							a_		:  Any											=      True

							a_		:  Union[str, Any]											=      TFEsmModel(config=__SCREAMING_SNAKE_CASE					)
							a_		:  Optional[Any]											=      {
							    '''input_ids''': input_ids,
							    '''attention_mask''': input_mask,
							    '''encoder_hidden_states''': encoder_hidden_states,
							    '''encoder_attention_mask''': encoder_attention_mask,
							}
							a_		:  Dict											=      model(__SCREAMING_SNAKE_CASE					)

							a_		:  str											=      [input_ids, input_mask]
							a_		:  Any											=      model(__SCREAMING_SNAKE_CASE  ,						encoder_hidden_states=__SCREAMING_SNAKE_CASE					)

							# Also check the case where encoder outputs are not passed
							a_		:  Union[str, Any]											=      model(__SCREAMING_SNAKE_CASE  ,						attention_mask=__SCREAMING_SNAKE_CASE					)

							self.parent.assertEqual(result.last_hidden_state.shape  ,						(self.batch_size, self.seq_length, self.hidden_size)					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]  ,						__SCREAMING_SNAKE_CASE      :			str  ,						__SCREAMING_SNAKE_CASE      :			List[Any]  ,						__SCREAMING_SNAKE_CASE      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			Tuple  ,						__SCREAMING_SNAKE_CASE      :			int					)			->			List[Any]:
							a_		:  Optional[int]											=      TFEsmForMaskedLM(config=__SCREAMING_SNAKE_CASE					)
							a_		:  List[Any]											=      model([input_ids, input_mask]					)
							self.parent.assertEqual(result.logits.shape  ,						(self.batch_size, self.seq_length, self.vocab_size)					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			int  ,						__SCREAMING_SNAKE_CASE      :			int  ,						__SCREAMING_SNAKE_CASE      :			int  ,						__SCREAMING_SNAKE_CASE      :			Union[str, Any]  ,						__SCREAMING_SNAKE_CASE      :			Tuple  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]					)			->			Union[str, Any]:
							a_		:  str											=      self.num_labels
							a_		:  int											=      TFEsmForTokenClassification(config=__SCREAMING_SNAKE_CASE					)
							a_		:  Tuple											=      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
							a_		:  str											=      model(__SCREAMING_SNAKE_CASE					)
							self.parent.assertEqual(result.logits.shape  ,						(self.batch_size, self.seq_length, self.num_labels)					)







			def 			SCREAMING_SNAKE_CASE      ( self      :			Union[str, Any]					)			->			str:
							a_		:  List[Any]											=      self.prepare_config_and_inputs()
							(
							    (
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			(
							    a_
							)				,			
							)		:  Union[str, Any]											=      config_and_inputs
							a_		:  List[str]											=      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
							return config, inputs_dict





@require_tf
class 	SCREAMING_SNAKE_CASE					(					SCREAMING_SNAKE_CASE_	,   SCREAMING_SNAKE_CASE_	,   unittest.TestCase       ):
			snake_case__  =				(
			    (
			        TFEsmModel,
			        TFEsmForMaskedLM,
			        TFEsmForSequenceClassification,
			        TFEsmForTokenClassification,
			    )
			    if is_tf_available()
			    else ()
			)
			snake_case__  =				(
			    {
			        "feature-extraction": TFEsmModel,
			        "fill-mask": TFEsmForMaskedLM,
			        "text-classification": TFEsmForSequenceClassification,
			        "token-classification": TFEsmForTokenClassification,
			        "zero-shot": TFEsmForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			snake_case__  =				False
			snake_case__  =				False






			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			Optional[Any]:
							a_		:  Any											=      TFEsmModelTester(self					)
							a_		:  Union[str, Any]											=      ConfigTester(self  ,						config_class=__SCREAMING_SNAKE_CASE  ,						hidden_size=37					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			Any:
							self.config_tester.run_common_tests()






			def 			SCREAMING_SNAKE_CASE      ( self      :			Tuple					)			->			List[Any]:
							a_		:  Any											=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[Any]					)			->			List[Any]:
							a_		:  List[str]											=      self.model_tester.prepare_config_and_inputs_for_decoder()
							self.model_tester.create_and_check_model_as_decoder(*__SCREAMING_SNAKE_CASE					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			int					)			->			Union[str, Any]:
							a_		:  int											=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_masked_lm(*__SCREAMING_SNAKE_CASE					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			List[Any]:
							a_		:  List[str]											=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*__SCREAMING_SNAKE_CASE					)






			@slow
			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			List[Any]:
							for model_name in TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											a_		:  List[Any]											=      TFEsmModel.from_pretrained(__SCREAMING_SNAKE_CASE					)
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE					)






			@unittest.skip('''Protein models do not support embedding resizing.'''					)
			def 			SCREAMING_SNAKE_CASE      ( self      :			Dict					)			->			str:
							pass






			@unittest.skip('''Protein models do not support embedding resizing.'''					)
			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			int:
							pass







			def 			SCREAMING_SNAKE_CASE      ( self      :			Union[str, Any]					)			->			List[Any]:
							a_				,			a_		:  int											=      self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											a_		:  Union[str, Any]											=      model_class(__SCREAMING_SNAKE_CASE					)
											assert isinstance(model.get_input_embeddings()  ,						tf.keras.layers.Layer					)
											if model_class is TFEsmForMaskedLM:
															# Output embedding test differs from the main test because they're a matrix, not a layer
															a_		:  Dict											=      model.get_bias()
															assert isinstance(__SCREAMING_SNAKE_CASE  ,						__SCREAMING_SNAKE_CASE					)
															for k, v in name.items():
																			assert isinstance(__SCREAMING_SNAKE_CASE  ,						tf.Variable					)
											else:
															a_		:  Union[str, Any]											=      model.get_output_embeddings()
															assert x is None
															a_		:  List[Any]											=      model.get_bias()
															assert name is None





@require_tf
class 	SCREAMING_SNAKE_CASE					(					unittest.TestCase       ):






			@slow
			def 			SCREAMING_SNAKE_CASE      ( self      :			Any					)			->			Union[str, Any]:
							a_		:  str											=      TFEsmForMaskedLM.from_pretrained('''facebook/esm2_t6_8M_UR50D'''					)

							a_		:  Union[str, Any]											=      tf.constant([[0, 1, 2, 3, 4, 5]]					)
							a_		:  List[str]											=      model(__SCREAMING_SNAKE_CASE					)[0]
							a_		:  Optional[Any]											=      [1, 6, 33]
							self.assertEqual(list(output.numpy().shape					)  ,						__SCREAMING_SNAKE_CASE					)
							# compare the actual values for a slice.
							a_		:  List[Any]											=      tf.constant(
							    [
							        [
							            [8.92_1518, -10.58_9814, -6.467_1307],
							            [-6.396_7156, -13.91_1377, -1.121_1915],
							            [-7.78_1247, -13.95_1557, -3.74_0592],
							        ]
							    ]					)
							self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()  ,						expected_slice.numpy()  ,						atol=1e-2					)					)







			@slow
			def 			SCREAMING_SNAKE_CASE      ( self      :			Any					)			->			Optional[Any]:
							a_		:  List[str]											=      TFEsmModel.from_pretrained('''facebook/esm2_t6_8M_UR50D'''					)

							a_		:  Any											=      tf.constant([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]					)
							a_		:  Tuple											=      model(__SCREAMING_SNAKE_CASE					)[0]
							# compare the actual values for a slice.
							a_		:  str											=      tf.constant(
							    [
							        [
							            [0.1444_3092, 0.5412_5327, 0.324_7739],
							            [0.3034_0484, 0.0052_6676, 0.3107_7722],
							            [0.3227_8043, -0.2498_7096, 0.341_4628],
							        ]
							    ]					)
							self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()  ,						expected_slice.numpy()  ,						atol=1e-4					)					)












'''simple docstring'''







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


__lowerCAmelCase       		=      logging.get_logger(__name__)

__lowerCAmelCase       		=      {'vocab_file': 'sentencepiece.bpe.model'}

__lowerCAmelCase       		=      {
    'vocab_file': {
        'moussaKam/mbarthez': 'https://huggingface.co/moussaKam/mbarthez/resolve/main/sentencepiece.bpe.model',
        'moussaKam/barthez': 'https://huggingface.co/moussaKam/barthez/resolve/main/sentencepiece.bpe.model',
        'moussaKam/barthez-orangesum-title': (
            'https://huggingface.co/moussaKam/barthez-orangesum-title/resolve/main/sentencepiece.bpe.model'
        ),
    },
}

__lowerCAmelCase       		=      {
    'moussaKam/mbarthez': 1_024,
    'moussaKam/barthez': 1_024,
    'moussaKam/barthez-orangesum-title': 1_024,
}

__lowerCAmelCase       		=      '▁'





class 	SCREAMING_SNAKE_CASE					(					SCREAMING_SNAKE_CASE_       ):
			snake_case__  =				VOCAB_FILES_NAMES
			snake_case__  =				PRETRAINED_VOCAB_FILES_MAP
			snake_case__  =				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			snake_case__  =				["input_ids", "attention_mask"]






			def __init__( self      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			str  ,						__SCREAMING_SNAKE_CASE      :			Dict="<s>"  ,						__SCREAMING_SNAKE_CASE      :			List[Any]="</s>"  ,						__SCREAMING_SNAKE_CASE      :			List[str]="</s>"  ,						__SCREAMING_SNAKE_CASE      :			List[str]="<s>"  ,						__SCREAMING_SNAKE_CASE      :			Dict="<unk>"  ,						__SCREAMING_SNAKE_CASE      :			int="<pad>"  ,						__SCREAMING_SNAKE_CASE      :			Tuple="<mask>"  ,						__SCREAMING_SNAKE_CASE      :			Optional[Dict[str, Any]] = None  ,						**__SCREAMING_SNAKE_CASE      :			Optional[Any]  ,						)			->			None:
							# Mask token behave like a normal word, i.e. include the space before it
							a_		:  Tuple											=      AddedToken(__SCREAMING_SNAKE_CASE  ,						lstrip=__SCREAMING_SNAKE_CASE  ,						rstrip=__SCREAMING_SNAKE_CASE					) if isinstance(__SCREAMING_SNAKE_CASE  ,						__SCREAMING_SNAKE_CASE					) else mask_token

							a_		:  List[str]											=      {} if sp_model_kwargs is None else sp_model_kwargs

							super().__init__(
							    bos_token=__SCREAMING_SNAKE_CASE  ,						eos_token=__SCREAMING_SNAKE_CASE  ,						unk_token=__SCREAMING_SNAKE_CASE  ,						sep_token=__SCREAMING_SNAKE_CASE  ,						cls_token=__SCREAMING_SNAKE_CASE  ,						pad_token=__SCREAMING_SNAKE_CASE  ,						mask_token=__SCREAMING_SNAKE_CASE  ,						sp_model_kwargs=self.sp_model_kwargs  ,						**__SCREAMING_SNAKE_CASE  ,						)

							a_		:  Tuple											=      vocab_file
							a_		:  Optional[Any]											=      spm.SentencePieceProcessor(**self.sp_model_kwargs					)
							self.sp_model.Load(str(__SCREAMING_SNAKE_CASE					)					)

							a_		:  Optional[Any]											=      {'''<s>''': 0, '''<pad>''': 1, '''</s>''': 2, '''<unk>''': 3}

							a_		:  Any											=      len(self.sp_model					) - 1
							a_		:  Optional[Any]											=      {v: k for k, v in self.fairseq_tokens_to_ids.items()}






			def 			SCREAMING_SNAKE_CASE      ( self      :			str  ,						__SCREAMING_SNAKE_CASE      :			List[int]  ,						__SCREAMING_SNAKE_CASE      :			Optional[List[int]] = None					)			->			List[int]:

							if token_ids_a is None:
											return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
							a_		:  List[str]											=      [self.cls_token_id]
							a_		:  Optional[Any]											=      [self.sep_token_id]
							return cls + token_ids_a + sep + sep + token_ids_a + sep






			def 			SCREAMING_SNAKE_CASE      ( self      :			Optional[int]  ,						__SCREAMING_SNAKE_CASE      :			List[int]  ,						__SCREAMING_SNAKE_CASE      :			Optional[List[int]] = None  ,						__SCREAMING_SNAKE_CASE      :			bool = False					)			->			List[int]:
							if already_has_special_tokens:
											return super().get_special_tokens_mask(
											    token_ids_a=__SCREAMING_SNAKE_CASE  ,						token_ids_a=__SCREAMING_SNAKE_CASE  ,						already_has_special_tokens=__SCREAMING_SNAKE_CASE					)

							if token_ids_a is None:
											return [1] + ([0] * len(__SCREAMING_SNAKE_CASE					)) + [1]
							return [1] + ([0] * len(__SCREAMING_SNAKE_CASE					)) + [1, 1] + ([0] * len(__SCREAMING_SNAKE_CASE					)) + [1]






			def 			SCREAMING_SNAKE_CASE      ( self      :			Union[str, Any]  ,						__SCREAMING_SNAKE_CASE      :			List[int]  ,						__SCREAMING_SNAKE_CASE      :			Optional[List[int]] = None					)			->			List[int]:
							a_		:  List[str]											=      [self.sep_token_id]
							a_		:  Any											=      [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 + sep + token_ids_a + sep					) * [0]






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






			def 			SCREAMING_SNAKE_CASE      ( self      :			str					)			->			Tuple:
							a_		:  int											=      {self.convert_ids_to_tokens(__SCREAMING_SNAKE_CASE					): i for i in range(self.vocab_size					)}
							vocab.update(self.added_tokens_encoder					)
							return vocab






			def 			SCREAMING_SNAKE_CASE      ( self      :			Optional[Any]  ,						__SCREAMING_SNAKE_CASE      :			str					)			->			List[str]:
							return self.sp_model.encode(__SCREAMING_SNAKE_CASE  ,						out_type=__SCREAMING_SNAKE_CASE					)






			def 			SCREAMING_SNAKE_CASE      ( self      :			str  ,						__SCREAMING_SNAKE_CASE      :			List[Any]					)			->			Dict:
							if token in self.fairseq_tokens_to_ids:
											return self.fairseq_tokens_to_ids[token]
							a_		:  Optional[int]											=      self.sp_model.PieceToId(__SCREAMING_SNAKE_CASE					)

							return spm_id if spm_id else self.unk_token_id






			def 			SCREAMING_SNAKE_CASE      ( self      :			List[str]  ,						__SCREAMING_SNAKE_CASE      :			int					)			->			str:
							if index in self.fairseq_ids_to_tokens:
											return self.fairseq_ids_to_tokens[index]
							return self.sp_model.IdToPiece(__SCREAMING_SNAKE_CASE					)






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






			def __getstate__( self      :			Dict					)			->			int:
							a_		:  Dict											=      self.__dict__.copy()
							a_		:  List[str]											=      None
							return state






			def __setstate__( self      :			Dict  ,						__SCREAMING_SNAKE_CASE      :			Optional[Any]					)			->			Any:
							a_		:  Optional[Any]											=      d

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

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







			def 			SCREAMING_SNAKE_CASE      ( self      :			str  ,						__SCREAMING_SNAKE_CASE      :			str  ,						__SCREAMING_SNAKE_CASE      :			Optional[str] = None					)			->			Tuple[str]:
							if not os.path.isdir(__SCREAMING_SNAKE_CASE					):
											logger.error(f'Vocabulary path ({save_directory}) should be a directory'					)
											return
							a_		:  Union[str, Any]											=      os.path.join(
							    __SCREAMING_SNAKE_CASE  ,						(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']					)

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

							return (out_vocab_file,)




