





import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import (
	    MODEL_FOR_PRETRAINING_MAPPING,
	    MegatronBertForCausalLM,
	    MegatronBertForMaskedLM,
	    MegatronBertForMultipleChoice,
	    MegatronBertForNextSentencePrediction,
	    MegatronBertForPreTraining,
	    MegatronBertForQuestionAnswering,
	    MegatronBertForSequenceClassification,
	    MegatronBertForTokenClassification,
	    MegatronBertModel,
	)




class 	UpperCamelCase_							:


							def __init__(				self     :int				,					__A     :Optional[Any]				,					__A     :Any=13				,					__A     :Optional[int]=7				,					__A     :str=True				,					__A     :Tuple=True				,					__A     :Union[str, Any]=True				,					__A     :int=True				,					__A     :Any=99				,					__A     :Union[str, Any]=64				,					__A     :int=32				,					__A     :Tuple=5				,					__A     :int=4				,					__A     :Tuple=37				,					__A     :Optional[Any]="gelu"				,					__A     :Union[str, Any]=0.1				,					__A     :Any=0.1				,					__A     :str=512				,					__A     :Tuple=16				,					__A     :Optional[Any]=2				,					__A     :Tuple=0.0_2				,					__A     :int=3				,					__A     :Union[str, Any]=4				,					__A     :List[Any]=None				,					) -> Any:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   parent
									SCREAMING_SNAKE_CASE__								=   batch_size
									SCREAMING_SNAKE_CASE__								=   seq_length
									SCREAMING_SNAKE_CASE__								=   is_training
									SCREAMING_SNAKE_CASE__								=   use_input_mask
									SCREAMING_SNAKE_CASE__								=   use_token_type_ids
									SCREAMING_SNAKE_CASE__								=   use_labels
									SCREAMING_SNAKE_CASE__								=   vocab_size
									SCREAMING_SNAKE_CASE__								=   hidden_size
									SCREAMING_SNAKE_CASE__								=   embedding_size
									SCREAMING_SNAKE_CASE__								=   num_hidden_layers
									SCREAMING_SNAKE_CASE__								=   num_attention_heads
									SCREAMING_SNAKE_CASE__								=   intermediate_size
									SCREAMING_SNAKE_CASE__								=   hidden_act
									SCREAMING_SNAKE_CASE__								=   hidden_dropout_prob
									SCREAMING_SNAKE_CASE__								=   attention_probs_dropout_prob
									SCREAMING_SNAKE_CASE__								=   max_position_embeddings
									SCREAMING_SNAKE_CASE__								=   type_vocab_size
									SCREAMING_SNAKE_CASE__								=   type_sequence_label_size
									SCREAMING_SNAKE_CASE__								=   initializer_range
									SCREAMING_SNAKE_CASE__								=   num_labels
									SCREAMING_SNAKE_CASE__								=   num_choices
									SCREAMING_SNAKE_CASE__								=   scope


							def   _snake_case	(				self     :Dict		) -> Optional[Any]:



									"""simple docstring"""



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

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

									SCREAMING_SNAKE_CASE__								=   None
									if self.use_token_type_ids:
											SCREAMING_SNAKE_CASE__								=   ids_tensor([self.batch_size, self.seq_length]				,					self.type_vocab_size		)

									SCREAMING_SNAKE_CASE__								=   None
									SCREAMING_SNAKE_CASE__								=   None
									SCREAMING_SNAKE_CASE__								=   None
									if self.use_labels:
											SCREAMING_SNAKE_CASE__								=   ids_tensor([self.batch_size]				,					self.type_sequence_label_size		)
											SCREAMING_SNAKE_CASE__								=   ids_tensor([self.batch_size, self.seq_length]				,					self.num_labels		)
											SCREAMING_SNAKE_CASE__								=   ids_tensor([self.batch_size]				,					self.num_choices		)

									SCREAMING_SNAKE_CASE__								=   self.get_config()

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


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



									"""simple docstring"""



									return MegatronBertConfig(
									    vocab_size=self.vocab_size				,					hidden_size=self.hidden_size				,					num_hidden_layers=self.num_hidden_layers				,					num_attention_heads=self.num_attention_heads				,					intermediate_size=self.intermediate_size				,					embedding_size=self.embedding_size				,					hidden_act=self.hidden_act				,					hidden_dropout_prob=self.hidden_dropout_prob				,					attention_probs_dropout_prob=self.attention_probs_dropout_prob				,					max_position_embeddings=self.max_position_embeddings				,					type_vocab_size=self.type_vocab_size				,					is_decoder=__A				,					initializer_range=self.initializer_range				,					)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertModel(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(__A				,					attention_mask=__A				,					token_type_ids=__A		)
									SCREAMING_SNAKE_CASE__								=   model(__A				,					token_type_ids=__A		)
									SCREAMING_SNAKE_CASE__								=   model(__A		)

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


							def   _snake_case	(				self     :List[Any]				,					__A     :List[str]				,					__A     :Optional[Any]				,					__A     :Optional[int]				,					__A     :List[str]				,					__A     :List[Any]				,					__A     :int				,					__A     :Any		) -> str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertForMaskedLM(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(__A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A		)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, self.seq_length, self.vocab_size)		)


							def   _snake_case	(				self     :List[Any]				,					__A     :Any				,					__A     :Tuple				,					__A     :str				,					__A     :str				,					__A     :List[str]				,					__A     :Union[str, Any]				,					__A     :Optional[int]		) -> int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertForCausalLM(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(__A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A		)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, self.seq_length, self.vocab_size)		)


							def   _snake_case	(				self     :Tuple				,					__A     :int				,					__A     :Optional[int]				,					__A     :Union[str, Any]				,					__A     :Union[str, Any]				,					__A     :int				,					__A     :Union[str, Any]				,					__A     :str		) -> Tuple:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertForNextSentencePrediction(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(
									    __A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A				,					)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, 2)		)


							def   _snake_case	(				self     :Union[str, Any]				,					__A     :str				,					__A     :Any				,					__A     :Union[str, Any]				,					__A     :List[Any]				,					__A     :Any				,					__A     :str				,					__A     :Dict		) -> Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertForPreTraining(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(
									    __A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A				,					next_sentence_label=__A				,					)
									self.parent.assertEqual(result.prediction_logits.shape				,					(self.batch_size, self.seq_length, self.vocab_size)		)
									self.parent.assertEqual(result.seq_relationship_logits.shape				,					(self.batch_size, 2)		)


							def   _snake_case	(				self     :Optional[Any]				,					__A     :int				,					__A     :Optional[Any]				,					__A     :List[Any]				,					__A     :Tuple				,					__A     :Any				,					__A     :Union[str, Any]				,					__A     :Any		) -> Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertForQuestionAnswering(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(
									    __A				,					attention_mask=__A				,					token_type_ids=__A				,					start_positions=__A				,					end_positions=__A				,					)
									self.parent.assertEqual(result.start_logits.shape				,					(self.batch_size, self.seq_length)		)
									self.parent.assertEqual(result.end_logits.shape				,					(self.batch_size, self.seq_length)		)


							def   _snake_case	(				self     :str				,					__A     :int				,					__A     :List[Any]				,					__A     :Tuple				,					__A     :Optional[Any]				,					__A     :Optional[int]				,					__A     :Dict				,					__A     :Optional[int]		) -> str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.num_labels
									SCREAMING_SNAKE_CASE__								=   MegatronBertForSequenceClassification(__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(__A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A		)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, self.num_labels)		)


							def   _snake_case	(				self     :Optional[Any]				,					__A     :List[Any]				,					__A     :List[Any]				,					__A     :Any				,					__A     :Tuple				,					__A     :Any				,					__A     :Optional[int]				,					__A     :str		) -> List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.num_labels
									SCREAMING_SNAKE_CASE__								=   MegatronBertForTokenClassification(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   model(__A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A		)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, self.seq_length, self.num_labels)		)


							def   _snake_case	(				self     :Optional[Any]				,					__A     :int				,					__A     :List[Any]				,					__A     :List[str]				,					__A     :Any				,					__A     :List[Any]				,					__A     :Any				,					__A     :Optional[int]		) -> int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.num_choices
									SCREAMING_SNAKE_CASE__								=   MegatronBertForMultipleChoice(config=__A		)
									model.to(__A		)
									model.eval()
									SCREAMING_SNAKE_CASE__								=   input_ids.unsqueeze(1		).expand(-1				,					self.num_choices				,					-1		).contiguous()
									SCREAMING_SNAKE_CASE__								=   token_type_ids.unsqueeze(1		).expand(-1				,					self.num_choices				,					-1		).contiguous()
									SCREAMING_SNAKE_CASE__								=   input_mask.unsqueeze(1		).expand(-1				,					self.num_choices				,					-1		).contiguous()
									SCREAMING_SNAKE_CASE__								=   model(
									    __A				,					attention_mask=__A				,					token_type_ids=__A				,					labels=__A				,					)
									self.parent.assertEqual(result.logits.shape				,					(self.batch_size, self.num_choices)		)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.prepare_config_and_inputs()
									(
									    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    (
									    SCREAMING_SNAKE_CASE__
									)						,    
									)								=   config_and_inputs
									SCREAMING_SNAKE_CASE__								=   {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
									return config, inputs_dict




@require_torch
class 	UpperCamelCase_							(  UpperCamelCase__					,	UpperCamelCase__					,	unittest.TestCase     ):
							lowerCamelCase_							     =       (
							    (
							        MegatronBertModel,
							        MegatronBertForMaskedLM,
							        MegatronBertForCausalLM,
							        MegatronBertForMultipleChoice,
							        MegatronBertForNextSentencePrediction,
							        MegatronBertForPreTraining,
							        MegatronBertForQuestionAnswering,
							        MegatronBertForSequenceClassification,
							        MegatronBertForTokenClassification,
							    )
							    if is_torch_available()
							    else ()
							)
							lowerCamelCase_							     =       (
							    {
							        "feature-extraction": MegatronBertModel,
							        "fill-mask": MegatronBertForMaskedLM,
							        "question-answering": MegatronBertForQuestionAnswering,
							        "text-classification": MegatronBertForSequenceClassification,
							        "text-generation": MegatronBertForCausalLM,
							        "token-classification": MegatronBertForTokenClassification,
							        "zero-shot": MegatronBertForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							lowerCamelCase_							     =       True
							# test_resize_embeddings = False
							lowerCamelCase_							     =       False


							def   _snake_case	(				self     :int				,					__A     :Tuple				,					__A     :List[str]				,					__A     :int=False		) -> int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   super()._prepare_for_class(__A				,					__A				,					return_labels=__A		)

									if return_labels:
											if model_class in get_values(__A		):
													SCREAMING_SNAKE_CASE__								=   torch.zeros(
													    (self.model_tester.batch_size, self.model_tester.seq_length)				,					dtype=torch.long				,					device=__A		)
													SCREAMING_SNAKE_CASE__								=   torch.zeros(
													    self.model_tester.batch_size				,					dtype=torch.long				,					device=__A		)
									return inputs_dict


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   MegatronBertModelTester(self		)
									SCREAMING_SNAKE_CASE__								=   ConfigTester(self				,					config_class=__A				,					hidden_size=37		)


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



									"""simple docstring"""



									self.config_tester.run_common_tests()


							def   _snake_case	(				self     :int		) -> Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_model(*__A		)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_masked_lm(*__A		)


							def   _snake_case	(				self     :Optional[Any]		) -> Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*__A		)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*__A		)


							def   _snake_case	(				self     :Optional[Any]		) -> Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_pretraining(*__A		)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_question_answering(*__A		)


							def   _snake_case	(				self     :Tuple		) -> Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*__A		)


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_megatron_bert_for_token_classification(*__A		)






