






"""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      UpperCamelCase       ( _A  ,				_A=False )     ->       Any:
				try:
								lowercase    :      Dict       = os.environ[key]
				except KeyError:
								# KEY isn't set, default to `default`.
								lowercase    :      Optional[Any]       = default
				else:
								# KEY is set, convert it to True or False.
								try:
												lowercase    :      List[Any]       = strtobool(_A )
								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


_lowerCAmelCase            =	parse_flag_from_env('RUN_SLOW', default=False)
_lowerCAmelCase            =	parse_flag_from_env('RUN_REMOTE', default=False)
_lowerCAmelCase            =	parse_flag_from_env('RUN_LOCAL', default=True)
_lowerCAmelCase            =	parse_flag_from_env('RUN_PACKAGED', default=True)

# Compression
_lowerCAmelCase            =	pytest.mark.skipif(not config.LZ4_AVAILABLE, reason='test requires lz4')
_lowerCAmelCase            =	pytest.mark.skipif(not config.PY7ZR_AVAILABLE, reason='test requires py7zr')
_lowerCAmelCase            =	pytest.mark.skipif(not config.ZSTANDARD_AVAILABLE, reason='test requires zstandard')

# Audio
_lowerCAmelCase            =	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
_lowerCAmelCase            =	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
_lowerCAmelCase            =	pytest.mark.skipif(
    config.DILL_VERSION <= version.parse('0.3.2'),
    reason='test requires dill>0.3.2 for cloudpickle compatibility',
)

# Windows
_lowerCAmelCase            =	pytest.mark.skipif(
    sys.platform == 'win32',
    reason='test should not be run on Windows',
)


def      UpperCamelCase       ( _A )     ->       Union[str, Any]:
				try:
								import faiss  # noqa
				except ImportError:
								lowercase    :      str       = unittest.skip("""test requires faiss""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       Dict:
				try:
								import regex  # noqa
				except ImportError:
								lowercase    :      Optional[Any]       = unittest.skip("""test requires regex""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       Union[str, Any]:
				try:
								import elasticsearch  # noqa
				except ImportError:
								lowercase    :      Tuple       = unittest.skip("""test requires elasticsearch""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       str:
				try:
								import sqlalchemy  # noqa
				except ImportError:
								lowercase    :      Union[str, Any]       = unittest.skip("""test requires sqlalchemy""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       List[str]:
				if not config.TORCH_AVAILABLE:
								lowercase    :      int       = unittest.skip("""test requires PyTorch""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       str:
				if not config.TF_AVAILABLE:
								lowercase    :      List[str]       = unittest.skip("""test requires TensorFlow""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       int:
				if not config.JAX_AVAILABLE:
								lowercase    :      Any       = unittest.skip("""test requires JAX""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       List[Any]:
				if not config.PIL_AVAILABLE:
								lowercase    :      str       = unittest.skip("""test requires Pillow""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       int:
				try:
								import transformers  # noqa F401
				except ImportError:
								return unittest.skip("""test requires transformers""" )(_A )
				else:
								return test_case


def      UpperCamelCase       ( _A )     ->       Union[str, Any]:
				try:
								import tiktoken  # noqa F401
				except ImportError:
								return unittest.skip("""test requires tiktoken""" )(_A )
				else:
								return test_case


def      UpperCamelCase       ( _A )     ->       List[str]:
				try:
								import spacy  # noqa F401
				except ImportError:
								return unittest.skip("""test requires spacy""" )(_A )
				else:
								return test_case


def      UpperCamelCase       ( _A )     ->       Optional[Any]:

				def _require_spacy_model(_A ):
								try:
												import spacy  # noqa F401

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

				return _require_spacy_model


def      UpperCamelCase       ( _A )     ->       Union[str, Any]:
				try:
								import pyspark  # noqa F401
				except ImportError:
								return unittest.skip("""test requires pyspark""" )(_A )
				else:
								return test_case


def      UpperCamelCase       ( _A )     ->       str:
				try:
								import joblibspark  # noqa F401
				except ImportError:
								return unittest.skip("""test requires joblibspark""" )(_A )
				else:
								return test_case


def      UpperCamelCase       ( _A )     ->       List[str]:
				if not _run_slow_tests or _run_slow_tests == 0:
								lowercase    :      List[str]       = unittest.skip("""test is slow""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       List[str]:
				if not _run_local_tests or _run_local_tests == 0:
								lowercase    :      Any       = unittest.skip("""test is local""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       Dict:
				if not _run_packaged_tests or _run_packaged_tests == 0:
								lowercase    :      str       = unittest.skip("""test is packaged""" )(_A )
				return test_case


def      UpperCamelCase       ( _A )     ->       Dict:
				if not _run_remote_tests or _run_remote_tests == 0:
								lowercase    :      str       = unittest.skip("""test requires remote""" )(_A )
				return test_case


def      UpperCamelCase       ( *_A )     ->       Tuple:
				def decorate(cls ):
								for name, fn in cls.__dict__.items():
												if callable(_A ) and name.startswith("""test""" ):
																for decorator in decorators:
																				lowercase    :      Any       = decorator(_A )
																setattr(cls  ,				_A  ,				_A )
								return cls

				return decorate


class      UpperCamelCase		(__snake_case     ):
						pass


class      UpperCamelCase		(__snake_case     ):
						_SCREAMING_SNAKE_CASE  : Any												=		0
						_SCREAMING_SNAKE_CASE  : List[str]												=		1
						_SCREAMING_SNAKE_CASE  : Tuple												=		2


@contextmanager
def      UpperCamelCase       ( _A=OfflineSimulationMode.CONNECTION_FAILS  ,				_A=1e-16 )     ->       Optional[Any]:
				lowercase    :      Optional[int]       = requests.Session().request

				def timeout_request(_A  ,				_A  ,				_A  ,				**_A ):
								# Change the url to an invalid url so that the connection hangs
								lowercase    :      List[str]       = """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.""" )
								lowercase    :      Union[str, Any]       = timeout
								try:
												return online_request(_A  ,				_A  ,				**_A )
								except Exception as e:
												# The following changes in the error are just here to make the offline timeout error prettier
												lowercase    :      Any       = url
												lowercase    :      Tuple       = e.args[0]
												lowercase    :      Optional[Any]       = (max_retry_error.args[0].replace("""10.255.255.1"""  ,				F"""OfflineMock[{url}]""" ),)
												lowercase    :      Optional[Any]       = (max_retry_error,)
												raise

				def raise_connection_error(_A  ,				_A  ,				**_A ):
								raise requests.ConnectionError("""Offline mode is enabled."""  ,				request=_A )

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


@contextmanager
def      UpperCamelCase       ( *_A  ,				**_A )     ->       Optional[int]:
				lowercase    :      Union[str, Any]       = str(Path().resolve() )
				with tempfile.TemporaryDirectory(*_A  ,				**_A ) as tmp_dir:
								try:
												os.chdir(_A )
												yield
								finally:
												os.chdir(_A )


@contextmanager
def      UpperCamelCase       ( )     ->       Union[str, Any]:
				import gc

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


@contextmanager
def      UpperCamelCase       ( )     ->       Dict:
				import gc

				gc.collect()
				lowercase    :      Union[str, Any]       = pa.total_allocated_bytes()
				yield
				assert pa.total_allocated_bytes() - previous_allocated_memory <= 0, "Arrow memory wasn't expected to increase."


def      UpperCamelCase       ( _A  ,				_A )     ->       Dict:
				return deepcopy(_A ).integers(0  ,				100  ,				10 ).tolist() == deepcopy(_A ).integers(0  ,				100  ,				10 ).tolist()


def      UpperCamelCase       ( _A )     ->       Tuple:
				import decorator
				from requests.exceptions import HTTPError

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

				return decorator.decorator(_wrapper  ,				_A )


class      UpperCamelCase		:






						def __init__(		self  :Dict			, __magic_name__  :List[Any]			, __magic_name__  :List[Any]			, __magic_name__  :List[Any]				)      ->Union[str, Any]:
										lowercase    :      List[str]       = returncode
										lowercase    :      Any       = stdout
										lowercase    :      int       = stderr


async def      UpperCamelCase       ( _A  ,				_A )     ->       List[Any]:
				while True:
								lowercase    :      Optional[int]       = await stream.readline()
								if line:
												callback(_A )
								else:
												break


async def      UpperCamelCase       ( _A  ,				_A=None  ,				_A=None  ,				_A=None  ,				_A=False  ,				_A=False )     ->       _RunOutput:
				if echo:
								print("""\nRunning: """  ,				""" """.join(_A ) )

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

				# 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)

				lowercase    :      Union[str, Any]       = []
				lowercase    :      Optional[Any]       = []

				def tee(_A  ,				_A  ,				_A  ,				_A="" ):
								lowercase    :      int       = line.decode("""utf-8""" ).rstrip()
								sink.append(_A )
								if not quiet:
												print(_A  ,				_A  ,				file=_A )

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


def      UpperCamelCase       ( _A  ,				_A=None  ,				_A=None  ,				_A=180  ,				_A=False  ,				_A=True )     ->       _RunOutput:
				lowercase    :      Dict       = asyncio.get_event_loop()
				lowercase    :      int       = loop.run_until_complete(
				    _stream_subprocess(_A  ,				env=_A  ,				stdin=_A  ,				timeout=_A  ,				quiet=_A  ,				echo=_A ) )

				lowercase    :      Optional[Any]       = """ """.join(_A )
				if result.returncode > 0:
								lowercase    :      str       = """\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      UpperCamelCase       ( )     ->       Dict:
				lowercase    :      Any       = os.environ.get("""PYTEST_XDIST_WORKER"""  ,				"""gw0""" )
				lowercase    :      Union[str, Any]       = re.sub(r"""^gw"""  ,				""""""  ,				_A  ,				0  ,				re.M )
				return int(_A )


def      UpperCamelCase       ( )     ->       int:
				lowercase    :      Optional[int]       = 29_500
				lowercase    :      Tuple       = pytest_xdist_worker_id()
				return port + uniq_delta








"""simple docstring"""







import itertools
import json
import os
import unittest

from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast
from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class      UpperCamelCase		(__snake_case						,						unittest.TestCase     ):
						_SCREAMING_SNAKE_CASE  : List[Any]												=		LongformerTokenizer
						_SCREAMING_SNAKE_CASE  : int												=		True
						_SCREAMING_SNAKE_CASE  : List[str]												=		LongformerTokenizerFast
						_SCREAMING_SNAKE_CASE  : Dict												=		True






						def      __snake_case      (		self  :Dict				)      ->Tuple:
										super().setUp()

										# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
										lowercase    :      Dict       = [
										    """l""",
										    """o""",
										    """w""",
										    """e""",
										    """r""",
										    """s""",
										    """t""",
										    """i""",
										    """d""",
										    """n""",
										    """\u0120""",
										    """\u0120l""",
										    """\u0120n""",
										    """\u0120lo""",
										    """\u0120low""",
										    """er""",
										    """\u0120lowest""",
										    """\u0120newer""",
										    """\u0120wider""",
										    """<unk>""",
										]
										lowercase    :      Tuple       = dict(zip(__magic_name__			, range(len(__magic_name__				)				)				)				)
										lowercase    :      Tuple       = ["""#version: 0.2""", """\u0120 l""", """\u0120l o""", """\u0120lo w""", """e r""", """"""]
										lowercase    :      Dict       = {"""unk_token""": """<unk>"""}

										lowercase    :      Dict       = os.path.join(self.tmpdirname			, VOCAB_FILES_NAMES["""vocab_file"""]				)
										lowercase    :      Optional[int]       = os.path.join(self.tmpdirname			, VOCAB_FILES_NAMES["""merges_file"""]				)
										with open(self.vocab_file			, """w"""			, encoding="""utf-8"""				) as fp:
														fp.write(json.dumps(__magic_name__				) + """\n"""				)
										with open(self.merges_file			, """w"""			, encoding="""utf-8"""				) as fp:
														fp.write("""\n""".join(__magic_name__				)				)






						def      __snake_case      (		self  :List[Any]			, **__magic_name__  :Any				)      ->Tuple:
										kwargs.update(self.special_tokens_map				)
										return self.tokenizer_class.from_pretrained(self.tmpdirname			, **__magic_name__				)






						def      __snake_case      (		self  :Optional[Any]			, **__magic_name__  :Optional[Any]				)      ->Dict:
										kwargs.update(self.special_tokens_map				)
										return self.rust_tokenizer_class.from_pretrained(self.tmpdirname			, **__magic_name__				)






						def      __snake_case      (		self  :Tuple			, __magic_name__  :Dict				)      ->str:
										lowercase    :      List[str]       = """lower newer"""
										lowercase    :      Any       = """lower newer"""
										return input_text, output_text






						def      __snake_case      (		self  :Tuple				)      ->Union[str, Any]:
										lowercase    :      Union[str, Any]       = self.tokenizer_class(self.vocab_file			, self.merges_file			, **self.special_tokens_map				)
										lowercase    :      List[str]       = """lower newer"""
										lowercase    :      Tuple       = ["""l""", """o""", """w""", """er""", """\u0120""", """n""", """e""", """w""", """er"""]
										lowercase    :      Optional[int]       = tokenizer.tokenize(__magic_name__				)  # , add_prefix_space=True)
										self.assertListEqual(__magic_name__			, __magic_name__				)

										lowercase    :      str       = tokens + [tokenizer.unk_token]
										lowercase    :      Any       = [0, 1, 2, 15, 10, 9, 3, 2, 15, 19]
										self.assertListEqual(tokenizer.convert_tokens_to_ids(__magic_name__				)			, __magic_name__				)






						def      __snake_case      (		self  :Any				)      ->str:
										lowercase    :      int       = self.get_tokenizer()

										self.assertListEqual(tokenizer.encode("""Hello world!"""			, add_special_tokens=__magic_name__				)			, [0, 31_414, 232, 328, 2]				)
										self.assertListEqual(
										    tokenizer.encode("""Hello world! cécé herlolip 418"""			, add_special_tokens=__magic_name__				)			, [0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]			, )






						@slow
						def      __snake_case      (		self  :Tuple				)      ->Union[str, Any]:
										lowercase    :      Any       = self.tokenizer_class.from_pretrained("""allenai/longformer-base-4096"""				)

										lowercase    :      Tuple       = tokenizer.encode("""sequence builders"""			, add_special_tokens=__magic_name__				)
										lowercase    :      List[Any]       = tokenizer.encode("""multi-sequence build"""			, add_special_tokens=__magic_name__				)

										lowercase    :      Union[str, Any]       = tokenizer.encode(
										    """sequence builders"""			, add_special_tokens=__magic_name__			, add_prefix_space=__magic_name__				)
										lowercase    :      List[Any]       = tokenizer.encode(
										    """sequence builders"""			, """multi-sequence build"""			, add_special_tokens=__magic_name__			, add_prefix_space=__magic_name__				)

										lowercase    :      int       = tokenizer.build_inputs_with_special_tokens(__magic_name__				)
										lowercase    :      List[Any]       = tokenizer.build_inputs_with_special_tokens(__magic_name__			, __magic_name__				)

										assert encoded_sentence == encoded_text_from_decode
										assert encoded_pair == encoded_pair_from_decode






						def      __snake_case      (		self  :Optional[Any]				)      ->int:
										lowercase    :      Optional[int]       = self.get_tokenizer()

										lowercase    :      Tuple       = """Encode this sequence."""
										lowercase    :      Dict       = tokenizer.byte_encoder[""" """.encode("""utf-8"""				)[0]]

										# Testing encoder arguments
										lowercase    :      List[Any]       = tokenizer.encode(__magic_name__			, add_special_tokens=__magic_name__			, add_prefix_space=__magic_name__				)
										lowercase    :      int       = tokenizer.convert_ids_to_tokens(encoded[0]				)[0]
										self.assertNotEqual(__magic_name__			, __magic_name__				)

										lowercase    :      Optional[Any]       = tokenizer.encode(__magic_name__			, add_special_tokens=__magic_name__			, add_prefix_space=__magic_name__				)
										lowercase    :      Tuple       = tokenizer.convert_ids_to_tokens(encoded[0]				)[0]
										self.assertEqual(__magic_name__			, __magic_name__				)

										tokenizer.add_special_tokens({"""bos_token""": """<s>"""}				)
										lowercase    :      Union[str, Any]       = tokenizer.encode(__magic_name__			, add_special_tokens=__magic_name__				)
										lowercase    :      List[str]       = tokenizer.convert_ids_to_tokens(encoded[1]				)[0]
										self.assertNotEqual(__magic_name__			, __magic_name__				)

										# Testing spaces after special tokens
										lowercase    :      Any       = """<mask>"""
										tokenizer.add_special_tokens(
										    {"""mask_token""": AddedToken(__magic_name__			, lstrip=__magic_name__			, rstrip=__magic_name__				)}				)  # mask token has a left space
										lowercase    :      Any       = tokenizer.convert_tokens_to_ids(__magic_name__				)

										lowercase    :      Any       = """Encode <mask> sequence"""
										lowercase    :      str       = """Encode <mask>sequence"""

										lowercase    :      Optional[int]       = tokenizer.encode(__magic_name__				)
										lowercase    :      List[str]       = encoded.index(__magic_name__				)
										lowercase    :      Tuple       = tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1]				)[0]
										self.assertEqual(__magic_name__			, __magic_name__				)

										lowercase    :      Tuple       = tokenizer.encode(__magic_name__				)
										lowercase    :      List[str]       = encoded.index(__magic_name__				)
										lowercase    :      Optional[Any]       = tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1]				)[0]
										self.assertNotEqual(__magic_name__			, __magic_name__				)






						def      __snake_case      (		self  :Any				)      ->int:
										pass






						def      __snake_case      (		self  :List[Any]				)      ->str:
										for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
														with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""				):
																		lowercase    :      int       = self.rust_tokenizer_class.from_pretrained(__magic_name__			, **__magic_name__				)
																		lowercase    :      List[str]       = self.tokenizer_class.from_pretrained(__magic_name__			, **__magic_name__				)
																		lowercase    :      Optional[int]       = """A, <mask> AllenNLP sentence."""
																		lowercase    :      Any       = tokenizer_r.encode_plus(__magic_name__			, add_special_tokens=__magic_name__			, return_token_type_ids=__magic_name__				)
																		lowercase    :      str       = tokenizer_p.encode_plus(__magic_name__			, add_special_tokens=__magic_name__			, return_token_type_ids=__magic_name__				)

																		# token_type_ids should put 0 everywhere
																		self.assertEqual(sum(tokens_r["""token_type_ids"""]				)			, sum(tokens_p["""token_type_ids"""]				)				)

																		# attention_mask should put 1 everywhere, so sum over length should be 1
																		self.assertEqual(
																		    sum(tokens_r["""attention_mask"""]				) / len(tokens_r["""attention_mask"""]				)			, sum(tokens_p["""attention_mask"""]				) / len(tokens_p["""attention_mask"""]				)			, )

																		lowercase    :      Union[str, Any]       = tokenizer_r.convert_ids_to_tokens(tokens_r["""input_ids"""]				)
																		lowercase    :      Dict       = tokenizer_p.convert_ids_to_tokens(tokens_p["""input_ids"""]				)

																		# Rust correctly handles the space before the mask while python doesnt
																		self.assertSequenceEqual(tokens_p["""input_ids"""]			, [0, 250, 6, 50_264, 3_823, 487, 21_992, 3_645, 4, 2]				)
																		self.assertSequenceEqual(tokens_r["""input_ids"""]			, [0, 250, 6, 50_264, 3_823, 487, 21_992, 3_645, 4, 2]				)

																		self.assertSequenceEqual(
																		    __magic_name__			, ["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]				)
																		self.assertSequenceEqual(
																		    __magic_name__			, ["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]				)






						def      __snake_case      (		self  :List[str]				)      ->Tuple:
										for trim_offsets, add_prefix_space in itertools.product([True, False]			, repeat=2				):
														lowercase    :      str       = self.rust_tokenizer_class.from_pretrained(
														    self.tmpdirname			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)

														lowercase    :      str       = json.loads(tokenizer_r.backend_tokenizer.pre_tokenizer.__getstate__()				)
														lowercase    :      Optional[Any]       = json.loads(tokenizer_r.backend_tokenizer.post_processor.__getstate__()				)

														self.assertEqual(pre_tokenizer_state["""add_prefix_space"""]			, __magic_name__				)

														self.assertEqual(post_processor_state["""add_prefix_space"""]			, __magic_name__				)
														self.assertEqual(post_processor_state["""trim_offsets"""]			, __magic_name__				)






						def      __snake_case      (		self  :Dict				)      ->List[str]:
										# Test which aims to verify that the offsets are well adapted to the argument `add_prefix_space` and
										# `trim_offsets`
										for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
														with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""				):
																		lowercase    :      Optional[Any]       = """hello"""  # `hello` is a token in the vocabulary of `pretrained_name`
																		lowercase    :      Optional[Any]       = f"""{text_of_1_token} {text_of_1_token}"""

																		lowercase    :      List[str]       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      List[Any]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (len(__magic_name__				) + 1, len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      List[Any]       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      List[Any]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (len(__magic_name__				) + 1, len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      Tuple       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      List[str]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (len(__magic_name__				), len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      Optional[Any]       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      Optional[int]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (len(__magic_name__				), len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      Optional[int]       = f""" {text}"""

																		# tokenizer_r = self.rust_tokenizer_class.from_pretrained(
																		#     pretrained_name, use_fast=True, add_prefix_space=True, trim_offsets=True
																		# )
																		# encoding = tokenizer_r(text, return_offsets_mapping=True, add_special_tokens=False)
																		# self.assertEqual(encoding.offset_mapping[0], (1, 1 + len(text_of_1_token)))
																		# self.assertEqual(
																		#     encoding.offset_mapping[1],
																		#     (1 + len(text_of_1_token) + 1, 1 + len(text_of_1_token) + 1 + len(text_of_1_token)),
																		# )

																		lowercase    :      Union[str, Any]       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      Union[str, Any]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (1, 1 + len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (1 + len(__magic_name__				) + 1, 1 + len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      int       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      Optional[int]       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, 1 + len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (1 + len(__magic_name__				), 1 + len(__magic_name__				) + 1 + len(__magic_name__				))			, )

																		lowercase    :      str       = self.rust_tokenizer_class.from_pretrained(
																		    __magic_name__			, use_fast=__magic_name__			, add_prefix_space=__magic_name__			, trim_offsets=__magic_name__				)
																		lowercase    :      Any       = tokenizer_r(__magic_name__			, return_offsets_mapping=__magic_name__			, add_special_tokens=__magic_name__				)
																		self.assertEqual(encoding.offset_mapping[0]			, (0, 1 + len(__magic_name__				))				)
																		self.assertEqual(
																		    encoding.offset_mapping[1]			, (1 + len(__magic_name__				), 1 + len(__magic_name__				) + 1 + len(__magic_name__				))			, )
