


'''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__					:





			'''simple docstring'''

			def __init__(  self							:			Tuple			,    lowerCAmelCase_							:			Tuple			,    lowerCAmelCase_							:			List[Any]=14			,    lowerCAmelCase_							:			int=7			,    lowerCAmelCase_							:			Any=True			,    lowerCAmelCase_							:			str=True			,    lowerCAmelCase_							:			Tuple=False			,    lowerCAmelCase_							:			Dict=True			,    lowerCAmelCase_							:			Tuple=99			,    lowerCAmelCase_							:			List[Any]=32			,    lowerCAmelCase_							:			Any=4			,    lowerCAmelCase_							:			Tuple=4			,    lowerCAmelCase_							:			Tuple=4			,    lowerCAmelCase_							:			str=37			,    lowerCAmelCase_							:			Tuple="gelu"			,    lowerCAmelCase_							:			List[Any]=0.1			,    lowerCAmelCase_							:			List[Any]=0.1			,    lowerCAmelCase_							:			Union[str, Any]=512			,    lowerCAmelCase_							:			Tuple=0.02			,    )      ->		Union[str, Any]:
						__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							:			Optional[int]	)      ->		Dict:
						__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							:			str	)      ->		Dict:
						__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							:			Dict			,    lowerCAmelCase_							:			List[Any]			,    lowerCAmelCase_							:			Any			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			Optional[int]	)      ->		Optional[Any]:
						__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_							:			Dict			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			str			,    lowerCAmelCase_							:			str	)      ->		Dict:
						__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   ):





			'''simple docstring'''

			A						:				List[Any]					      =			(FlaxGPTJModel, FlaxGPTJForCausalLM) if is_flax_available() else ()
			A						:				List[str]					      =			(FlaxGPTJForCausalLM,) if is_flax_available() else ()
			def 					lowerCAmelCase     (  self							:			str	)      ->		Any:
						__A=	FlaxGPTJModelTester(self	)
			def 					lowerCAmelCase     (  self							:			Optional[int]	)      ->		Tuple:
						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							:			Tuple	)      ->		Any:
						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							:			List[str]	)      ->		str:
						__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							:			Dict	)      ->		Dict:
						__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							:			str	)      ->		Tuple:
						__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							:			Union[str, Any]	)      ->		Optional[int]:
						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'''





from __future__ import annotations

import unittest

from transformers import DistilBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
					import tensorflow as tf

					from transformers.models.distilbert.modeling_tf_distilbert import (
					    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
					    TFDistilBertForMaskedLM,
					    TFDistilBertForMultipleChoice,
					    TFDistilBertForQuestionAnswering,
					    TFDistilBertForSequenceClassification,
					    TFDistilBertForTokenClassification,
					    TFDistilBertModel,
					)
class 						a__					:





			'''simple docstring'''

			def __init__(  self							:			str			,    lowerCAmelCase_							:			str			,    )      ->		Optional[int]:
						__A=	parent
						__A=	13
						__A=	7
						__A=	True
						__A=	True
						__A=	False
						__A=	True
						__A=	99
						__A=	32
						__A=	2
						__A=	4
						__A=	37
						__A=	'gelu'
						__A=	0.1
						__A=	0.1
						__A=	512
						__A=	16
						__A=	2
						__A=	0.02
						__A=	3
						__A=	4
						__A=	None
			def 					lowerCAmelCase     (  self							:			Optional[Any]	)      ->		str:
						__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=	None
						__A=	None
						__A=	None
						if self.use_labels:
									__A=	ids_tensor([self.batch_size]			,    self.type_sequence_label_size	)
									__A=	ids_tensor([self.batch_size, self.seq_length]			,    self.num_labels	)
									__A=	ids_tensor([self.batch_size]			,    self.num_choices	)

						__A=	DistilBertConfig(
						    vocab_size=self.vocab_size			,    dim=self.hidden_size			,    n_layers=self.num_hidden_layers			,    n_heads=self.num_attention_heads			,    hidden_dim=self.intermediate_size			,    hidden_act=self.hidden_act			,    dropout=self.hidden_dropout_prob			,    attention_dropout=self.attention_probs_dropout_prob			,    max_position_embeddings=self.max_position_embeddings			,    initializer_range=self.initializer_range			,    )

						return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels
			def 					lowerCAmelCase     (  self							:			str			,    lowerCAmelCase_							:			Any			,    lowerCAmelCase_							:			int			,    lowerCAmelCase_							:			int			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			Any			,    lowerCAmelCase_							:			Optional[Any]	)      ->		Any:
						__A=	TFDistilBertModel(config=lowerCAmelCase_	)
						__A=	{'input_ids': input_ids, 'attention_mask': input_mask}

						__A=	model(lowerCAmelCase_	)

						__A=	[input_ids, input_mask]

						__A=	model(lowerCAmelCase_	)

						self.parent.assertEqual(result.last_hidden_state.shape			,    (self.batch_size, self.seq_length, self.hidden_size)	)
			def 					lowerCAmelCase     (  self							:			Optional[int]			,    lowerCAmelCase_							:			Optional[Any]			,    lowerCAmelCase_							:			List[Any]			,    lowerCAmelCase_							:			str			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			Tuple	)      ->		Optional[int]:
						__A=	TFDistilBertForMaskedLM(config=lowerCAmelCase_	)
						__A=	{'input_ids': input_ids, 'attention_mask': input_mask}
						__A=	model(lowerCAmelCase_	)
						self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.seq_length, self.vocab_size)	)
			def 					lowerCAmelCase     (  self							:			str			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			Optional[Any]			,    lowerCAmelCase_							:			Tuple			,    lowerCAmelCase_							:			str			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			List[str]	)      ->		int:
						__A=	TFDistilBertForQuestionAnswering(config=lowerCAmelCase_	)
						__A=	{
						    'input_ids': input_ids,
						    'attention_mask': input_mask,
						}
						__A=	model(lowerCAmelCase_	)
						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 					lowerCAmelCase     (  self							:			List[str]			,    lowerCAmelCase_							:			Any			,    lowerCAmelCase_							:			Optional[int]			,    lowerCAmelCase_							:			Tuple			,    lowerCAmelCase_							:			int			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			List[str]	)      ->		Union[str, Any]:
						__A=	self.num_labels
						__A=	TFDistilBertForSequenceClassification(lowerCAmelCase_	)
						__A=	{'input_ids': input_ids, 'attention_mask': input_mask}
						__A=	model(lowerCAmelCase_	)
						self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.num_labels)	)
			def 					lowerCAmelCase     (  self							:			str			,    lowerCAmelCase_							:			Any			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			List[Any]			,    lowerCAmelCase_							:			str			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			int	)      ->		Optional[Any]:
						__A=	self.num_choices
						__A=	TFDistilBertForMultipleChoice(lowerCAmelCase_	)
						__A=	tf.tile(tf.expand_dims(lowerCAmelCase_			,    1	)			,    (1, self.num_choices, 1)	)
						__A=	tf.tile(tf.expand_dims(lowerCAmelCase_			,    1	)			,    (1, self.num_choices, 1)	)
						__A=	{
						    'input_ids': multiple_choice_inputs_ids,
						    'attention_mask': multiple_choice_input_mask,
						}
						__A=	model(lowerCAmelCase_	)
						self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.num_choices)	)
			def 					lowerCAmelCase     (  self							:			List[Any]			,    lowerCAmelCase_							:			Optional[Any]			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			Union[str, Any]			,    lowerCAmelCase_							:			Optional[int]			,    lowerCAmelCase_							:			List[str]			,    lowerCAmelCase_							:			Optional[Any]	)      ->		Dict:
						__A=	self.num_labels
						__A=	TFDistilBertForTokenClassification(lowerCAmelCase_	)
						__A=	{'input_ids': input_ids, 'attention_mask': input_mask}
						__A=	model(lowerCAmelCase_	)
						self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.seq_length, self.num_labels)	)

			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		int:
						__A=	self.prepare_config_and_inputs()
						((__A),	(__A),	(__A),	(__A),	(__A),	(__A))=	config_and_inputs
						__A=	{'input_ids': input_ids, 'attention_mask': input_mask}
						return config, inputs_dict