def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				List[str]     ):
		return torch.tensor(
		    UpperCamelCase__       , dtype=torch.long       , device=UpperCamelCase__       , )


_lowerCamelCase 					=      1e-4




@require_torch
@require_sentencepiece
@require_tokenizers
class 	UpperCamelCase_							(  unittest.TestCase     ):


							@slow
							@unittest.skip("""Model is not available."""		)
							def   _snake_case	(				self     :int		) -> List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   """nvidia/megatron-bert-uncased-345m"""
									if "MYDIR" in os.environ:
											SCREAMING_SNAKE_CASE__								=   os.path.join(os.environ["""MYDIR"""]				,					__A		)
									SCREAMING_SNAKE_CASE__								=   MegatronBertModel.from_pretrained(__A		)
									model.to(__A		)
									model.half()
									SCREAMING_SNAKE_CASE__								=   _long_tensor([[101, 7110, 1005, 1056, 2023, 1_1333, 1_7413, 1029, 102]]		)
									with torch.no_grad():
											SCREAMING_SNAKE_CASE__								=   model(__A		)[0]
									SCREAMING_SNAKE_CASE__								=   torch.Size((1, 9, 1024)		)
									self.assertEqual(output.shape				,					__A		)

									SCREAMING_SNAKE_CASE__								=   [-0.6_0_4_0, -0.2_5_1_7, -0.1_0_2_5, 0.3_4_2_0, -0.6_7_5_8, -0.0_0_1_7, -0.1_0_8_9, -0.1_9_9_0, 0.5_7_2_8]
									for ii in range(3		):
											for jj in range(3		):
													SCREAMING_SNAKE_CASE__								=   output[0, ii, jj]
													SCREAMING_SNAKE_CASE__								=   expected[3 * ii + jj]
													SCREAMING_SNAKE_CASE__								=   """ii={} jj={} a={} b={}""".format(__A				,					__A				,					__A				,					__A		)
													self.assertTrue(math.isclose(__A				,					__A				,					rel_tol=__A				,					abs_tol=__A		)				,					msg=__A		)






