

"""simple docstring"""






import asyncio
import os
import re
import sys
import tempfile
import unittest
from contextlib import contextmanager
from copy import deepcopy
from distutils.util import strtobool
from enum import Enum
from importlib.util import find_spec
from pathlib import Path
from unittest.mock import patch

import pyarrow as pa
import pytest
import requests
from packaging import version

from datasets import config


if config.PY_VERSION < version.parse("""3.8"""):
	import importlib_metadata
else:
	import importlib.metadata as importlib_metadata



def   lowercase_	(    _lowercase       :		Union[str, Any]							,      _lowercase       :		Dict=False	):



					try:
										UpperCAmelCase			:   Tuple      =				os.environ[key]
					except KeyError:
										# KEY isn't set, default to `default`.
										UpperCAmelCase			:   Optional[Any]      =				default
					else:
										# KEY is set, convert it to True or False.
										try:
															UpperCAmelCase			:   str      =				strtobool(_lowercase	)
										except ValueError:
															# More values are supported, but let's keep the message simple.
															raise ValueError(F"""If set, {key} must be yes or no."""	)
					return _value


snake_case_   :   Optional[int]        =       parse_flag_from_env("""RUN_SLOW""", default=False)
snake_case_   :   Optional[Any]        =       parse_flag_from_env("""RUN_REMOTE""", default=False)
snake_case_   :   Union[str, Any]        =       parse_flag_from_env("""RUN_LOCAL""", default=True)
snake_case_   :   Union[str, Any]        =       parse_flag_from_env("""RUN_PACKAGED""", default=True)

# Compression
snake_case_   :   Union[str, Any]        =       pytest.mark.skipif(not config.LZ4_AVAILABLE, reason="""test requires lz4""")
snake_case_   :   Tuple        =       pytest.mark.skipif(not config.PY7ZR_AVAILABLE, reason="""test requires py7zr""")
snake_case_   :   Union[str, Any]        =       pytest.mark.skipif(not config.ZSTANDARD_AVAILABLE, reason="""test requires zstandard""")

# Audio
snake_case_   :   Union[str, Any]        =       pytest.mark.skipif(
    # On Windows and OS X, soundfile installs sndfile
    find_spec("""soundfile""") is None or version.parse(importlib_metadata.version("""soundfile""")) < version.parse("""0.12.0"""),
    reason="""test requires sndfile>=0.12.1: 'pip install \"soundfile>=0.12.1\"'; """,
)

# Beam
snake_case_   :   int        =       pytest.mark.skipif(
    not config.BEAM_AVAILABLE or config.DILL_VERSION >= version.parse("""0.3.2"""),
    reason="""test requires apache-beam and a compatible dill version""",
)

# Dill-cloudpickle compatibility
snake_case_   :   List[Any]        =       pytest.mark.skipif(
    config.DILL_VERSION <= version.parse("""0.3.2"""),
    reason="""test requires dill>0.3.2 for cloudpickle compatibility""",
)

# Windows
snake_case_   :   int        =       pytest.mark.skipif(
    sys.platform == """win32""",
    reason="""test should not be run on Windows""",
)



def   lowercase_	(    _lowercase       :		Union[str, Any]	):



					try:
										import faiss  # noqa
					except ImportError:
										UpperCAmelCase			:   int      =				unittest.skip("test requires faiss"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		str	):



					try:
										import regex  # noqa
					except ImportError:
										UpperCAmelCase			:   List[Any]      =				unittest.skip("test requires regex"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		str	):



					try:
										import elasticsearch  # noqa
					except ImportError:
										UpperCAmelCase			:   Tuple      =				unittest.skip("test requires elasticsearch"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		str	):



					try:
										import sqlalchemy  # noqa
					except ImportError:
										UpperCAmelCase			:   str      =				unittest.skip("test requires sqlalchemy"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Dict	):



					if not config.TORCH_AVAILABLE:
										UpperCAmelCase			:   str      =				unittest.skip("test requires PyTorch"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		List[str]	):



					if not config.TF_AVAILABLE:
										UpperCAmelCase			:   List[Any]      =				unittest.skip("test requires TensorFlow"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Tuple	):



					if not config.JAX_AVAILABLE:
										UpperCAmelCase			:   Dict      =				unittest.skip("test requires JAX"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		str	):



					if not config.PIL_AVAILABLE:
										UpperCAmelCase			:   int      =				unittest.skip("test requires Pillow"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Optional[Any]	):



					try:
										import transformers  # noqa F401
					except ImportError:
										return unittest.skip("test requires transformers"	)(_lowercase	)
					else:
										return test_case



