





import argparse
import json
from collections import OrderedDict

import torch
from huggingface_hub import cached_download, hf_hub_url

from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification







def    A				(							UpperCAmelCase				):
					_snake_case       :					Tuple				       =   []
					embed.append(
					    (
					        F"""cvt.encoder.stages.{idx}.embedding.convolution_embeddings.projection.weight""",
					        F"""stage{idx}.patch_embed.proj.weight""",
					    )				)
					embed.append(
					    (
					        F"""cvt.encoder.stages.{idx}.embedding.convolution_embeddings.projection.bias""",
					        F"""stage{idx}.patch_embed.proj.bias""",
					    )				)
					embed.append(
					    (
					        F"""cvt.encoder.stages.{idx}.embedding.convolution_embeddings.normalization.weight""",
					        F"""stage{idx}.patch_embed.norm.weight""",
					    )				)
					embed.append(
					    (
					        F"""cvt.encoder.stages.{idx}.embedding.convolution_embeddings.normalization.bias""",
					        F"""stage{idx}.patch_embed.norm.bias""",
					    )				)
					return embed







def    A				(							UpperCAmelCase  ,  UpperCAmelCase				):
					_snake_case       :					str				       =   []
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.convolution.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.conv.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.normalization.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.bn.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.normalization.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.bn.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.normalization.running_mean""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.bn.running_mean""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.normalization.running_var""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.bn.running_var""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_query.convolution_projection.normalization.num_batches_tracked""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_q.bn.num_batches_tracked""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.convolution.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.conv.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.normalization.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.bn.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.normalization.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.bn.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.normalization.running_mean""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.bn.running_mean""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.normalization.running_var""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.bn.running_var""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_key.convolution_projection.normalization.num_batches_tracked""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_k.bn.num_batches_tracked""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.convolution.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.conv.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.normalization.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.bn.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.normalization.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.bn.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.normalization.running_mean""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.bn.running_mean""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.normalization.running_var""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.bn.running_var""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.convolution_projection_value.convolution_projection.normalization.num_batches_tracked""",
					        F"""stage{idx}.blocks.{cnt}.attn.conv_proj_v.bn.num_batches_tracked""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_query.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_q.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_query.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_q.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_key.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_k.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_key.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_k.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_value.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_v.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.attention.projection_value.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj_v.bias""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.output.dense.weight""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj.weight""",
					    )				)
					attention_weights.append(
					    (
					        F"""cvt.encoder.stages.{idx}.layers.{cnt}.attention.output.dense.bias""",
					        F"""stage{idx}.blocks.{cnt}.attn.proj.bias""",
					    )				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.intermediate.dense.weight""", F"""stage{idx}.blocks.{cnt}.mlp.fc1.weight""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.intermediate.dense.bias""", F"""stage{idx}.blocks.{cnt}.mlp.fc1.bias""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.output.dense.weight""", F"""stage{idx}.blocks.{cnt}.mlp.fc2.weight""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.output.dense.bias""", F"""stage{idx}.blocks.{cnt}.mlp.fc2.bias""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.layernorm_before.weight""", F"""stage{idx}.blocks.{cnt}.norm1.weight""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.layernorm_before.bias""", F"""stage{idx}.blocks.{cnt}.norm1.bias""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.layernorm_after.weight""", F"""stage{idx}.blocks.{cnt}.norm2.weight""")				)
					attention_weights.append(
					    (F"""cvt.encoder.stages.{idx}.layers.{cnt}.layernorm_after.bias""", F"""stage{idx}.blocks.{cnt}.norm2.bias""")				)
					return attention_weights







def    A				(							UpperCAmelCase				):
					_snake_case       :					int				       =   []
					token.append((F"""cvt.encoder.stages.{idx}.cls_token""", "stage2.cls_token")				)
					return token







def    A				(							):
					_snake_case       :					str				       =   []
					head.append(("layernorm.weight", "norm.weight")				)
					head.append(("layernorm.bias", "norm.bias")				)
					head.append(("classifier.weight", "head.weight")				)
					head.append(("classifier.bias", "head.bias")				)
					return head