@require_tf
class 						a__					(					a_      ,  a_      ,  unittest.TestCase   ):





			'''simple docstring'''

			A						:				Optional[Any]					      =			(
			    (
			        TFDistilBertModel,
			        TFDistilBertForMaskedLM,
			        TFDistilBertForQuestionAnswering,
			        TFDistilBertForSequenceClassification,
			        TFDistilBertForTokenClassification,
			        TFDistilBertForMultipleChoice,
			    )
			    if is_tf_available()
			    else None
			)
			A						:				Optional[int]					      =			(
			    {
			        '''feature-extraction''': TFDistilBertModel,
			        '''fill-mask''': TFDistilBertForMaskedLM,
			        '''question-answering''': TFDistilBertForQuestionAnswering,
			        '''text-classification''': TFDistilBertForSequenceClassification,
			        '''token-classification''': TFDistilBertForTokenClassification,
			        '''zero-shot''': TFDistilBertForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			A						:				str					      =			False
			A						:				List[Any]					      =			False
			def 					lowerCAmelCase     (  self							:			List[str]	)      ->		Optional[Any]:
						__A=	TFDistilBertModelTester(self	)
						__A=	ConfigTester(self			,    config_class=lowerCAmelCase_			,    dim=37	)
			def 					lowerCAmelCase     (  self							:			Dict	)      ->		Tuple:
						self.config_tester.run_common_tests()
			def 					lowerCAmelCase     (  self							:			Union[str, Any]	)      ->		Optional[int]:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_model(*lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			Optional[int]	)      ->		Optional[Any]:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_masked_lm(*lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			str	)      ->		Any:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_question_answering(*lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			Tuple	)      ->		Optional[Any]:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_sequence_classification(*lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			Optional[Any]	)      ->		Optional[Any]:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_multiple_choice(*lowerCAmelCase_	)
			def 					lowerCAmelCase     (  self							:			Any	)      ->		Optional[int]:
						__A=	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_token_classification(*lowerCAmelCase_	)

			@slow
			def 					lowerCAmelCase     (  self							:			int	)      ->		Tuple:
						for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]	):
									__A=	TFDistilBertModel.from_pretrained(lowerCAmelCase_	)
									self.assertIsNotNone(lowerCAmelCase_	)


@require_tf
class 						a__					(					unittest.TestCase   ):





			'''simple docstring'''

			@slow
			def 					lowerCAmelCase     (  self							:			Any	)      ->		List[Any]:
						__A=	TFDistilBertModel.from_pretrained('distilbert-base-uncased'	)
						__A=	tf.constant([[0, 1, 2, 3, 4, 5]]	)
						__A=	model(lowerCAmelCase_	)[0]

						__A=	[1, 6, 768]
						self.assertEqual(output.shape			,    lowerCAmelCase_	)

						__A=	tf.constant(
						    [
						        [
						            [0.19_26_18_85, -0.13_73_29_55, 0.4_11_97_99],
						            [0.22_15_01_56, -0.07_42_26_61, 0.39_03_72_04],
						            [0.22_75_60_18, -0.0_89_64_14, 0.3_70_14_67],
						        ]
						    ]	)
						tf.debugging.assert_near(output[:, :3, :3]			,    lowerCAmelCase_			,    atol=1E-4	)



