
from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import SwinConfig
from transformers.testing_utils import require_tf, require_vision, slow, to_atuple
from transformers.utils import cached_property, is_tf_available, is_vision_available

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


if is_tf_available():
							import tensorflow as tf

							from transformers.models.swin.modeling_tf_swin import (
							    TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
							    TFSwinForImageClassification,
							    TFSwinForMaskedImageModeling,
							    TFSwinModel,
							)


if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor
class      A__       :





							def __init__(			self  :       Any					,			_UpperCAmelCase  :       Any					,			_UpperCAmelCase  :       int=13					,			_UpperCAmelCase  :       Tuple=32					,			_UpperCAmelCase  :       int=2					,			_UpperCAmelCase  :       Union[str, Any]=3					,			_UpperCAmelCase  :       str=16					,			_UpperCAmelCase  :       List[str]=[1, 2, 1]					,			_UpperCAmelCase  :       Optional[int]=[2, 2, 4]					,			_UpperCAmelCase  :       Union[str, Any]=2					,			_UpperCAmelCase  :       Optional[Any]=2.0					,			_UpperCAmelCase  :       Tuple=True					,			_UpperCAmelCase  :       Tuple=0.0					,			_UpperCAmelCase  :       str=0.0					,			_UpperCAmelCase  :       Any=0.1					,			_UpperCAmelCase  :       List[str]="gelu"					,			_UpperCAmelCase  :       int=False					,			_UpperCAmelCase  :       Optional[Any]=True					,			_UpperCAmelCase  :       Union[str, Any]=0.02					,			_UpperCAmelCase  :       Union[str, Any]=1e-5					,			_UpperCAmelCase  :       Union[str, Any]=True					,			_UpperCAmelCase  :       Optional[Any]=None					,			_UpperCAmelCase  :       Optional[int]=True					,			_UpperCAmelCase  :       Union[str, Any]=10					,			_UpperCAmelCase  :       Any=8					,			)						->		None:



											"""simple docstring"""


											__lowercase								= parent
											__lowercase								= batch_size
											__lowercase								= image_size
											__lowercase								= patch_size
											__lowercase								= num_channels
											__lowercase								= embed_dim
											__lowercase								= depths
											__lowercase								= num_heads
											__lowercase								= window_size
											__lowercase								= mlp_ratio
											__lowercase								= qkv_bias
											__lowercase								= hidden_dropout_prob
											__lowercase								= attention_probs_dropout_prob
											__lowercase								= drop_path_rate
											__lowercase								= hidden_act
											__lowercase								= use_absolute_embeddings
											__lowercase								= patch_norm
											__lowercase								= layer_norm_eps
											__lowercase								= initializer_range
											__lowercase								= is_training
											__lowercase								= scope
											__lowercase								= use_labels
											__lowercase								= type_sequence_label_size
											__lowercase								= encoder_stride





							def       a__			(			self  :       List[Any]    )						->		Union[str, Any]:



											"""simple docstring"""


											__lowercase								= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

											__lowercase								= None
											if self.use_labels:
															__lowercase								= ids_tensor([self.batch_size]					,			self.type_sequence_label_size    )

											__lowercase								= self.get_config()

											return config, pixel_values, labels





							def       a__			(			self  :       str    )						->		Union[str, Any]:



											"""simple docstring"""


											return SwinConfig(
											    image_size=self.image_size					,			patch_size=self.patch_size					,			num_channels=self.num_channels					,			embed_dim=self.embed_dim					,			depths=self.depths					,			num_heads=self.num_heads					,			window_size=self.window_size					,			mlp_ratio=self.mlp_ratio					,			qkv_bias=self.qkv_bias					,			hidden_dropout_prob=self.hidden_dropout_prob					,			attention_probs_dropout_prob=self.attention_probs_dropout_prob					,			drop_path_rate=self.drop_path_rate					,			hidden_act=self.hidden_act					,			use_absolute_embeddings=self.use_absolute_embeddings					,			path_norm=self.patch_norm					,			layer_norm_eps=self.layer_norm_eps					,			initializer_range=self.initializer_range					,			encoder_stride=self.encoder_stride					,			)





							def       a__			(			self  :       str					,			_UpperCAmelCase  :       List[str]					,			_UpperCAmelCase  :       Any					,			_UpperCAmelCase  :       Union[str, Any]    )						->		Any:



											"""simple docstring"""


											__lowercase								= TFSwinModel(config=_UpperCAmelCase    )
											__lowercase								= model(_UpperCAmelCase    )

											__lowercase								= ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths    ) - 1))
											__lowercase								= int(config.embed_dim * 2 ** (len(config.depths    ) - 1)    )

											self.parent.assertEqual(result.last_hidden_state.shape					,			(self.batch_size, expected_seq_len, expected_dim)    )





							def       a__			(			self  :       Dict					,			_UpperCAmelCase  :       Optional[Any]					,			_UpperCAmelCase  :       List[str]					,			_UpperCAmelCase  :       Any    )						->		List[Any]:



											"""simple docstring"""


											__lowercase								= TFSwinForMaskedImageModeling(config=_UpperCAmelCase    )
											__lowercase								= model(_UpperCAmelCase    )
											self.parent.assertEqual(
											    result.logits.shape					,			(self.batch_size, self.num_channels, self.image_size, self.image_size)    )

											# test greyscale images
											__lowercase								= 1
											__lowercase								= TFSwinForMaskedImageModeling(_UpperCAmelCase    )

											__lowercase								= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
											__lowercase								= model(_UpperCAmelCase    )
											self.parent.assertEqual(result.logits.shape					,			(self.batch_size, 1, self.image_size, self.image_size)    )





							def       a__			(			self  :       Any					,			_UpperCAmelCase  :       Any					,			_UpperCAmelCase  :       List[str]					,			_UpperCAmelCase  :       List[Any]    )						->		Union[str, Any]:



											"""simple docstring"""


											__lowercase								= self.type_sequence_label_size
											__lowercase								= TFSwinForImageClassification(_UpperCAmelCase    )
											__lowercase								= model(_UpperCAmelCase					,			labels=_UpperCAmelCase    )
											self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.type_sequence_label_size)    )

											# test greyscale images
											__lowercase								= 1
											__lowercase								= TFSwinForImageClassification(_UpperCAmelCase    )
											__lowercase								= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
											__lowercase								= model(_UpperCAmelCase    )
											self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.type_sequence_label_size)    )





							def       a__			(			self  :       Optional[int]    )						->		Union[str, Any]:



											"""simple docstring"""


											__lowercase								= self.prepare_config_and_inputs()
											__lowercase		, __lowercase		, __lowercase								= config_and_inputs
											__lowercase								= {'pixel_values': pixel_values}
											return config, inputs_dict