def    A				(							UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase				):
					_snake_case       :					Optional[int]				       =   "imagenet-1k-id2label.json"
					_snake_case       :					int				       =   1_000

					_snake_case       :					Union[str, Any]				       =   "huggingface/label-files"
					_snake_case       :					int				       =   num_labels
					_snake_case       :					List[Any]				       =   json.load(open(cached_download(hf_hub_url(UpperCAmelCase  ,  UpperCAmelCase  ,  repo_type="dataset"				)				)  ,  "r"				)				)
					_snake_case       :					Union[str, Any]				       =   {int(UpperCAmelCase				): v for k, v in idalabel.items()}

					_snake_case       :					Any				       =   idalabel
					_snake_case       :					str				       =   {v: k for k, v in idalabel.items()}

					_snake_case       :					str				       =   CvtConfig(num_labels=UpperCAmelCase  ,  idalabel=UpperCAmelCase  ,  labelaid=UpperCAmelCase				)

					# For depth size 13 (13 = 1+2+10)
					if cvt_model.rsplit("/"  ,  1				)[-1][4:6] == "13":
										_snake_case       :					str				       =   [1, 2, 10]

					# For depth size 21 (21 = 1+4+16)
					elif cvt_model.rsplit("/"  ,  1				)[-1][4:6] == "21":
										_snake_case       :					Any				       =   [1, 4, 16]

					# For wide cvt (similar to wide-resnet) depth size 24 (w24 = 2 + 2 20)
					else:
										_snake_case       :					int				       =   [2, 2, 20]
										_snake_case       :					str				       =   [3, 12, 16]
										_snake_case       :					Union[str, Any]				       =   [192, 768, 1_024]

					_snake_case       :					int				       =   CvtForImageClassification(UpperCAmelCase				)
					_snake_case       :					Tuple				       =   AutoImageProcessor.from_pretrained("facebook/convnext-base-224-22k-1k"				)
					_snake_case       :					int				       =   image_size
					_snake_case       :					List[str]				       =   torch.load(UpperCAmelCase  ,  map_location=torch.device("cpu"				)				)

					_snake_case       :					int				       =   OrderedDict()
					_snake_case       :					str				       =   []

					for idx in range(len(config.depth				)				):
										if config.cls_token[idx]:
															_snake_case       :					Tuple				       =   list_of_state_dict + cls_token(UpperCAmelCase				)
										_snake_case       :					str				       =   list_of_state_dict + embeddings(UpperCAmelCase				)
										for cnt in range(config.depth[idx]				):
															_snake_case       :					str				       =   list_of_state_dict + attention(UpperCAmelCase  ,  UpperCAmelCase				)

					_snake_case       :					Union[str, Any]				       =   list_of_state_dict + final()
					for gg in list_of_state_dict:
										print(UpperCAmelCase				)
					for i in range(len(UpperCAmelCase				)				):
										_snake_case       :					Optional[Any]				       =   original_weights[list_of_state_dict[i][1]]

					model.load_state_dict(UpperCAmelCase				)
					model.save_pretrained(UpperCAmelCase				)
					image_processor.save_pretrained(UpperCAmelCase				)


# Download the weights from zoo: https://1drv.ms/u/s!AhIXJn_J-blW9RzF3rMW7SsLHa8h?e=blQ0Al

