




'''simple docstring'''


import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
				import jax
				import jax.numpy as jnp

				from transformers.modeling_flax_pytorch_utils import (
				    convert_pytorch_state_dict_to_flax,
				    load_flax_weights_in_pytorch_model,
				)
				from transformers.models.gptj.modeling_flax_gptj import FlaxGPTJForCausalLM, FlaxGPTJModel

if is_torch_available():
				import torch

class      A       :







							def __init__(    self			:    Union[str, Any]				,     lowerCAmelCase_			:    Any				,     lowerCAmelCase_			:    Tuple=14				,     lowerCAmelCase_			:    str=7				,     lowerCAmelCase_			:    Optional[Any]=True				,     lowerCAmelCase_			:    Dict=True				,     lowerCAmelCase_			:    Any=False				,     lowerCAmelCase_			:    List[str]=True				,     lowerCAmelCase_			:    List[str]=99				,     lowerCAmelCase_			:    Tuple=32				,     lowerCAmelCase_			:    Optional[int]=4				,     lowerCAmelCase_			:    Optional[Any]=4				,     lowerCAmelCase_			:    Union[str, Any]=4				,     lowerCAmelCase_			:    Optional[int]=37				,     lowerCAmelCase_			:    List[Any]="gelu"				,     lowerCAmelCase_			:    List[str]=0.1				,     lowerCAmelCase_			:    str=0.1				,     lowerCAmelCase_			:    Any=5_12				,     lowerCAmelCase_			:    Union[str, Any]=0.0_2				,     )     ->				Dict:


														"""simple docstring"""


														_a      	=							parent
														_a      	=							batch_size
														_a      	=							seq_length
														_a      	=							is_training
														_a      	=							use_input_mask
														_a      	=							use_token_type_ids
														_a      	=							use_labels
														_a      	=							vocab_size
														_a      	=							hidden_size
														_a      	=							rotary_dim
														_a      	=							num_hidden_layers
														_a      	=							num_attention_heads
														_a      	=							intermediate_size
														_a      	=							hidden_act
														_a      	=							hidden_dropout_prob
														_a      	=							attention_probs_dropout_prob
														_a      	=							max_position_embeddings
														_a      	=							initializer_range
														_a      	=							None
														_a      	=							vocab_size - 1
														_a      	=							vocab_size - 1
														_a      	=							vocab_size - 1







							def   __lowerCAmelCase     (    self			:    str   )     ->				str:


														"""simple docstring"""


														_a      	=							ids_tensor([self.batch_size, self.seq_length]				,     self.vocab_size   )

														_a      	=							None
														if self.use_input_mask:
																					_a      	=							random_attention_mask([self.batch_size, self.seq_length]   )

														_a      	=							GPTJConfig(
														    vocab_size=self.vocab_size				,     n_embd=self.hidden_size				,     n_layer=self.num_hidden_layers				,     n_head=self.num_attention_heads				,     n_positions=self.max_position_embeddings				,     use_cache=lowerCAmelCase_				,     bos_token_id=self.bos_token_id				,     eos_token_id=self.eos_token_id				,     pad_token_id=self.pad_token_id				,     rotary_dim=self.rotary_dim				,     )

														return (config, input_ids, input_mask)







							def   __lowerCAmelCase     (    self			:    List[Any]   )     ->				Optional[Any]:


														"""simple docstring"""


														_a      	=							self.prepare_config_and_inputs()
														_a	,				_a	,				_a      	=							config_and_inputs
														_a      	=							{'''input_ids''': input_ids, '''attention_mask''': attention_mask}
														return config, inputs_dict







							def   __lowerCAmelCase     (    self			:    Optional[Any]				,     lowerCAmelCase_			:    Optional[int]				,     lowerCAmelCase_			:    Tuple				,     lowerCAmelCase_			:    Any				,     lowerCAmelCase_			:    Any   )     ->				Dict:


														"""simple docstring"""


														_a      	=							20
														_a      	=							model_class_name(lowerCAmelCase_   )

														_a      	=							model.init_cache(input_ids.shape[0]				,     lowerCAmelCase_   )
														_a      	=							jnp.ones((input_ids.shape[0], max_decoder_length)				,     dtype='''i4'''   )

														_a      	=							jnp.broadcast_to(
														    jnp.arange(input_ids.shape[-1] - 1   )[None, :]				,     (input_ids.shape[0], input_ids.shape[-1] - 1)   )
														_a      	=							model(
														    input_ids[:, :-1]				,     attention_mask=lowerCAmelCase_				,     past_key_values=lowerCAmelCase_				,     position_ids=lowerCAmelCase_				,     )

														_a      	=							jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]				,     dtype='''i4'''   )
														_a      	=							model(
														    input_ids[:, -1:]				,     attention_mask=lowerCAmelCase_				,     past_key_values=outputs_cache.past_key_values				,     position_ids=lowerCAmelCase_				,     )

														_a      	=							model(lowerCAmelCase_   )

														_a      	=							np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])   )   )
														self.parent.assertTrue(diff < 1e-3				,     msg=F'Max diff is {diff}'   )







							def   __lowerCAmelCase     (    self			:    int				,     lowerCAmelCase_			:    str				,     lowerCAmelCase_			:    Dict				,     lowerCAmelCase_			:    List[Any]				,     lowerCAmelCase_			:    List[str]   )     ->				List[Any]:


														"""simple docstring"""


														_a      	=							20
														_a      	=							model_class_name(lowerCAmelCase_   )

														_a      	=							jnp.concatenate(
														    [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])   )]				,     axis=-1				,     )

														_a      	=							model.init_cache(input_ids.shape[0]				,     lowerCAmelCase_   )
														_a      	=							jnp.broadcast_to(
														    jnp.arange(input_ids.shape[-1] - 1   )[None, :]				,     (input_ids.shape[0], input_ids.shape[-1] - 1)   )

														_a      	=							model(
														    input_ids[:, :-1]				,     attention_mask=lowerCAmelCase_				,     past_key_values=lowerCAmelCase_				,     position_ids=lowerCAmelCase_				,     )
														_a      	=							jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]				,     dtype='''i4'''   )
														_a      	=							model(
														    input_ids[:, -1:]				,     past_key_values=outputs_cache.past_key_values				,     attention_mask=lowerCAmelCase_				,     position_ids=lowerCAmelCase_				,     )

														_a      	=							model(lowerCAmelCase_				,     attention_mask=lowerCAmelCase_   )

														_a      	=							np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])   )   )
														self.parent.assertTrue(diff < 1e-3				,     msg=F'Max diff is {diff}'   )



