




import os
import pickle
import tempfile
import unittest
from typing import Callable, Optional

import numpy as np

from transformers import (
    BatchEncoding,
    BertTokenizer,
    BertTokenizerFast,
    PreTrainedTokenizer,
    PreTrainedTokenizerFast,
    TensorType,
    TokenSpan,
    is_tokenizers_available,
)
from transformers.models.gpta.tokenization_gpta import GPTaTokenizer
from transformers.testing_utils import CaptureStderr, require_flax, require_tf, require_tokenizers, require_torch, slow


if is_tokenizers_available():
		from tokenizers import Tokenizer
		from tokenizers.models import WordPiece





class 		A__    (       unittest.TestCase			):






	def 			lowercase				(     self    ,					lowerCamelCase						)				->       str:




						"""simple docstring"""






						__magic_name__ :							Optional[int]		       =							list(tokenizer_class.max_model_input_sizes.keys()						)
						for model_name in sa_models[:1]:
											__magic_name__ :							int		       =							tokenizer_class.from_pretrained(__UpperCamelCase						)
											self.assertIsNotNone(__UpperCamelCase						)
											self.assertIsInstance(__UpperCamelCase    ,					__UpperCamelCase						)
											self.assertIsInstance(__UpperCamelCase    ,					__UpperCamelCase						)

											for special_tok in tokenizer.all_special_tokens:
																self.assertIsInstance(__UpperCamelCase    ,					__UpperCamelCase						)
																__magic_name__ :							Optional[Any]		       =							tokenizer.convert_tokens_to_ids(__UpperCamelCase						)
																self.assertIsInstance(__UpperCamelCase    ,					__UpperCamelCase						)






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase = None						)				->       Optional[Any]:




						"""simple docstring"""






						__magic_name__ :							Optional[int]		       =							pickle.dumps(__UpperCamelCase						)
						self.assertIsNotNone(__UpperCamelCase						)

						__magic_name__ :							str		       =							pickle.loads(__UpperCamelCase						)

						# Ensure is_fast is correctly restored
						self.assertEqual(be_restored.is_fast    ,					be_original.is_fast						)

						# Ensure encodings are potentially correctly restored
						if be_original.is_fast:
											self.assertIsNotNone(be_restored.encodings						)
						else:
											self.assertIsNone(be_restored.encodings						)

						# Ensure the keys are the same
						for original_v, restored_v in zip(be_original.values()    ,					be_restored.values()						):
											if equal_op:
																self.assertTrue(equal_op(__UpperCamelCase    ,					__UpperCamelCase						)						)
											else:
																self.assertEqual(__UpperCamelCase    ,					__UpperCamelCase						)






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




						"""simple docstring"""






						self.check_tokenizer_from_pretrained(__UpperCamelCase						)






	def 			lowercase				(     self						)				->       Optional[int]:




						"""simple docstring"""






						self.assertEqual(TensorType('''tf'''						)    ,					TensorType.TENSORFLOW						)
						self.assertEqual(TensorType('''pt'''						)    ,					TensorType.PYTORCH						)
						self.assertEqual(TensorType('''np'''						)    ,					TensorType.NUMPY						)






	@require_tokenizers
	def 			lowercase				(     self						)				->       List[Any]:




						"""simple docstring"""






						import numpy as np

						__magic_name__ :							Dict		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)
						__magic_name__ :							Any		       =							BertTokenizerFast.from_pretrained('''bert-base-cased'''						)

						# Python no tensor
						with self.subTest('''BatchEncoding (Python, return_tensors=None)'''						):
											self.assert_dump_and_restore(tokenizer_p('''Small example to encode'''						)						)

						with self.subTest('''BatchEncoding (Python, return_tensors=NUMPY)'''						):
											self.assert_dump_and_restore(
											    tokenizer_p('''Small example to encode'''    ,					return_tensors=TensorType.NUMPY						)    ,					np.array_equal						)

						with self.subTest('''BatchEncoding (Rust, return_tensors=None)'''						):
											self.assert_dump_and_restore(tokenizer_r('''Small example to encode'''						)						)

						with self.subTest('''BatchEncoding (Rust, return_tensors=NUMPY)'''						):
											self.assert_dump_and_restore(
											    tokenizer_r('''Small example to encode'''    ,					return_tensors=TensorType.NUMPY						)    ,					np.array_equal						)






	@require_tf
	@require_tokenizers
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						import tensorflow as tf

						def tf_array_equals(lowerCamelCase    ,					lowerCamelCase						):
											return tf.reduce_all(tf.equal(__UpperCamelCase    ,					__UpperCamelCase						)						)

						__magic_name__ :							str		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)
						__magic_name__ :							int		       =							BertTokenizerFast.from_pretrained('''bert-base-cased'''						)

						with self.subTest('''BatchEncoding (Python, return_tensors=TENSORFLOW)'''						):
											self.assert_dump_and_restore(
											    tokenizer_p('''Small example to encode'''    ,					return_tensors=TensorType.TENSORFLOW						)    ,					__UpperCamelCase						)

						with self.subTest('''BatchEncoding (Rust, return_tensors=TENSORFLOW)'''						):
											self.assert_dump_and_restore(
											    tokenizer_r('''Small example to encode'''    ,					return_tensors=TensorType.TENSORFLOW						)    ,					__UpperCamelCase						)






	@require_torch
	@require_tokenizers
	def 			lowercase				(     self						)				->       List[Any]:




						"""simple docstring"""






						import torch

						__magic_name__ :							List[Any]		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)
						__magic_name__ :							Dict		       =							BertTokenizerFast.from_pretrained('''bert-base-cased'''						)

						with self.subTest('''BatchEncoding (Python, return_tensors=PYTORCH)'''						):
											self.assert_dump_and_restore(
											    tokenizer_p('''Small example to encode'''    ,					return_tensors=TensorType.PYTORCH						)    ,					torch.equal						)

						with self.subTest('''BatchEncoding (Rust, return_tensors=PYTORCH)'''						):
											self.assert_dump_and_restore(
											    tokenizer_r('''Small example to encode'''    ,					return_tensors=TensorType.PYTORCH						)    ,					torch.equal						)






	@require_tokenizers
	def 			lowercase				(     self						)				->       Tuple:




						"""simple docstring"""






						__magic_name__ :							Optional[Any]		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)
						__magic_name__ :							Tuple		       =							BertTokenizerFast.from_pretrained('''bert-base-cased'''						)

						with self.subTest('''Python Tokenizer'''						):
											self.assertFalse(tokenizer_p('''Small example to_encode'''						).is_fast						)

						with self.subTest('''Rust Tokenizer'''						):
											self.assertTrue(tokenizer_r('''Small example to_encode'''						).is_fast						)






	@require_tokenizers
	def 			lowercase				(     self						)				->       int:




						"""simple docstring"""






						__magic_name__ :							Any		       =							BertTokenizerFast.from_pretrained('''bert-base-cased'''						)
						__magic_name__ :							Union[str, Any]		       =							tokenizer_r(['''Test''', '''\xad''', '''test''']    ,					is_split_into_words=__UpperCamelCase						)

						self.assertEqual(encoded.word_to_tokens(0						)    ,					TokenSpan(start=1    ,					end=2						)						)
						self.assertEqual(encoded.word_to_tokens(1						)    ,					__UpperCamelCase						)
						self.assertEqual(encoded.word_to_tokens(2						)    ,					TokenSpan(start=2    ,					end=3						)						)






	def 			lowercase				(     self						)				->       int:




						"""simple docstring"""






						__magic_name__ :							str		       =							BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}						)
						__magic_name__ :							Dict		       =							batch.convert_to_tensors(tensor_type='''np'''						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(2, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(2,)						)
						# test converting the converted
						with CaptureStderr() as cs:
											__magic_name__ :							int		       =							batch.convert_to_tensors(tensor_type='''np'''						)
						self.assertFalse(len(cs.err						)    ,					msg=F'''should have no warning, but got {cs.err}'''						)

						__magic_name__ :							Optional[Any]		       =							BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}						)
						__magic_name__ :							Optional[int]		       =							batch.convert_to_tensors(tensor_type='''np'''    ,					prepend_batch_axis=__UpperCamelCase						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(1, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(1,)						)






	@require_torch
	def 			lowercase				(     self						)				->       int:




						"""simple docstring"""






						__magic_name__ :							str		       =							BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}						)
						__magic_name__ :							Optional[Any]		       =							batch.convert_to_tensors(tensor_type='''pt'''						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(2, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(2,)						)
						# test converting the converted
						with CaptureStderr() as cs:
											__magic_name__ :							List[Any]		       =							batch.convert_to_tensors(tensor_type='''pt'''						)
						self.assertFalse(len(cs.err						)    ,					msg=F'''should have no warning, but got {cs.err}'''						)

						__magic_name__ :							int		       =							BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}						)
						__magic_name__ :							Any		       =							batch.convert_to_tensors(tensor_type='''pt'''    ,					prepend_batch_axis=__UpperCamelCase						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(1, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(1,)						)






	@require_tf
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						__magic_name__ :							str		       =							BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}						)
						__magic_name__ :							Union[str, Any]		       =							batch.convert_to_tensors(tensor_type='''tf'''						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(2, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(2,)						)
						# test converting the converted
						with CaptureStderr() as cs:
											__magic_name__ :							int		       =							batch.convert_to_tensors(tensor_type='''tf'''						)
						self.assertFalse(len(cs.err						)    ,					msg=F'''should have no warning, but got {cs.err}'''						)

						__magic_name__ :							int		       =							BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}						)
						__magic_name__ :							Tuple		       =							batch.convert_to_tensors(tensor_type='''tf'''    ,					prepend_batch_axis=__UpperCamelCase						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(1, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(1,)						)






	@require_flax
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						__magic_name__ :							Tuple		       =							BatchEncoding({'''inputs''': [[1, 2, 3], [4, 5, 6]], '''labels''': [0, 1]}						)
						__magic_name__ :							int		       =							batch.convert_to_tensors(tensor_type='''jax'''						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(2, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(2,)						)
						# test converting the converted
						with CaptureStderr() as cs:
											__magic_name__ :							List[Any]		       =							batch.convert_to_tensors(tensor_type='''jax'''						)
						self.assertFalse(len(cs.err						)    ,					msg=F'''should have no warning, but got {cs.err}'''						)

						__magic_name__ :							int		       =							BatchEncoding({'''inputs''': [1, 2, 3], '''labels''': 0}						)
						__magic_name__ :							int		       =							batch.convert_to_tensors(tensor_type='''jax'''    ,					prepend_batch_axis=__UpperCamelCase						)
						self.assertEqual(tensor_batch['''inputs'''].shape    ,					(1, 3)						)
						self.assertEqual(tensor_batch['''labels'''].shape    ,					(1,)						)






	def 			lowercase				(     self						)				->       Tuple:




						"""simple docstring"""






						__magic_name__ :							Optional[Any]		       =							[{'input_ids': np.array([0, 1, 2]						)}, {'input_ids': np.array([0, 1, 2, 3]						)}]
						__magic_name__ :							Optional[int]		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)

						__magic_name__ :							str		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					np.ndarray						)						)
						self.assertEqual(batch['''input_ids'''].tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)
						__magic_name__ :							int		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase    ,					return_tensors='''np'''						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					np.ndarray						)						)
						self.assertEqual(batch['''input_ids'''].tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)






	@require_torch
	def 			lowercase				(     self						)				->       Tuple:




						"""simple docstring"""






						import torch

						__magic_name__ :							str		       =							[{'input_ids': torch.tensor([0, 1, 2]						)}, {'input_ids': torch.tensor([0, 1, 2, 3]						)}]
						__magic_name__ :							Optional[int]		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)

						__magic_name__ :							Union[str, Any]		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					torch.Tensor						)						)
						self.assertEqual(batch['''input_ids'''].tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)
						__magic_name__ :							int		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase    ,					return_tensors='''pt'''						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					torch.Tensor						)						)
						self.assertEqual(batch['''input_ids'''].tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)






	@require_tf
	def 			lowercase				(     self						)				->       Any:




						"""simple docstring"""






						import tensorflow as tf

						__magic_name__ :							Any		       =							[{'input_ids': tf.constant([0, 1, 2]						)}, {'input_ids': tf.constant([0, 1, 2, 3]						)}]
						__magic_name__ :							Tuple		       =							BertTokenizer.from_pretrained('''bert-base-cased'''						)

						__magic_name__ :							Any		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					tf.Tensor						)						)
						self.assertEqual(batch['''input_ids'''].numpy().tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)
						__magic_name__ :							Optional[Any]		       =							tokenizer.pad(__UpperCamelCase    ,					padding=__UpperCamelCase    ,					return_tensors='''tf'''						)
						self.assertTrue(isinstance(batch['''input_ids''']    ,					tf.Tensor						)						)
						self.assertEqual(batch['''input_ids'''].numpy().tolist()    ,					[[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]						)






	@require_tokenizers
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						__magic_name__ :							List[Any]		       =							Tokenizer(WordPiece(unk_token='''[UNK]'''						)						)
						PreTrainedTokenizerFast(tokenizer_object=__UpperCamelCase						)






	@require_tokenizers
	def 			lowercase				(     self						)				->       List[str]:




						"""simple docstring"""






						__magic_name__ :							int		       =							Tokenizer(WordPiece(unk_token='''[UNK]'''						)						)
						with tempfile.TemporaryDirectory() as tmpdirname:
											bert_tokenizer.save(os.path.join(__UpperCamelCase    ,					'''tokenizer.json'''						)						)
											PreTrainedTokenizerFast(tokenizer_file=os.path.join(__UpperCamelCase    ,					'''tokenizer.json'''						)						)









from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


lowercase_		=							logging.get_logger(__name__)

lowercase_		=							{
    '''facebook/m2m100_418M''': '''https://huggingface.co/facebook/m2m100_418M/resolve/main/config.json''',
    # See all M2M100 models at https://huggingface.co/models?filter=m2m_100
}





class 		A__    (       __SCREAMING_SNAKE_CASE			):
	lowerCamelCase__		:			Optional[int]       ="m2m_100"
	lowerCamelCase__		:			List[str]       =["past_key_values"]
	lowerCamelCase__		:			Union[str, Any]       ={"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}






	def __init__(     self    ,					lowerCamelCase=128112    ,					lowerCamelCase=1024    ,					lowerCamelCase=12    ,					lowerCamelCase=4096    ,					lowerCamelCase=16    ,					lowerCamelCase=12    ,					lowerCamelCase=4096    ,					lowerCamelCase=16    ,					lowerCamelCase=0.0_5    ,					lowerCamelCase=0.0_5    ,					lowerCamelCase=True    ,					lowerCamelCase=True    ,					lowerCamelCase="relu"    ,					lowerCamelCase=1024    ,					lowerCamelCase=0.1    ,					lowerCamelCase=0.1    ,					lowerCamelCase=0.0    ,					lowerCamelCase=0.0_2    ,					lowerCamelCase=2    ,					lowerCamelCase=True    ,					lowerCamelCase=1    ,					lowerCamelCase=0    ,					lowerCamelCase=2    ,					**lowerCamelCase    ,					)				->       List[str]:




						"""simple docstring"""






						__magic_name__ :							List[Any]		       =							vocab_size
						__magic_name__ :							str		       =							max_position_embeddings
						__magic_name__ :							Union[str, Any]		       =							d_model
						__magic_name__ :							Dict		       =							encoder_ffn_dim
						__magic_name__ :							List[Any]		       =							encoder_layers
						__magic_name__ :							Optional[int]		       =							encoder_attention_heads
						__magic_name__ :							Dict		       =							decoder_ffn_dim
						__magic_name__ :							List[str]		       =							decoder_layers
						__magic_name__ :							Optional[Any]		       =							decoder_attention_heads
						__magic_name__ :							List[Any]		       =							dropout
						__magic_name__ :							List[str]		       =							attention_dropout
						__magic_name__ :							Optional[int]		       =							activation_dropout
						__magic_name__ :							Dict		       =							activation_function
						__magic_name__ :							Tuple		       =							init_std
						__magic_name__ :							Optional[int]		       =							encoder_layerdrop
						__magic_name__ :							int		       =							decoder_layerdrop
						__magic_name__ :							Union[str, Any]		       =							use_cache
						__magic_name__ :							Optional[int]		       =							encoder_layers
						__magic_name__ :							Dict		       =							scale_embedding  # scale factor will be sqrt(d_model) if True

						super().__init__(
						    pad_token_id=lowerCamelCase    ,					bos_token_id=lowerCamelCase    ,					eos_token_id=lowerCamelCase    ,					is_encoder_decoder=lowerCamelCase    ,					decoder_start_token_id=lowerCamelCase    ,					**lowerCamelCase    ,					)





class 		A__    (       __SCREAMING_SNAKE_CASE			):






	@property
	def 			lowercase				(     self						)				->       Mapping[str, Mapping[int, str]]:




						"""simple docstring"""






						__magic_name__ :							Dict		       =							OrderedDict(
						    [
						        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
						        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
						    ]						)

						if self.use_past:
											__magic_name__ :							Optional[Any]		       =							{0: '''batch'''}
											__magic_name__ :							Any		       =							{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
						else:
											__magic_name__ :							Union[str, Any]		       =							{0: '''batch''', 1: '''decoder_sequence'''}
											__magic_name__ :							Optional[Any]		       =							{0: '''batch''', 1: '''decoder_sequence'''}

						if self.use_past:
											self.fill_with_past_key_values_(lowerCamelCase    ,					direction='''inputs'''						)
						return common_inputs






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase = -1    ,					lowerCamelCase = -1    ,					lowerCamelCase = False    ,					lowerCamelCase = None    ,					)				->       Mapping[str, Any]:




						"""simple docstring"""






						__magic_name__ :							int		       =							compute_effective_axis_dimension(
						    lowerCamelCase    ,					fixed_dimension=OnnxConfig.default_fixed_batch    ,					num_token_to_add=0						)

						# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
						__magic_name__ :							str		       =							tokenizer.num_special_tokens_to_add(lowerCamelCase						)
						__magic_name__ :							Optional[Any]		       =							compute_effective_axis_dimension(
						    lowerCamelCase    ,					fixed_dimension=OnnxConfig.default_fixed_sequence    ,					num_token_to_add=lowerCamelCase						)

						# Generate dummy inputs according to compute batch and sequence
						__magic_name__ :							Optional[Any]		       =							[''' '''.join([tokenizer.unk_token]						) * seq_length] * batch_size
						__magic_name__ :							Any		       =							dict(tokenizer(lowerCamelCase    ,					return_tensors=lowerCamelCase						)						)
						return common_inputs






	def 			lowercase				(     self    ,					lowerCamelCase    ,					lowerCamelCase = -1    ,					lowerCamelCase = -1    ,					lowerCamelCase = False    ,					lowerCamelCase = None    ,					)				->       Mapping[str, Any]:




						"""simple docstring"""






						__magic_name__ :							Any		       =							self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
						    lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase						)

						# Generate decoder inputs
						__magic_name__ :							int		       =							seq_length if not self.use_past else 1
						__magic_name__ :							Optional[Any]		       =							self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
						    lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase    ,					lowerCamelCase						)
						__magic_name__ :							List[str]		       =							{F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
						__magic_name__ :							Optional[Any]		       =							dict(**lowerCamelCase    ,					**lowerCamelCase						)

						if self.use_past:
											if not is_torch_available():
																raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''						)
											else:
																import torch
											__magic_name__       ,			__magic_name__ :							List[Any]		       =							common_inputs['''input_ids'''].shape
											__magic_name__ :							List[str]		       =							common_inputs['''decoder_input_ids'''].shape[1]
											__magic_name__       ,			__magic_name__ :							Any		       =							self.num_attention_heads
											__magic_name__ :							Optional[int]		       =							(
											    batch,
											    num_encoder_attention_heads,
											    encoder_seq_length,
											    self._config.hidden_size // num_encoder_attention_heads,
											)
											__magic_name__ :							Tuple		       =							decoder_seq_length + 3
											__magic_name__ :							str		       =							(
											    batch,
											    num_decoder_attention_heads,
											    decoder_past_length,
											    self._config.hidden_size // num_decoder_attention_heads,
											)

											__magic_name__ :							int		       =							torch.cat(
											    [common_inputs['''decoder_attention_mask'''], torch.ones(lowerCamelCase    ,					lowerCamelCase						)]    ,					dim=1						)

											__magic_name__ :							List[str]		       =							[]
											# If the number of encoder and decoder layers are present in the model configuration, both are considered
											__magic_name__       ,			__magic_name__ :							int		       =							self.num_layers
											__magic_name__ :							List[Any]		       =							min(lowerCamelCase    ,					lowerCamelCase						)
											__magic_name__ :							int		       =							max(lowerCamelCase    ,					lowerCamelCase						) - min_num_layers
											__magic_name__ :							Optional[int]		       =							'''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

											for _ in range(lowerCamelCase						):
																common_inputs["past_key_values"].append(
																    (
																        torch.zeros(lowerCamelCase						),
																        torch.zeros(lowerCamelCase						),
																        torch.zeros(lowerCamelCase						),
																        torch.zeros(lowerCamelCase						),
																    )						)
											# TODO: test this.
											__magic_name__ :							Tuple		       =							encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
											for _ in range(lowerCamelCase    ,					lowerCamelCase						):
																common_inputs["past_key_values"].append((torch.zeros(lowerCamelCase						), torch.zeros(lowerCamelCase						))						)
						return common_inputs





	lowerCamelCase__		:			List[str]       =_generate_dummy_inputs_for_default_and_seqaseq_lm