from typing import Dict, List, Optional

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


_lowerCamelCase 					=      logging.get_logger(__name__)


_lowerCamelCase 					=      {
    'nielsr/canine-s': 2048,
}

# Unicode defines 1,114,112 total “codepoints”
_lowerCamelCase 					=      1114112

# Below: Constants defining canonical codepoints for special, pseudo-characters.
# Copied from https://github.com/google-research/language/blob/master/language/canine/special_codepoints.py
_lowerCamelCase 					=      0

_lowerCamelCase 					=      0XE0_00
_lowerCamelCase 					=      0XE0_01
_lowerCamelCase 					=      0XE0_02
_lowerCamelCase 					=      0XE0_03
_lowerCamelCase 					=      0XE0_04

# Maps special codepoints to human-readable names.
_lowerCamelCase 					=      {
    # Special symbols are represented using codepoints values that are valid,
    # but designated as "Private Use", meaning that they will never be assigned
    # characters by the Unicode Consortium, and are thus safe for use here.
    #
    # NOTE: Do *NOT* add any sort of [UNK_CHAR] here. They are explicitly
    # excluded and should fail with a hard error.
    CLS: "[CLS]",
    SEP: "[SEP]",
    BOS: "[BOS]",
    MASK: "[MASK]",
    PAD: "[PAD]",
    RESERVED: "[RESERVED]",
}