@require_flax
class      A       (						_a	,_a	,unittest.TestCase       ):
							lowercase_							     =							(FlaxGPTJModel, FlaxGPTJForCausalLM) if is_flax_available() else ()
							lowercase_							     =							(FlaxGPTJForCausalLM,) if is_flax_available() else ()







							def   __lowerCAmelCase     (    self			:    Any   )     ->				int:


														"""simple docstring"""


														_a      	=							FlaxGPTJModelTester(self   )







							def   __lowerCAmelCase     (    self			:    int   )     ->				List[str]:


														"""simple docstring"""


														for model_class_name in self.all_model_classes:
																					_a	,				_a	,				_a      	=							self.model_tester.prepare_config_and_inputs()
																					self.model_tester.check_use_cache_forward(lowerCAmelCase_				,     lowerCAmelCase_				,     lowerCAmelCase_				,     lowerCAmelCase_   )







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


														"""simple docstring"""


														for model_class_name in self.all_model_classes:
																					_a	,				_a	,				_a      	=							self.model_tester.prepare_config_and_inputs()
																					self.model_tester.check_use_cache_forward_with_attn_mask(
																					    lowerCAmelCase_				,     lowerCAmelCase_				,     lowerCAmelCase_				,     lowerCAmelCase_   )







							@tooslow
							def   __lowerCAmelCase     (    self			:    Optional[int]   )     ->				Tuple:


														"""simple docstring"""


														_a      	=							GPTaTokenizer.from_pretrained('''gpt2'''				,     pad_token='''<|endoftext|>'''				,     padding_side='''left'''   )
														_a      	=							tokenizer(['''Hello this is a long string''', '''Hey''']				,     return_tensors='''np'''				,     padding=lowerCAmelCase_				,     truncation=lowerCAmelCase_   )

														_a      	=							FlaxGPTJForCausalLM.from_pretrained('''EleutherAI/gpt-j-6B'''   )
														_a      	=							False
														_a      	=							model.config.eos_token_id

														_a      	=							jax.jit(model.generate   )

														_a      	=							jit_generate(
														    inputs['''input_ids''']				,     attention_mask=inputs['''attention_mask''']				,     pad_token_id=tokenizer.pad_token_id   ).sequences

														_a      	=							tokenizer.batch_decode(lowerCAmelCase_				,     skip_special_tokens=lowerCAmelCase_   )

														_a      	=							[
														    '''Hello this is a long string of text.\n\nI\'m trying to get the text of the''',
														    '''Hey, I\'m a little late to the party. I\'m going to''',
														]

														self.assertListEqual(lowerCAmelCase_				,     lowerCAmelCase_   )







							@is_pt_flax_cross_test
							def   __lowerCAmelCase     (    self			:    Optional[int]   )     ->				Optional[int]:


														"""simple docstring"""


														_a	,				_a      	=							self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					with self.subTest(model_class.__name__   ):
																												# prepare inputs
																												_a      	=							self._prepare_for_class(lowerCAmelCase_				,     lowerCAmelCase_   )
																												_a      	=							{k: torch.tensor(v.tolist()   ) for k, v in prepared_inputs_dict.items()}

																												# load corresponding PyTorch class
																												_a      	=							model_class.__name__[4:]  # Skip the "Flax" at the beginning
																												_a      	=							getattr(lowerCAmelCase_				,     lowerCAmelCase_   )

																												_a	,				_a      	=							pt_inputs['''input_ids'''].shape
																												_a      	=							np.random.randint(0				,     seq_length - 1				,     size=(batch_size,)   )
																												for batch_idx, start_index in enumerate(lowerCAmelCase_   ):
																																			_a      	=							0
																																			_a      	=							1
																																			_a      	=							0
																																			_a      	=							1
																												_a      	=							pt_model_class(lowerCAmelCase_   ).eval()
																												_a      	=							model_class(lowerCAmelCase_				,     dtype=jnp.floataa   )

																												_a      	=							convert_pytorch_state_dict_to_flax(pt_model.state_dict()				,     lowerCAmelCase_   )
																												_a      	=							fx_state

																												with torch.no_grad():
																																			_a      	=							pt_model(**lowerCAmelCase_   ).to_tuple()

																												_a      	=							fx_model(**lowerCAmelCase_   ).to_tuple()
																												self.assertEqual(len(lowerCAmelCase_   )				,     len(lowerCAmelCase_   )				,     '''Output lengths differ between Flax and PyTorch'''   )
																												for fx_output, pt_output in zip(lowerCAmelCase_				,     lowerCAmelCase_   ):
																																			self.assert_almost_equals(fx_output[:, -1]				,     pt_output[:, -1].numpy()				,     4e-2   )

																												with tempfile.TemporaryDirectory() as tmpdirname:
																																			pt_model.save_pretrained(lowerCAmelCase_   )
																																			_a      	=							model_class.from_pretrained(lowerCAmelCase_				,     from_pt=lowerCAmelCase_   )

																												_a      	=							fx_model_loaded(**lowerCAmelCase_   ).to_tuple()
																												self.assertEqual(
																												    len(lowerCAmelCase_   )				,     len(lowerCAmelCase_   )				,     '''Output lengths differ between Flax and PyTorch'''   )
																												for fx_output_loaded, pt_output in zip(lowerCAmelCase_				,     lowerCAmelCase_   ):
																																			self.assert_almost_equals(fx_output_loaded[:, -1]				,     pt_output[:, -1].numpy()				,     4e-2   )







							@is_pt_flax_cross_test
							def   __lowerCAmelCase     (    self			:    Optional[int]   )     ->				int:


														"""simple docstring"""


														_a	,				_a      	=							self.model_tester.prepare_config_and_inputs_for_common()
														for model_class in self.all_model_classes:
																					with self.subTest(model_class.__name__   ):
																												# prepare inputs
																												_a      	=							self._prepare_for_class(lowerCAmelCase_				,     lowerCAmelCase_   )
																												_a      	=							{k: torch.tensor(v.tolist()   ) for k, v in prepared_inputs_dict.items()}

																												# load corresponding PyTorch class
																												_a      	=							model_class.__name__[4:]  # Skip the "Flax" at the beginning
																												_a      	=							getattr(lowerCAmelCase_				,     lowerCAmelCase_   )

																												_a      	=							pt_model_class(lowerCAmelCase_   ).eval()
																												_a      	=							model_class(lowerCAmelCase_				,     dtype=jnp.floataa   )

																												_a      	=							load_flax_weights_in_pytorch_model(lowerCAmelCase_				,     fx_model.params   )
																												_a	,				_a      	=							pt_inputs['''input_ids'''].shape
																												_a      	=							np.random.randint(0				,     seq_length - 1				,     size=(batch_size,)   )
																												for batch_idx, start_index in enumerate(lowerCAmelCase_   ):
																																			_a      	=							0
																																			_a      	=							1
																																			_a      	=							0
																																			_a      	=							1

																												# make sure weights are tied in PyTorch
																												pt_model.tie_weights()

																												with torch.no_grad():
																																			_a      	=							pt_model(**lowerCAmelCase_   ).to_tuple()

																												_a      	=							fx_model(**lowerCAmelCase_   ).to_tuple()
																												self.assertEqual(len(lowerCAmelCase_   )				,     len(lowerCAmelCase_   )				,     '''Output lengths differ between Flax and PyTorch'''   )
																												for fx_output, pt_output in zip(lowerCAmelCase_				,     lowerCAmelCase_   ):
																																			self.assert_almost_equals(fx_output[:, -1]				,     pt_output[:, -1].numpy()				,     4e-2   )

																												with tempfile.TemporaryDirectory() as tmpdirname:
																																			fx_model.save_pretrained(lowerCAmelCase_   )
																																			_a      	=							pt_model_class.from_pretrained(lowerCAmelCase_				,     from_flax=lowerCAmelCase_   )

																												with torch.no_grad():
																																			_a      	=							pt_model_loaded(**lowerCAmelCase_   ).to_tuple()

																												self.assertEqual(
																												    len(lowerCAmelCase_   )				,     len(lowerCAmelCase_   )				,     '''Output lengths differ between Flax and PyTorch'''   )
																												for fx_output, pt_output in zip(lowerCAmelCase_				,     lowerCAmelCase_   ):
																																			self.assert_almost_equals(fx_output[:, -1]				,     pt_output[:, -1].numpy()				,     4e-2   )







							@tooslow
							def   __lowerCAmelCase     (    self			:    Optional[int]   )     ->				List[str]:


														"""simple docstring"""


														for model_class_name in self.all_model_classes:
																					_a      	=							model_class_name.from_pretrained('''EleutherAI/gpt-j-6B'''   )
																					_a      	=							model(np.ones((1, 1)   )   )
																					self.assertIsNotNone(lowerCAmelCase_   )