if __name__ == "__main__":
							__lowerCAmelCase :Union[str, Any]     =    argparse.ArgumentParser()
							parser.add_argument(
							    '--cvt_model',
							    default='cvt-w24',
							    type=str,
							    help='Name of the cvt model you\'d like to convert.',
							)
							parser.add_argument(
							    '--image_size',
							    default=3_84,
							    type=int,
							    help='Input Image Size',
							)
							parser.add_argument(
							    '--cvt_file_name',
							    default=R'cvtmodels\CvT-w24-384x384-IN-22k.pth',
							    type=str,
							    help='Input Image Size',
							)
							parser.add_argument(
							    '--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model directory.'
							)

							__lowerCAmelCase :str     =    parser.parse_args()
							convert_cvt_checkpoint(args.cvt_model, args.image_size, args.cvt_file_name, args.pytorch_dump_folder_path)






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:







		def __init__(    self ,						__snake_case ,						)      ->      List[str]:


							'''simple docstring'''

							_snake_case       :					Dict				       =   parent
							_snake_case       :					Any				       =   1_3
							_snake_case       :					Union[str, Any]				       =   7
							_snake_case       :					Any				       =   True
							_snake_case       :					Optional[Any]				       =   True
							_snake_case       :					List[str]				       =   False
							_snake_case       :					str				       =   True
							_snake_case       :					int				       =   9_9
							_snake_case       :					Optional[int]				       =   3_2
							_snake_case       :					Dict				       =   2
							_snake_case       :					Optional[Any]				       =   4
							_snake_case       :					Any				       =   3_7
							_snake_case       :					Optional[int]				       =   "gelu"
							_snake_case       :					Optional[Any]				       =   0.1
							_snake_case       :					List[Any]				       =   0.1
							_snake_case       :					Any				       =   5_1_2
							_snake_case       :					Optional[int]				       =   1_6
							_snake_case       :					Dict				       =   2
							_snake_case       :					Optional[int]				       =   0.02
							_snake_case       :					Any				       =   3
							_snake_case       :					Tuple				       =   4
							_snake_case       :					str				       =   None







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


							'''simple docstring'''

							_snake_case       :					Optional[int]				       =   ids_tensor([self.batch_size, self.seq_length] ,						self.vocab_size				)

							_snake_case       :					List[Any]				       =   None
							if self.use_input_mask:
												_snake_case       :					Tuple				       =   random_attention_mask([self.batch_size, self.seq_length]				)

							_snake_case       :					str				       =   None
							_snake_case       :					Optional[Any]				       =   None
							_snake_case       :					Any				       =   None
							if self.use_labels:
												_snake_case       :					Union[str, Any]				       =   ids_tensor([self.batch_size] ,						self.type_sequence_label_size				)
												_snake_case       :					List[str]				       =   ids_tensor([self.batch_size, self.seq_length] ,						self.num_labels				)
												_snake_case       :					List[Any]				       =   ids_tensor([self.batch_size] ,						self.num_choices				)

							_snake_case       :					Optional[Any]				       =   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        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					str				       =   TFDistilBertModel(config=__snake_case				)
							_snake_case       :					Dict				       =   {"input_ids": input_ids, "attention_mask": input_mask}

							_snake_case       :					Union[str, Any]				       =   model(__snake_case				)

							_snake_case       :					Union[str, Any]				       =   [input_ids, input_mask]

							_snake_case       :					int				       =   model(__snake_case				)

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







		def        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      str:


							'''simple docstring'''

							_snake_case       :					str				       =   TFDistilBertForMaskedLM(config=__snake_case				)
							_snake_case       :					Optional[Any]				       =   {"input_ids": input_ids, "attention_mask": input_mask}
							_snake_case       :					Tuple				       =   model(__snake_case				)
							self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length, self.vocab_size)				)







		def        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      Union[str, Any]:


							'''simple docstring'''

							_snake_case       :					int				       =   TFDistilBertForQuestionAnswering(config=__snake_case				)
							_snake_case       :					Any				       =   {
							    "input_ids": input_ids,
							    "attention_mask": input_mask,
							}
							_snake_case       :					Tuple				       =   model(__snake_case				)
							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        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      str:


							'''simple docstring'''

							_snake_case       :					Dict				       =   self.num_labels
							_snake_case       :					Dict				       =   TFDistilBertForSequenceClassification(__snake_case				)
							_snake_case       :					Dict				       =   {"input_ids": input_ids, "attention_mask": input_mask}
							_snake_case       :					Optional[Any]				       =   model(__snake_case				)
							self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.num_labels)				)







		def        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      Dict:


							'''simple docstring'''

							_snake_case       :					str				       =   self.num_choices
							_snake_case       :					List[str]				       =   TFDistilBertForMultipleChoice(__snake_case				)
							_snake_case       :					Optional[int]				       =   tf.tile(tf.expand_dims(__snake_case ,						1				) ,						(1, self.num_choices, 1)				)
							_snake_case       :					int				       =   tf.tile(tf.expand_dims(__snake_case ,						1				) ,						(1, self.num_choices, 1)				)
							_snake_case       :					str				       =   {
							    "input_ids": multiple_choice_inputs_ids,
							    "attention_mask": multiple_choice_input_mask,
							}
							_snake_case       :					List[Any]				       =   model(__snake_case				)
							self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.num_choices)				)







		def        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case ,						__snake_case				)      ->      Dict:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   self.num_labels
							_snake_case       :					int				       =   TFDistilBertForTokenClassification(__snake_case				)
							_snake_case       :					Any				       =   {"input_ids": input_ids, "attention_mask": input_mask}
							_snake_case       :					Any				       =   model(__snake_case				)
							self.parent.assertEqual(result.logits.shape ,						(self.batch_size, self.seq_length, self.num_labels)				)







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   self.prepare_config_and_inputs()
							((_snake_case)       , (_snake_case)       , (_snake_case)       , (_snake_case)       , (_snake_case)       , (_snake_case))       :					List[str]				       =   config_and_inputs
							_snake_case       :					Optional[int]				       =   {"input_ids": input_ids, "attention_mask": input_mask}
							return config, inputs_dict