# Maps special codepoint human-readable names to their codepoint values.
_lowerCamelCase 					=      {name: codepoint for codepoint, name in SPECIAL_CODEPOINTS.items()}




class 	UpperCamelCase_							(  UpperCamelCase__     ):
							lowerCamelCase_							     =       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES


							def __init__(				self     :str				,					__A     :str=chr(__A		)				,					__A     :str=chr(__A		)				,					__A     :Dict=chr(__A		)				,					__A     :str=chr(__A		)				,					__A     :Union[str, Any]=chr(__A		)				,					__A     :str=chr(__A		)				,					__A     :int=False				,					__A     :int=2048				,					**__A     :Dict				,					) -> Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else bos_token
									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else eos_token
									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else sep_token
									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else cls_token
									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else pad_token

									# Mask token behave like a normal word, i.e. include the space before it
									SCREAMING_SNAKE_CASE__								=   AddedToken(__A				,					lstrip=__A				,					rstrip=__A		) if isinstance(__A				,					__A		) else mask_token

									super().__init__(
									    bos_token=__A				,					eos_token=__A				,					sep_token=__A				,					cls_token=__A				,					pad_token=__A				,					mask_token=__A				,					add_prefix_space=__A				,					model_max_length=__A				,					**__A				,					)

									# Creates a mapping for looking up the IDs of special symbols.
									SCREAMING_SNAKE_CASE__								=   {}
									for codepoint, name in SPECIAL_CODEPOINTS.items():
											SCREAMING_SNAKE_CASE__								=   codepoint

									# Creates a mapping for looking up the string forms of special symbol IDs.
									SCREAMING_SNAKE_CASE__								=   {
									    codepoint: name for name, codepoint in self._special_codepoints.items()
									}

									SCREAMING_SNAKE_CASE__								=   UNICODE_VOCAB_SIZE
									SCREAMING_SNAKE_CASE__								=   len(self._special_codepoints		)


							@property
							def   _snake_case	(				self     :Optional[Any]		) -> int:



									"""simple docstring"""



									return self._unicode_vocab_size


							def   _snake_case	(				self     :Tuple				,					__A     :str		) -> List[str]:



									"""simple docstring"""



									return list(__A		)


							def   _snake_case	(				self     :Optional[Any]				,					__A     :str		) -> int:



									"""simple docstring"""



									try:
											return ord(__A		)
									except TypeError:
											raise ValueError(f'''invalid token: \'{token}\''''		)


							def   _snake_case	(				self     :str				,					__A     :int		) -> str:



									"""simple docstring"""



									try:
											if index in SPECIAL_CODEPOINTS:
													return SPECIAL_CODEPOINTS[index]
											return chr(__A		)
									except TypeError:
											raise ValueError(f'''invalid id: {index}'''		)


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



									"""simple docstring"""



									return "".join(__A		)


							def   _snake_case	(				self     :Optional[Any]				,					__A     :List[int]				,					__A     :Optional[List[int]] = None		) -> List[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   [self.sep_token_id]
									SCREAMING_SNAKE_CASE__								=   [self.cls_token_id]

									SCREAMING_SNAKE_CASE__								=   cls + token_ids_a + sep
									if token_ids_a is not None:
											result += token_ids_a + sep
									return result


							def   _snake_case	(				self     :List[Any]				,					__A     :List[int]				,					__A     :Optional[List[int]] = None				,					__A     :bool = False		) -> List[int]:



									"""simple docstring"""



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

									SCREAMING_SNAKE_CASE__								=   [1] + ([0] * len(__A		)) + [1]
									if token_ids_a is not None:
											result += ([0] * len(__A		)) + [1]
									return result


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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   [self.sep_token_id]
									SCREAMING_SNAKE_CASE__								=   [self.cls_token_id]

									SCREAMING_SNAKE_CASE__								=   len(cls + token_ids_a + sep		) * [0]
									if token_ids_a is not None:
											result += len(token_ids_a + sep		) * [1]
									return result


							def   _snake_case	(				self     :int				,					__A     :str				,					__A     :Optional[str] = None		) -> Any:



									"""simple docstring"""



									return ()