@require_tf
class      A__       (						lowerCAmelCase__   ,						lowerCAmelCase__   ,						unittest.TestCase    ):
							lowerCAmelCase__		:						List[Any]         =							(
							    (
							        TFSwinModel,
							        TFSwinForImageClassification,
							        TFSwinForMaskedImageModeling,
							    )
							    if is_tf_available()
							    else ()
							)
							lowerCAmelCase__		:						Optional[Any]         =							(
							    {"feature-extraction": TFSwinModel, "image-classification": TFSwinForImageClassification}
							    if is_tf_available()
							    else {}
							)

							lowerCAmelCase__		:						int         =							False
							lowerCAmelCase__		:						List[Any]         =							False
							lowerCAmelCase__		:						Tuple         =							False
							lowerCAmelCase__		:						Tuple         =							False





							def       a__			(			self  :       List[Any]    )						->		List[str]:



											"""simple docstring"""


											__lowercase								= TFSwinModelTester(self    )
											__lowercase								= ConfigTester(self					,			config_class=_UpperCAmelCase					,			embed_dim=37    )





							def       a__			(			self  :       Optional[int]    )						->		str:



											"""simple docstring"""


											self.create_and_test_config_common_properties()
											self.config_tester.create_and_test_config_to_json_string()
											self.config_tester.create_and_test_config_to_json_file()
											self.config_tester.create_and_test_config_from_and_save_pretrained()
											self.config_tester.create_and_test_config_with_num_labels()
											self.config_tester.check_config_can_be_init_without_params()
											self.config_tester.check_config_arguments_init()





							def       a__			(			self  :       Dict    )						->		str:



											"""simple docstring"""


											return





							def       a__			(			self  :       Optional[Any]    )						->		Tuple:



											"""simple docstring"""


											__lowercase								= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*_UpperCAmelCase    )





							def       a__			(			self  :       str    )						->		List[Any]:



											"""simple docstring"""


											__lowercase								= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_image_modeling(*_UpperCAmelCase    )





							def       a__			(			self  :       int    )						->		Tuple:



											"""simple docstring"""


											__lowercase								= self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_image_classification(*_UpperCAmelCase    )





							@unittest.skip(reason='Swin does not use inputs_embeds'    )
							def       a__			(			self  :       int    )						->		List[str]:



											"""simple docstring"""


											pass





							def       a__			(			self  :       Any    )						->		List[Any]:



											"""simple docstring"""


											__lowercase		, __lowercase								= self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
															__lowercase								= model_class(_UpperCAmelCase    )
															self.assertIsInstance(model.get_input_embeddings()					,			tf.keras.layers.Layer    )
															__lowercase								= model.get_output_embeddings()
															self.assertTrue(x is None or isinstance(_UpperCAmelCase					,			tf.keras.layers.Dense    )    )





							def       a__			(			self  :       int    )						->		List[Any]:



											"""simple docstring"""


											__lowercase		, __lowercase								= self.model_tester.prepare_config_and_inputs_for_common()

											for model_class in self.all_model_classes:
															__lowercase								= model_class(_UpperCAmelCase    )
															__lowercase								= inspect.signature(model.call    )
															# signature.parameters is an OrderedDict => so arg_names order is deterministic
															__lowercase								= [*signature.parameters.keys()]

															__lowercase								= ['pixel_values']
															self.assertListEqual(arg_names[:1]					,			_UpperCAmelCase    )





							def       a__			(			self  :       Optional[Any]    )						->		Optional[int]:



											"""simple docstring"""


											__lowercase		, __lowercase								= self.model_tester.prepare_config_and_inputs_for_common()
											__lowercase								= True

											for model_class in self.all_model_classes:
															__lowercase								= True
															__lowercase								= False
															__lowercase								= True
															__lowercase								= model_class(_UpperCAmelCase    )
															__lowercase								= model(**self._prepare_for_class(_UpperCAmelCase					,			_UpperCAmelCase    )    )
															__lowercase								= outputs.attentions
															__lowercase								= len(self.model_tester.depths    )
															self.assertEqual(len(_UpperCAmelCase    )					,			_UpperCAmelCase    )

															# check that output_attentions also work using config
															del inputs_dict["output_attentions"]
															__lowercase								= True
															__lowercase								= config.window_size**2
															__lowercase								= model_class(_UpperCAmelCase    )
															__lowercase								= model(**self._prepare_for_class(_UpperCAmelCase					,			_UpperCAmelCase    )    )
															__lowercase								= outputs.attentions
															self.assertEqual(len(_UpperCAmelCase    )					,			_UpperCAmelCase    )

															self.assertListEqual(
															    list(attentions[0].shape[-3:]    )					,			[self.model_tester.num_heads[0], window_size_squared, window_size_squared]					,			)
															__lowercase								= len(_UpperCAmelCase    )

															# Check attention is always last and order is fine
															__lowercase								= True
															__lowercase								= True
															__lowercase								= model_class(_UpperCAmelCase    )
															__lowercase								= model(**self._prepare_for_class(_UpperCAmelCase					,			_UpperCAmelCase    )    )

															if hasattr(self.model_tester					,			'num_hidden_states_types'    ):
																			__lowercase								= self.model_tester.num_hidden_states_types
															else:
																			# also another +1 for reshaped_hidden_states
																			__lowercase								= 2
															self.assertEqual(out_len + added_hidden_states					,			len(_UpperCAmelCase    )    )

															__lowercase								= outputs.attentions

															self.assertEqual(len(_UpperCAmelCase    )					,			_UpperCAmelCase    )

															self.assertListEqual(
															    list(self_attentions[0].shape[-3:]    )					,			[self.model_tester.num_heads[0], window_size_squared, window_size_squared]					,			)





							def       a__			(			self  :       List[str]					,			_UpperCAmelCase  :       Union[str, Any]					,			_UpperCAmelCase  :       Any					,			_UpperCAmelCase  :       Union[str, Any]					,			_UpperCAmelCase  :       Optional[int]    )						->		str:



											"""simple docstring"""


											__lowercase								= model_class(_UpperCAmelCase    )
											__lowercase								= model(**self._prepare_for_class(_UpperCAmelCase					,			_UpperCAmelCase    )    )
											__lowercase								= outputs.hidden_states

											__lowercase								= getattr(
											    self.model_tester					,			'expected_num_hidden_layers'					,			len(self.model_tester.depths    ) + 1    )
											self.assertEqual(len(_UpperCAmelCase    )					,			_UpperCAmelCase    )

											# Swin has a different seq_length
											__lowercase								= to_atuple(config.patch_size    )

											__lowercase								= (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

											self.assertListEqual(
											    list(hidden_states[0].shape[-2:]    )					,			[num_patches, self.model_tester.embed_dim]					,			)

											__lowercase								= outputs.reshaped_hidden_states
											self.assertEqual(len(_UpperCAmelCase    )					,			_UpperCAmelCase    )

											__lowercase		, __lowercase		, __lowercase		, __lowercase								= reshaped_hidden_states[0].shape

											__lowercase								= tf.reshape(reshaped_hidden_states[0]					,			(batch_size, num_channels, height * width)    )
											__lowercase								= tf.transpose(_UpperCAmelCase					,			(0, 2, 1)    )

											self.assertListEqual(
											    list(reshaped_hidden_states.shape[-2:]    )					,			[num_patches, self.model_tester.embed_dim]					,			)





							def       a__			(			self  :       Optional[Any]    )						->		Tuple:



											"""simple docstring"""


											__lowercase		, __lowercase								= self.model_tester.prepare_config_and_inputs_for_common()

											__lowercase								= to_atuple(self.model_tester.image_size    )

											for model_class in self.all_model_classes:
															__lowercase								= True
															self.check_hidden_states_output(_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase    )

															# check that output_hidden_states also work using config
															del inputs_dict["output_hidden_states"]
															__lowercase								= True

															self.check_hidden_states_output(_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase    )





							def       a__			(			self  :       List[str]    )						->		Tuple:



											"""simple docstring"""


											__lowercase		, __lowercase								= self.model_tester.prepare_config_and_inputs_for_common()
											__lowercase								= 3

											__lowercase								= to_atuple(self.model_tester.image_size    )
											__lowercase								= to_atuple(config.patch_size    )

											__lowercase								= image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
											__lowercase								= image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

											for model_class in self.all_model_classes:
															__lowercase								= True
															self.check_hidden_states_output(_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase					,			(padded_height, padded_width)    )

															# check that output_hidden_states also work using config
															del inputs_dict["output_hidden_states"]
															__lowercase								= True
															self.check_hidden_states_output(_UpperCAmelCase					,			_UpperCAmelCase					,			_UpperCAmelCase					,			(padded_height, padded_width)    )





							@slow
							def       a__			(			self  :       List[Any]    )						->		Optional[int]:



											"""simple docstring"""


											for model_name in TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__lowercase								= TFSwinModel.from_pretrained(_UpperCAmelCase    )
															self.assertIsNotNone(_UpperCAmelCase    )






@require_vision
@require_tf
class      A__       (						unittest.TestCase    ):





							@cached_property
							def       a__			(			self  :       Any    )						->		Tuple:



											"""simple docstring"""


											return (
											    AutoImageProcessor.from_pretrained('microsoft/swin-tiny-patch4-window7-224'    )
											    if is_vision_available()
											    else None
											)





							@slow
							def       a__			(			self  :       Optional[int]    )						->		Tuple:



											"""simple docstring"""


											__lowercase								= TFSwinForImageClassification.from_pretrained('microsoft/swin-tiny-patch4-window7-224'    )
											__lowercase								= self.default_image_processor

											__lowercase								= Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'    )
											__lowercase								= image_processor(images=_UpperCAmelCase					,			return_tensors='tf'    )

											# forward pass
											__lowercase								= model(_UpperCAmelCase    )

											# verify the logits
											__lowercase								= tf.TensorShape((1, 10_00)    )
											self.assertEqual(outputs.logits.shape					,			_UpperCAmelCase    )
											__lowercase								= tf.constant([-0.0_948, -0.6_454, -0.0_921]    )
											self.assertTrue(np.allclose(outputs.logits[0, :3]					,			_UpperCAmelCase					,			atol=1e-4    )    )







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

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
							from .tokenization_xlm_roberta import XLMRobertaTokenizer
else:
							SCREAMING_SNAKE_CASE__							=    None


SCREAMING_SNAKE_CASE__							=    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__							=    {"""vocab_file""": """sentencepiece.bpe.model""", """tokenizer_file""": """tokenizer.json"""}

SCREAMING_SNAKE_CASE__							=    {
    """vocab_file""": {
        """xlm-roberta-base""": """https://huggingface.co/xlm-roberta-base/resolve/main/sentencepiece.bpe.model""",
        """xlm-roberta-large""": """https://huggingface.co/xlm-roberta-large/resolve/main/sentencepiece.bpe.model""",
        """xlm-roberta-large-finetuned-conll02-dutch""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll02-dutch/resolve/main/sentencepiece.bpe.model"""
        ),
        """xlm-roberta-large-finetuned-conll02-spanish""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll02-spanish/resolve/main/sentencepiece.bpe.model"""
        ),
        """xlm-roberta-large-finetuned-conll03-english""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/resolve/main/sentencepiece.bpe.model"""
        ),
        """xlm-roberta-large-finetuned-conll03-german""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll03-german/resolve/main/sentencepiece.bpe.model"""
        ),
    },
    """tokenizer_file""": {
        """xlm-roberta-base""": """https://huggingface.co/xlm-roberta-base/resolve/main/tokenizer.json""",
        """xlm-roberta-large""": """https://huggingface.co/xlm-roberta-large/resolve/main/tokenizer.json""",
        """xlm-roberta-large-finetuned-conll02-dutch""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll02-dutch/resolve/main/tokenizer.json"""
        ),
        """xlm-roberta-large-finetuned-conll02-spanish""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll02-spanish/resolve/main/tokenizer.json"""
        ),
        """xlm-roberta-large-finetuned-conll03-english""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/resolve/main/tokenizer.json"""
        ),
        """xlm-roberta-large-finetuned-conll03-german""": (
            """https://huggingface.co/xlm-roberta-large-finetuned-conll03-german/resolve/main/tokenizer.json"""
        ),
    },
}