def   lowercase_	(    _lowercase       :		Any	):



					try:
										import tiktoken  # noqa F401
					except ImportError:
										return unittest.skip("test requires tiktoken"	)(_lowercase	)
					else:
										return test_case



def   lowercase_	(    _lowercase       :		Optional[int]	):



					try:
										import spacy  # noqa F401
					except ImportError:
										return unittest.skip("test requires spacy"	)(_lowercase	)
					else:
										return test_case



def   lowercase_	(    _lowercase       :		Tuple	):



					def _require_spacy_model(_lowercase       :		Dict	):
										try:
															import spacy  # noqa F401

															spacy.load(_lowercase	)
										except ImportError:
															return unittest.skip("test requires spacy"	)(_lowercase	)
										except OSError:
															return unittest.skip("test requires spacy model \'{}\'".format(_lowercase	)	)(_lowercase	)
										else:
															return test_case

					return _require_spacy_model



def   lowercase_	(    _lowercase       :		Optional[Any]	):



					try:
										import pyspark  # noqa F401
					except ImportError:
										return unittest.skip("test requires pyspark"	)(_lowercase	)
					else:
										return test_case



def   lowercase_	(    _lowercase       :		Optional[int]	):



					try:
										import joblibspark  # noqa F401
					except ImportError:
										return unittest.skip("test requires joblibspark"	)(_lowercase	)
					else:
										return test_case



def   lowercase_	(    _lowercase       :		List[Any]	):



					if not _run_slow_tests or _run_slow_tests == 0:
										UpperCAmelCase			:   Any      =				unittest.skip("test is slow"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Optional[Any]	):



					if not _run_local_tests or _run_local_tests == 0:
										UpperCAmelCase			:   Dict      =				unittest.skip("test is local"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Any	):



					if not _run_packaged_tests or _run_packaged_tests == 0:
										UpperCAmelCase			:   Optional[Any]      =				unittest.skip("test is packaged"	)(_lowercase	)
					return test_case



def   lowercase_	(    _lowercase       :		Tuple	):



					if not _run_remote_tests or _run_remote_tests == 0:
										UpperCAmelCase			:   int      =				unittest.skip("test requires remote"	)(_lowercase	)
					return test_case



def   lowercase_	(    *_lowercase       :		Dict	):



					def decorate(cls       :		Optional[int]	):
										for name, fn in cls.__dict__.items():
															if callable(_lowercase	) and name.startswith("test"	):
																				for decorator in decorators:
																									UpperCAmelCase			:   List[Any]      =				decorator(_lowercase	)
																				setattr(cls							,      _lowercase							,      _lowercase	)
										return cls

					return decorate







class       snake_case__  ( __lowerCAmelCase     ):
			pass







class       snake_case__  ( __lowerCAmelCase     ):
			SCREAMING_SNAKE_CASE__     				=						0
			SCREAMING_SNAKE_CASE__     				=						1
			SCREAMING_SNAKE_CASE__     				=						2