@require_tf
class        _a(    __A	,   __A	,   unittest.TestCase    ):
		lowerCamelCase__     :str   				=		(
		    (
		        TFDistilBertModel,
		        TFDistilBertForMaskedLM,
		        TFDistilBertForQuestionAnswering,
		        TFDistilBertForSequenceClassification,
		        TFDistilBertForTokenClassification,
		        TFDistilBertForMultipleChoice,
		    )
		    if is_tf_available()
		    else None
		)
		lowerCamelCase__     :Tuple   				=		(
		    {
		        'feature-extraction': TFDistilBertModel,
		        'fill-mask': TFDistilBertForMaskedLM,
		        'question-answering': TFDistilBertForQuestionAnswering,
		        'text-classification': TFDistilBertForSequenceClassification,
		        'token-classification': TFDistilBertForTokenClassification,
		        'zero-shot': TFDistilBertForSequenceClassification,
		    }
		    if is_tf_available()
		    else {}
		)
		lowerCamelCase__     :Tuple   				=		False
		lowerCamelCase__     :Any   				=		False







		def        lowercase       (    self				)      ->      int:


							'''simple docstring'''

							_snake_case       :					Optional[Any]				       =   TFDistilBertModelTester(self				)
							_snake_case       :					str				       =   ConfigTester(self ,						config_class=__snake_case ,						dim=3_7				)







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


							'''simple docstring'''

							self.config_tester.run_common_tests()







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


							'''simple docstring'''

							_snake_case       :					Dict				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_model(*__snake_case				)







		def        lowercase       (    self				)      ->      Any:


							'''simple docstring'''

							_snake_case       :					Any				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_masked_lm(*__snake_case				)







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


							'''simple docstring'''

							_snake_case       :					str				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_question_answering(*__snake_case				)







		def        lowercase       (    self				)      ->      Dict:


							'''simple docstring'''

							_snake_case       :					List[Any]				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_sequence_classification(*__snake_case				)







		def        lowercase       (    self				)      ->      Dict:


							'''simple docstring'''

							_snake_case       :					List[str]				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_multiple_choice(*__snake_case				)







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


							'''simple docstring'''

							_snake_case       :					Dict				       =   self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_token_classification(*__snake_case				)







		@slow
		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]				):
												_snake_case       :					Any				       =   TFDistilBertModel.from_pretrained(__snake_case				)
												self.assertIsNotNone(__snake_case				)






@require_tf
class        _a(    unittest.TestCase    ):







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


							'''simple docstring'''

							_snake_case       :					Any				       =   TFDistilBertModel.from_pretrained("distilbert-base-uncased"				)
							_snake_case       :					int				       =   tf.constant([[0, 1, 2, 3, 4, 5]]				)
							_snake_case       :					Dict				       =   model(__snake_case				)[0]

							_snake_case       :					str				       =   [1, 6, 7_6_8]
							self.assertEqual(output.shape ,						__snake_case				)

							_snake_case       :					Optional[Any]				       =   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] ,						__snake_case ,						atol=1E-4				)