SCREAMING_SNAKE_CASE__							=    {
    """xlm-roberta-base""": 512,
    """xlm-roberta-large""": 512,
    """xlm-roberta-large-finetuned-conll02-dutch""": 512,
    """xlm-roberta-large-finetuned-conll02-spanish""": 512,
    """xlm-roberta-large-finetuned-conll03-english""": 512,
    """xlm-roberta-large-finetuned-conll03-german""": 512,
}
class      A__       (						lowerCAmelCase__    ):
							lowerCAmelCase__		:						Dict         =							VOCAB_FILES_NAMES
							lowerCAmelCase__		:						List[str]         =							PRETRAINED_VOCAB_FILES_MAP
							lowerCAmelCase__		:						List[Any]         =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowerCAmelCase__		:						Dict         =							["input_ids", "attention_mask"]
							lowerCAmelCase__		:						List[str]         =							XLMRobertaTokenizer





							def __init__(			self  :       Tuple					,			_UpperCAmelCase  :       Tuple=None					,			_UpperCAmelCase  :       int=None					,			_UpperCAmelCase  :       Tuple="<s>"					,			_UpperCAmelCase  :       Dict="</s>"					,			_UpperCAmelCase  :       Dict="</s>"					,			_UpperCAmelCase  :       List[Any]="<s>"					,			_UpperCAmelCase  :       List[Any]="<unk>"					,			_UpperCAmelCase  :       Optional[int]="<pad>"					,			_UpperCAmelCase  :       Union[str, Any]="<mask>"					,			**_UpperCAmelCase  :       Optional[int]					,			)						->		Dict:



											"""simple docstring"""


											__lowercase								= AddedToken(_UpperCAmelCase					,			lstrip=_UpperCAmelCase					,			rstrip=_UpperCAmelCase    ) if isinstance(_UpperCAmelCase					,			_UpperCAmelCase    ) else mask_token

											super().__init__(
											    _UpperCAmelCase					,			tokenizer_file=_UpperCAmelCase					,			bos_token=_UpperCAmelCase					,			eos_token=_UpperCAmelCase					,			sep_token=_UpperCAmelCase					,			cls_token=_UpperCAmelCase					,			unk_token=_UpperCAmelCase					,			pad_token=_UpperCAmelCase					,			mask_token=_UpperCAmelCase					,			**_UpperCAmelCase					,			)

											__lowercase								= vocab_file
											__lowercase								= False if not self.vocab_file else True





							def       a__			(			self  :       Union[str, Any]					,			_UpperCAmelCase  :       List[int]					,			_UpperCAmelCase  :       Optional[List[int]] = None    )						->		List[int]:



											"""simple docstring"""


											if token_ids_a is None:
															return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
											__lowercase								= [self.cls_token_id]
											__lowercase								= [self.sep_token_id]
											return cls + token_ids_a + sep + sep + token_ids_a + sep





							def       a__			(			self  :       Union[str, Any]					,			_UpperCAmelCase  :       List[int]					,			_UpperCAmelCase  :       Optional[List[int]] = None    )						->		List[int]:



											"""simple docstring"""


											__lowercase								= [self.sep_token_id]
											__lowercase								= [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]





							def       a__			(			self  :       str					,			_UpperCAmelCase  :       str					,			_UpperCAmelCase  :       Optional[str] = None    )						->		Tuple[str]:



											"""simple docstring"""


											if not self.can_save_slow_tokenizer:
															raise ValueError(
															    'Your fast tokenizer does not have the necessary information to save the vocabulary for a slow '
															    'tokenizer.'    )

											if not os.path.isdir(_UpperCAmelCase    ):
															logger.error(f"""Vocabulary path ({save_directory}) should be a directory."""    )
															return
											__lowercase								= 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    ):
															copyfile(self.vocab_file					,			_UpperCAmelCase    )

											return (out_vocab_file,)