@contextmanager
def   lowercase_	(    _lowercase       :		List[Any]=OfflineSimulationMode.CONNECTION_FAILS							,      _lowercase       :		Union[str, Any]=1E-16	):
					UpperCAmelCase			:   Union[str, Any]      =				requests.Session().request

					def timeout_request(_lowercase       :		Any							,      _lowercase       :		Any							,      _lowercase       :		Union[str, Any]							,      **_lowercase       :		Optional[Any]	):
										# Change the url to an invalid url so that the connection hangs
										UpperCAmelCase			:   Tuple      =				'''https://10.255.255.1'''
										if kwargs.get("timeout"	) is None:
															raise RequestWouldHangIndefinitelyError(
															    F"""Tried a call to {url} in offline mode with no timeout set. Please set a timeout."""	)
										UpperCAmelCase			:   Union[str, Any]      =				timeout
										try:
															return online_request(_lowercase							,      _lowercase							,      **_lowercase	)
										except Exception as e:
															# The following changes in the error are just here to make the offline timeout error prettier
															UpperCAmelCase			:   List[Any]      =				url
															UpperCAmelCase			:   int      =				e.args[0]
															UpperCAmelCase			:   Tuple      =				(max_retry_error.args[0].replace("10.255.255.1"							,      F"""OfflineMock[{url}]"""	),)
															UpperCAmelCase			:   Union[str, Any]      =				(max_retry_error,)
															raise

					def raise_connection_error(_lowercase       :		List[str]							,      _lowercase       :		Optional[int]							,      **_lowercase       :		Optional[Any]	):
										raise requests.ConnectionError("Offline mode is enabled."							,      request=_lowercase	)

					if mode is OfflineSimulationMode.CONNECTION_FAILS:
										with patch("requests.Session.send"							,      _lowercase	):
															yield
					elif mode is OfflineSimulationMode.CONNECTION_TIMES_OUT:
										# inspired from https://stackoverflow.com/a/904609
										with patch("requests.Session.request"							,      _lowercase	):
															yield
					elif mode is OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1:
										with patch("datasets.config.HF_DATASETS_OFFLINE"							,      _lowercase	):
															yield
					else:
										raise ValueError("Please use a value from the OfflineSimulationMode enum."	)



@contextmanager
def   lowercase_	(    *_lowercase       :		str							,      **_lowercase       :		Tuple	):
					UpperCAmelCase			:   int      =				str(Path().resolve()	)
					with tempfile.TemporaryDirectory(*_lowercase							,      **_lowercase	) as tmp_dir:
										try:
															os.chdir(_lowercase	)
															yield
										finally:
															os.chdir(_lowercase	)



@contextmanager
def   lowercase_	(    ):
					import gc

					gc.collect()
					UpperCAmelCase			:   Any      =				pa.total_allocated_bytes()
					yield
					assert pa.total_allocated_bytes() - previous_allocated_memory > 0, "Arrow memory didn't increase."



@contextmanager
def   lowercase_	(    ):
					import gc

					gc.collect()
					UpperCAmelCase			:   Tuple      =				pa.total_allocated_bytes()
					yield
					assert pa.total_allocated_bytes() - previous_allocated_memory <= 0, "Arrow memory wasn't expected to increase."



def   lowercase_	(    _lowercase       :		str							,      _lowercase       :		str	):
					return deepcopy(_lowercase	).integers(0							,      1_00							,      10	).tolist() == deepcopy(_lowercase	).integers(0							,      1_00							,      10	).tolist()



def   lowercase_	(    _lowercase       :		Union[str, Any]	):
					import decorator
					from requests.exceptions import HTTPError

					def _wrapper(_lowercase       :		Optional[int]							,      *_lowercase       :		str							,      **_lowercase       :		Optional[int]	):
										try:
															return func(*_lowercase							,      **_lowercase	)
										except HTTPError as err:
															if str(_lowercase	).startswith("500"	) or str(_lowercase	).startswith("502"	):
																				pytest.xfail(str(_lowercase	)	)
															raise err

					return decorator.decorator(_wrapper							,      _lowercase	)