'''simple docstring'''


import json
import os
import unittest

from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast
from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, require_torch
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class      A       (						_a	,unittest.TestCase       ):
							lowercase_							     =							LEDTokenizer
							lowercase_							     =							LEDTokenizerFast
							lowercase_							     =							True







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


														"""simple docstring"""


														super().setUp()
														_a      	=							[
														    '''l''',
														    '''o''',
														    '''w''',
														    '''e''',
														    '''r''',
														    '''s''',
														    '''t''',
														    '''i''',
														    '''d''',
														    '''n''',
														    '''\u0120''',
														    '''\u0120l''',
														    '''\u0120n''',
														    '''\u0120lo''',
														    '''\u0120low''',
														    '''er''',
														    '''\u0120lowest''',
														    '''\u0120newer''',
														    '''\u0120wider''',
														    '''<unk>''',
														]
														_a      	=							dict(zip(lowerCAmelCase_				,     range(len(lowerCAmelCase_   )   )   )   )
														_a      	=							['''#version: 0.2''', '''\u0120 l''', '''\u0120l o''', '''\u0120lo w''', '''e r''', '''''']
														_a      	=							{'''unk_token''': '''<unk>'''}

														_a      	=							os.path.join(self.tmpdirname				,     VOCAB_FILES_NAMES['''vocab_file''']   )
														_a      	=							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(lowerCAmelCase_   ) + '''\n'''   )
														with open(self.merges_file				,     '''w'''				,     encoding='''utf-8'''   ) as fp:
																					fp.write('''\n'''.join(lowerCAmelCase_   )   )







							def   __lowerCAmelCase     (    self			:    Union[str, Any]				,     **lowerCAmelCase_			:    int   )     ->				Optional[int]:


														"""simple docstring"""


														kwargs.update(self.special_tokens_map   )
														return self.tokenizer_class.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Optional[Any]				,     **lowerCAmelCase_			:    Any   )     ->				int:


														"""simple docstring"""


														kwargs.update(self.special_tokens_map   )
														return self.rust_tokenizer_class.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Optional[Any]				,     lowerCAmelCase_			:    Dict   )     ->				List[str]:


														"""simple docstring"""


														return "lower newer", "lower newer"







							@cached_property
							def   __lowerCAmelCase     (    self			:    Dict   )     ->				int:


														"""simple docstring"""


														return LEDTokenizer.from_pretrained('''allenai/led-base-16384'''   )







							@cached_property
							def   __lowerCAmelCase     (    self			:    List[str]   )     ->				Union[str, Any]:


														"""simple docstring"""


														return LEDTokenizerFast.from_pretrained('''allenai/led-base-16384'''   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    int   )     ->				Tuple:


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
														_a      	=							[0, 2_50, 2_51, 1_78_18, 13, 3_91_86, 19_38, 4, 2]

														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     max_length=len(lowerCAmelCase_   )				,     padding=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIsInstance(lowerCAmelCase_				,     lowerCAmelCase_   )

																					self.assertEqual((2, 9)				,     batch.input_ids.shape   )
																					self.assertEqual((2, 9)				,     batch.attention_mask.shape   )
																					_a      	=							batch.input_ids.tolist()[0]
																					self.assertListEqual(lowerCAmelCase_				,     lowerCAmelCase_   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    Tuple   )     ->				List[Any]:


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     padding=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIn('''input_ids'''				,     lowerCAmelCase_   )
																					self.assertIn('''attention_mask'''				,     lowerCAmelCase_   )
																					self.assertNotIn('''labels'''				,     lowerCAmelCase_   )
																					self.assertNotIn('''decoder_attention_mask'''				,     lowerCAmelCase_   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    List[str]   )     ->				str:


														"""simple docstring"""


														_a      	=							[
														    '''Summary of the text.''',
														    '''Another summary.''',
														]
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(text_target=lowerCAmelCase_				,     max_length=32				,     padding='''max_length'''				,     return_tensors='''pt'''   )
																					self.assertEqual(32				,     targets['''input_ids'''].shape[1]   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    Any   )     ->				Union[str, Any]:


														"""simple docstring"""


														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(
																					    ['''I am a small frog''' * 10_24, '''I am a small frog''']				,     padding=lowerCAmelCase_				,     truncation=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					self.assertIsInstance(lowerCAmelCase_				,     lowerCAmelCase_   )
																					self.assertEqual(batch.input_ids.shape				,     (2, 51_22)   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    Optional[Any]   )     ->				Union[str, Any]:


														"""simple docstring"""


														_a      	=							['''A long paragraph for summarization.''']
														_a      	=							[
														    '''Summary of the text.''',
														]
														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							tokenizer(lowerCAmelCase_				,     return_tensors='''pt'''   )
																					_a      	=							tokenizer(text_target=lowerCAmelCase_				,     return_tensors='''pt'''   )
																					_a      	=							inputs['''input_ids''']
																					_a      	=							targets['''input_ids''']
																					self.assertTrue((input_ids[:, 0] == tokenizer.bos_token_id).all().item()   )
																					self.assertTrue((labels[:, 0] == tokenizer.bos_token_id).all().item()   )
																					self.assertTrue((input_ids[:, -1] == tokenizer.eos_token_id).all().item()   )
																					self.assertTrue((labels[:, -1] == tokenizer.eos_token_id).all().item()   )







							@require_torch
							def   __lowerCAmelCase     (    self			:    Any   )     ->				Union[str, Any]:


														"""simple docstring"""


														for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
																					_a      	=							['''Summary of the text.''', '''Another summary.''']
																					_a      	=							[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -1]]

																					_a      	=							tokenizer(lowerCAmelCase_				,     padding=lowerCAmelCase_   )
																					_a      	=							[[0] * len(lowerCAmelCase_   ) for x in encoded_output['''input_ids''']]
																					_a      	=							tokenizer.pad(lowerCAmelCase_   )
																					self.assertSequenceEqual(outputs['''global_attention_mask''']				,     lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Dict:


														"""simple docstring"""


														pass







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Optional[Any]:


														"""simple docstring"""


														for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																					with self.subTest(F'{tokenizer.__class__.__name__} ({pretrained_name})'   ):
																												_a      	=							self.rust_tokenizer_class.from_pretrained(lowerCAmelCase_				,     **lowerCAmelCase_   )
																												_a      	=							self.tokenizer_class.from_pretrained(lowerCAmelCase_				,     **lowerCAmelCase_   )
																												_a      	=							'''A, <mask> AllenNLP sentence.'''
																												_a      	=							tokenizer_r.encode_plus(lowerCAmelCase_				,     add_special_tokens=lowerCAmelCase_				,     return_token_type_ids=lowerCAmelCase_   )
																												_a      	=							tokenizer_p.encode_plus(lowerCAmelCase_				,     add_special_tokens=lowerCAmelCase_				,     return_token_type_ids=lowerCAmelCase_   )
																												self.assertEqual(sum(tokens_r['''token_type_ids''']   )				,     sum(tokens_p['''token_type_ids''']   )   )
																												self.assertEqual(
																												    sum(tokens_r['''attention_mask''']   ) / len(tokens_r['''attention_mask''']   )				,     sum(tokens_p['''attention_mask''']   ) / len(tokens_p['''attention_mask''']   )				,     )

																												_a      	=							tokenizer_r.convert_ids_to_tokens(tokens_r['''input_ids''']   )
																												_a      	=							tokenizer_p.convert_ids_to_tokens(tokens_p['''input_ids''']   )
																												self.assertSequenceEqual(tokens_p['''input_ids''']				,     [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]   )
																												self.assertSequenceEqual(tokens_r['''input_ids''']				,     [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2]   )

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