class       snake_case__  :







			def __init__(			self			: Union[str, Any]			,  lowercase			: Optional[int]			,  lowercase			: List[Any]			,  lowercase			: Dict  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				returncode
								UpperCAmelCase			:   Tuple      =				stdout
								UpperCAmelCase			:   Any      =				stderr



async def   lowercase_	(    _lowercase       :		Optional[int]							,      _lowercase       :		List[Any]	):



					while True:
										UpperCAmelCase			:   List[Any]      =				await stream.readline()
										if line:
															callback(_lowercase	)
										else:
															break



async def   lowercase_	(    _lowercase       :		int							,      _lowercase       :		List[Any]=None							,      _lowercase       :		Tuple=None							,      _lowercase       :		str=None							,      _lowercase       :		Optional[int]=False							,      _lowercase       :		Optional[int]=False	):



					if echo:
										print("\nRunning: "							,      " ".join(_lowercase	)	)

					UpperCAmelCase			:   Optional[Any]      =				await asyncio.create_subprocess_exec(
					    cmd[0]							,      *cmd[1:]							,      stdin=_lowercase							,      stdout=asyncio.subprocess.PIPE							,      stderr=asyncio.subprocess.PIPE							,      env=_lowercase							,      )

					# note: there is a warning for a possible deadlock when using `wait` with huge amounts of data in the pipe
					# https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.asyncio.subprocess.Process.wait
					#
					# If it starts hanging, will need to switch to the following code. The problem is that no data
					# will be seen until it's done and if it hangs for example there will be no debug info.
					# out, err = await p.communicate()
					# return _RunOutput(p.returncode, out, err)

					UpperCAmelCase			:   Optional[Any]      =				[]
					UpperCAmelCase			:   str      =				[]

					def tee(_lowercase       :		List[str]							,      _lowercase       :		Optional[Any]							,      _lowercase       :		Any							,      _lowercase       :		List[Any]=""	):
										UpperCAmelCase			:   int      =				line.decode("utf-8"	).rstrip()
										sink.append(_lowercase	)
										if not quiet:
															print(_lowercase							,      _lowercase							,      file=_lowercase	)

															 # XXX: the timeout doesn't seem to make any difference here
					await asyncio.wait(
					    [
					        _read_stream(p.stdout							,      lambda _lowercase	: tee(_lowercase							,      _lowercase							,      sys.stdout							,      label="stdout:"	)	),
					        _read_stream(p.stderr							,      lambda _lowercase	: tee(_lowercase							,      _lowercase							,      sys.stderr							,      label="stderr:"	)	),
					    ]							,      timeout=_lowercase							,      )
					return _RunOutput(await p.wait()							,      _lowercase							,      _lowercase	)



def   lowercase_	(    _lowercase       :		int							,      _lowercase       :		int=None							,      _lowercase       :		Optional[int]=None							,      _lowercase       :		str=1_80							,      _lowercase       :		Tuple=False							,      _lowercase       :		List[str]=True	):
					UpperCAmelCase			:   str      =				asyncio.get_event_loop()
					UpperCAmelCase			:   Any      =				loop.run_until_complete(
					    _stream_subprocess(_lowercase							,      env=_lowercase							,      stdin=_lowercase							,      timeout=_lowercase							,      quiet=_lowercase							,      echo=_lowercase	)	)

					UpperCAmelCase			:   List[Any]      =				''' '''.join(_lowercase	)
					if result.returncode > 0:
										UpperCAmelCase			:   Optional[int]      =				'''\n'''.join(result.stderr	)
										raise RuntimeError(
										    F"""'{cmd_str}' failed with returncode {result.returncode}\n\n"""
										    F"""The combined stderr from workers follows:\n{stderr}"""	)

					# check that the subprocess actually did run and produced some output, should the test rely on
					# the remote side to do the testing
					if not result.stdout and not result.stderr:
										raise RuntimeError(F"""'{cmd_str}' produced no output."""	)

					return result



def   lowercase_	(    ):
					UpperCAmelCase			:   int      =				os.environ.get("PYTEST_XDIST_WORKER"							,      "gw0"	)
					UpperCAmelCase			:   Tuple      =				re.sub(R"^gw"							,      ""							,      _lowercase							,      0							,      re.M	)
					return int(_lowercase	)




def   lowercase_	(    ):
					UpperCAmelCase			:   Optional[int]      =				2_95_00
					UpperCAmelCase			:   Optional[Any]      =				pytest_xdist_worker_id()
					return port + uniq_delta





"""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


snake_case_   :   Union[str, Any]        =       logging.get_logger(__name__)

snake_case_   :   Tuple        =       {"""vocab_file""": """sentencepiece.bpe.model"""}

snake_case_   :   List[str]        =       {
    """vocab_file""": {
        """camembert-base""": """https://huggingface.co/camembert-base/resolve/main/sentencepiece.bpe.model""",
    }
}

snake_case_   :   List[Any]        =       {
    """camembert-base""": 5_1_2,
}

snake_case_   :   Any        =       """▁"""







class       snake_case__  ( lowerCAmelCase_     ):
			SCREAMING_SNAKE_CASE__     				=						VOCAB_FILES_NAMES
			SCREAMING_SNAKE_CASE__     				=						PRETRAINED_VOCAB_FILES_MAP
			SCREAMING_SNAKE_CASE__     				=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			SCREAMING_SNAKE_CASE__     				=						['''input_ids''', '''attention_mask''']







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





								'''simple docstring'''



								UpperCAmelCase			:   Optional[Any]      =				AddedToken(lowercase			,  lstrip=lowercase			,  rstrip=lowercase  ) if isinstance(lowercase			,  lowercase  ) else mask_token

								UpperCAmelCase			:   int      =				{} if sp_model_kwargs is None else sp_model_kwargs

								super().__init__(
								    bos_token=lowercase			,  eos_token=lowercase			,  unk_token=lowercase			,  sep_token=lowercase			,  cls_token=lowercase			,  pad_token=lowercase			,  mask_token=lowercase			,  additional_special_tokens=lowercase			,  sp_model_kwargs=self.sp_model_kwargs			,  **lowercase			,  )
								UpperCAmelCase			:   Tuple      =				spm.SentencePieceProcessor(**self.sp_model_kwargs  )
								self.sp_model.Load(str(lowercase  )  )
								UpperCAmelCase			:   str      =				vocab_file
								# HACK: These tokens were added by fairseq but don't seem to be actually used when duplicated in the actual
								# sentencepiece vocabulary (this is the case for <s> and </s>
								UpperCAmelCase			:   Union[str, Any]      =				{"<s>NOTUSED": 0, "<pad>": 1, "</s>NOTUSED": 2, "<unk>": 3}
								UpperCAmelCase			:   Union[str, Any]      =				len(self.fairseq_tokens_to_ids  )
								UpperCAmelCase			:   Dict      =				len(self.sp_model  ) + len(self.fairseq_tokens_to_ids  )
								UpperCAmelCase			:   List[Any]      =				{v: k for k, v in self.fairseq_tokens_to_ids.items()}







			def 			__lowerCAmelCase				(			self			: Union[str, Any]			,  lowercase			: List[int]			,  lowercase			: Optional[List[int]] = None  ):





								'''simple docstring'''



								if token_ids_a is None:
													return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
								UpperCAmelCase			:   Dict      =				[self.cls_token_id]
								UpperCAmelCase			:   List[str]      =				[self.sep_token_id]
								return cls + token_ids_a + sep + sep + token_ids_a + sep







			def 			__lowerCAmelCase				(			self			: Dict			,  lowercase			: List[int]			,  lowercase			: Optional[List[int]] = None			,  lowercase			: bool = False  ):





								'''simple docstring'''



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

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







			def 			__lowerCAmelCase				(			self			: Tuple			,  lowercase			: List[int]			,  lowercase			: Optional[List[int]] = None  ):





								'''simple docstring'''



								UpperCAmelCase			:   Optional[Any]      =				[self.sep_token_id]
								UpperCAmelCase			:   List[str]      =				[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 			__lowerCAmelCase				(			self			: Optional[int]  ):





								'''simple docstring'''



								return len(self.fairseq_tokens_to_ids  ) + len(self.sp_model  )







			def 			__lowerCAmelCase				(			self			: List[Any]  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				{self.convert_ids_to_tokens(lowercase  ): i for i in range(self.vocab_size  )}
								vocab.update(self.added_tokens_encoder  )
								return vocab







			def 			__lowerCAmelCase				(			self			: Optional[Any]			,  lowercase			: str  ):





								'''simple docstring'''



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







			def 			__lowerCAmelCase				(			self			: int			,  lowercase			: Optional[Any]  ):





								'''simple docstring'''



								if token in self.fairseq_tokens_to_ids:
													return self.fairseq_tokens_to_ids[token]
								elif self.sp_model.PieceToId(lowercase  ) == 0:
													# Convert sentence piece unk token to fairseq unk token index
													return self.unk_token_id
								return self.fairseq_offset + self.sp_model.PieceToId(lowercase  )







			def 			__lowerCAmelCase				(			self			: Any			,  lowercase			: Dict  ):





								'''simple docstring'''



								if index in self.fairseq_ids_to_tokens:
													return self.fairseq_ids_to_tokens[index]
								return self.sp_model.IdToPiece(index - self.fairseq_offset  )







			def 			__lowerCAmelCase				(			self			: Tuple			,  lowercase			: Optional[int]  ):





								'''simple docstring'''



								UpperCAmelCase			:   Tuple      =				[]
								UpperCAmelCase			:   Tuple      =				""
								UpperCAmelCase			:   Union[str, 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(lowercase  ) + token
																		UpperCAmelCase			:   Optional[int]      =				True
																		UpperCAmelCase			:   str      =				[]
													else:
																		current_sub_tokens.append(lowercase  )
																		UpperCAmelCase			:   Any      =				False
								out_string += self.sp_model.decode(lowercase  )
								return out_string.strip()







			def __getstate__(			self			: str  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[str]      =				self.__dict__.copy()
								UpperCAmelCase			:   Dict      =				None
								return state







			def __setstate__(			self			: List[str]			,  lowercase			: str  ):





								'''simple docstring'''



								UpperCAmelCase			:   List[Any]      =				d

								# for backward compatibility
								if not hasattr(self			,  "sp_model_kwargs"  ):
													UpperCAmelCase			:   Any      =				{}

								UpperCAmelCase			:   List[Any]      =				spm.SentencePieceProcessor(**self.sp_model_kwargs  )
								self.sp_model.Load(self.vocab_file  )







			def 			__lowerCAmelCase				(			self			: Optional[Any]			,  lowercase			: str			,  lowercase			: Optional[str] = None  ):





								'''simple docstring'''



								if not os.path.isdir(lowercase  ):
													logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""  )
													return
								UpperCAmelCase			:   Optional[Any]      =				os.path.join(
								    lowercase			,  (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]  )

								if os.path.abspath(self.vocab_file  ) != os.path.abspath(lowercase  ) and os.path.isfile(self.vocab_file  ):
													copyfile(self.vocab_file			,  lowercase  )
								elif not os.path.isfile(self.vocab_file  ):
													with open(lowercase			,  "wb"  ) as fi:
																		UpperCAmelCase			:   List[Any]      =				self.sp_model.serialized_model_proto()
																		fi.write(lowercase  )

								return (out_vocab_file,)


