






"""simple docstring"""
from typing import Dict, Iterable, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


lowerCamelCase_							      = logging.get_logger(__name__)







class      UpperCamelCase_			(__A	):
	__magic_name__       =							['''pixel_values''']





	def __init__( self   :					Optional[int]      ,      lowerCAmelCase_   :					bool = True      ,      lowerCAmelCase_   :					Dict[str, int] = None      ,      lowerCAmelCase_   :					PILImageResampling = PILImageResampling.BICUBIC      ,      lowerCAmelCase_   :					bool = True      ,      lowerCAmelCase_   :					Dict[str, int] = None      ,      lowerCAmelCase_   :					bool = True      ,      lowerCAmelCase_   :					Union[int, float] = 1 / 255      ,      lowerCAmelCase_   :					bool = True      ,      lowerCAmelCase_   :					Optional[Union[float, Iterable[float]]] = IMAGENET_DEFAULT_MEAN      ,      lowerCAmelCase_   :					Optional[Union[float, Iterable[float]]] = IMAGENET_DEFAULT_STD      ,      **lowerCAmelCase_   :					Union[str, Any]      ,      )		->     None:
				super().__init__(**lowerCAmelCase_		)
				UpperCAmelCase_	:					Any     	=   size if size is not None else {"shortest_edge": 224}
				UpperCAmelCase_	:					List[Any]     	=   get_size_dict(lowerCAmelCase_      ,      default_to_square=lowerCAmelCase_		)
				UpperCAmelCase_	:					Optional[int]     	=   crop_size if crop_size is not None else {"height": 224, "width": 224}
				UpperCAmelCase_	:					Optional[Any]     	=   get_size_dict(lowerCAmelCase_      ,      param_name="crop_size"		)

				UpperCAmelCase_	:					Union[str, Any]     	=   do_resize
				UpperCAmelCase_	:					List[str]     	=   size
				UpperCAmelCase_	:					int     	=   resample
				UpperCAmelCase_	:					Optional[int]     	=   do_center_crop
				UpperCAmelCase_	:					Optional[Any]     	=   crop_size
				UpperCAmelCase_	:					Optional[int]     	=   do_rescale
				UpperCAmelCase_	:					Tuple     	=   rescale_factor
				UpperCAmelCase_	:					List[Any]     	=   do_normalize
				UpperCAmelCase_	:					Dict     	=   image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
				UpperCAmelCase_	:					int     	=   image_std if image_std is not None else IMAGENET_DEFAULT_STD





	def 	_SCREAMING_SNAKE_CASE ( self   :					List[str]      ,      lowerCAmelCase_   :					np.ndarray      ,      lowerCAmelCase_   :					Dict[str, int]      ,      lowerCAmelCase_   :					PILImageResampling = PILImageResampling.BICUBIC      ,      lowerCAmelCase_   :					Optional[Union[str, ChannelDimension]] = None      ,      **lowerCAmelCase_   :					str      ,      )		->     np.ndarray:
				UpperCAmelCase_	:					List[Any]     	=   get_size_dict(lowerCAmelCase_      ,      default_to_square=lowerCAmelCase_		)
				# size_dict is a dict with either keys "height" and "width" or "shortest_edge"
				if "shortest_edge" in size:
							UpperCAmelCase_	:					List[Any]     	=   int((256 / 224) * size["shortest_edge"]		)
							UpperCAmelCase_	:					List[Any]     	=   get_resize_output_image_size(lowerCAmelCase_      ,      size=lowerCAmelCase_      ,      default_to_square=lowerCAmelCase_		)
							UpperCAmelCase_	:					str     	=   {"height": output_size[0], "width": output_size[1]}
				if "height" not in size_dict or "width" not in size_dict:
							raise ValueError(
							    f"""Size dict must have keys 'height' and 'width' or 'shortest_edge'. Got {size_dict.keys()}"""		)
				return resize(
				    lowerCAmelCase_      ,      size=(size_dict["height"], size_dict["width"])      ,      resample=lowerCAmelCase_      ,      data_format=lowerCAmelCase_      ,      **lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					List[Any]      ,      lowerCAmelCase_   :					np.ndarray      ,      lowerCAmelCase_   :					Dict[str, int]      ,      lowerCAmelCase_   :					Optional[Union[str, ChannelDimension]] = None      ,      **lowerCAmelCase_   :					List[str]      ,      )		->     np.ndarray:
				UpperCAmelCase_	:					Union[str, Any]     	=   get_size_dict(lowerCAmelCase_		)
				if "height" not in size or "width" not in size:
							raise ValueError(f"""Size dict must have keys 'height' and 'width'. Got {size.keys()}"""		)
				return center_crop(lowerCAmelCase_      ,      size=(size["height"], size["width"])      ,      data_format=lowerCAmelCase_      ,      **lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Optional[Any]      ,      lowerCAmelCase_   :					np.ndarray      ,      lowerCAmelCase_   :					Union[int, float]      ,      lowerCAmelCase_   :					Optional[Union[str, ChannelDimension]] = None      ,      **lowerCAmelCase_   :					str      ,      )		->     np.ndarray:
				return rescale(lowerCAmelCase_      ,      scale=lowerCAmelCase_      ,      data_format=lowerCAmelCase_      ,      **lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Union[str, Any]      ,      lowerCAmelCase_   :					np.ndarray      ,      lowerCAmelCase_   :					Union[float, List[float]]      ,      lowerCAmelCase_   :					Union[float, List[float]]      ,      lowerCAmelCase_   :					Optional[Union[str, ChannelDimension]] = None      ,      **lowerCAmelCase_   :					Optional[int]      ,      )		->     np.ndarray:
				return normalize(lowerCAmelCase_      ,      mean=lowerCAmelCase_      ,      std=lowerCAmelCase_      ,      data_format=lowerCAmelCase_      ,      **lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					int      ,      lowerCAmelCase_   :					ImageInput      ,      lowerCAmelCase_   :					Optional[bool] = None      ,      lowerCAmelCase_   :					Optional[Dict[str, int]] = None      ,      lowerCAmelCase_   :					PILImageResampling = None      ,      lowerCAmelCase_   :					Optional[bool] = None      ,      lowerCAmelCase_   :					Optional[Dict[str, int]] = None      ,      lowerCAmelCase_   :					Optional[bool] = None      ,      lowerCAmelCase_   :					Optional[float] = None      ,      lowerCAmelCase_   :					Optional[bool] = None      ,      lowerCAmelCase_   :					Optional[Union[float, Iterable[float]]] = None      ,      lowerCAmelCase_   :					Optional[Union[float, Iterable[float]]] = None      ,      lowerCAmelCase_   :					Optional[TensorType] = None      ,      lowerCAmelCase_   :					ChannelDimension = ChannelDimension.FIRST      ,      **lowerCAmelCase_   :					Any      ,      )		->     BatchFeature:
				UpperCAmelCase_	:					Optional[Any]     	=   do_resize if do_resize is not None else self.do_resize
				UpperCAmelCase_	:					int     	=   resample if resample is not None else self.resample
				UpperCAmelCase_	:					Dict     	=   do_center_crop if do_center_crop is not None else self.do_center_crop
				UpperCAmelCase_	:					Dict     	=   do_rescale if do_rescale is not None else self.do_rescale
				UpperCAmelCase_	:					Optional[Any]     	=   rescale_factor if rescale_factor is not None else self.rescale_factor
				UpperCAmelCase_	:					List[str]     	=   do_normalize if do_normalize is not None else self.do_normalize
				UpperCAmelCase_	:					Optional[Any]     	=   image_mean if image_mean is not None else self.image_mean
				UpperCAmelCase_	:					int     	=   image_std if image_std is not None else self.image_std

				UpperCAmelCase_	:					Optional[Any]     	=   size if size is not None else self.size
				UpperCAmelCase_	:					List[Any]     	=   get_size_dict(lowerCAmelCase_      ,      default_to_square=lowerCAmelCase_		)
				UpperCAmelCase_	:					int     	=   crop_size if crop_size is not None else self.crop_size
				UpperCAmelCase_	:					Dict     	=   get_size_dict(lowerCAmelCase_      ,      param_name="crop_size"		)

				UpperCAmelCase_	:					Optional[Any]     	=   make_list_of_images(lowerCAmelCase_		)

				if not valid_images(lowerCAmelCase_		):
							raise ValueError(
							    "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
							    "torch.Tensor, tf.Tensor or jax.ndarray."		)

				if do_resize and size is None:
							raise ValueError("Size must be specified if do_resize is True."		)

				if do_center_crop and crop_size is None:
							raise ValueError("Crop size must be specified if do_center_crop is True."		)

				if do_rescale and rescale_factor is None:
							raise ValueError("Rescale factor must be specified if do_rescale is True."		)

				if do_normalize and (image_mean is None or image_std is None):
							raise ValueError("Image mean and std must be specified if do_normalize is True."		)

				# All transformations expect numpy arrays.
				UpperCAmelCase_	:					Union[str, Any]     	=   [to_numpy_array(lowerCAmelCase_		) for image in images]

				if do_resize:
							UpperCAmelCase_	:					Any     	=   [self.resize(lowerCAmelCase_      ,      lowerCAmelCase_      ,      lowerCAmelCase_		) for image in images]

				if do_center_crop:
							UpperCAmelCase_	:					str     	=   [self.center_crop(lowerCAmelCase_      ,      lowerCAmelCase_		) for image in images]

				if do_rescale:
							UpperCAmelCase_	:					Dict     	=   [self.rescale(lowerCAmelCase_      ,      lowerCAmelCase_		) for image in images]

				if do_normalize:
							UpperCAmelCase_	:					Dict     	=   [self.normalize(lowerCAmelCase_      ,      lowerCAmelCase_      ,      lowerCAmelCase_		) for image in images]

				UpperCAmelCase_	:					List[str]     	=   [to_channel_dimension_format(lowerCAmelCase_      ,      lowerCAmelCase_		) for image in images]

				UpperCAmelCase_	:					Optional[int]     	=   {"pixel_values": images}
				return BatchFeature(data=lowerCAmelCase_      ,      tensor_type=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      UpperCamelCase_			:





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





	def 	_SCREAMING_SNAKE_CASE ( self   :					int		)		->     List[str]:
				UpperCAmelCase_	:					Tuple     	=   ids_tensor([self.batch_size, self.seq_length]      ,      self.vocab_size		)

				UpperCAmelCase_	:					Optional[Any]     	=   None
				if self.use_input_mask:
							UpperCAmelCase_	:					Optional[int]     	=   random_attention_mask([self.batch_size, self.seq_length]		)

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

				UpperCAmelCase_	:					Dict     	=   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 	_SCREAMING_SNAKE_CASE ( self   :					Optional[Any]      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					List[Any]      ,      lowerCAmelCase_   :					List[Any]      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					Any		)		->     str:
				UpperCAmelCase_	:					Optional[Any]     	=   TFDistilBertModel(config=lowerCAmelCase_		)
				UpperCAmelCase_	:					Any     	=   {"input_ids": input_ids, "attention_mask": input_mask}

				UpperCAmelCase_	:					str     	=   model(lowerCAmelCase_		)

				UpperCAmelCase_	:					List[Any]     	=   [input_ids, input_mask]

				UpperCAmelCase_	:					Optional[int]     	=   model(lowerCAmelCase_		)

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





	def 	_SCREAMING_SNAKE_CASE ( self   :					Tuple      ,      lowerCAmelCase_   :					Optional[Any]      ,      lowerCAmelCase_   :					Optional[int]      ,      lowerCAmelCase_   :					Dict      ,      lowerCAmelCase_   :					Optional[Any]      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					Union[str, Any]		)		->     List[str]:
				UpperCAmelCase_	:					Dict     	=   TFDistilBertForMaskedLM(config=lowerCAmelCase_		)
				UpperCAmelCase_	:					int     	=   {"input_ids": input_ids, "attention_mask": input_mask}
				UpperCAmelCase_	:					List[str]     	=   model(lowerCAmelCase_		)
				self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.seq_length, self.vocab_size)		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Union[str, Any]      ,      lowerCAmelCase_   :					int      ,      lowerCAmelCase_   :					List[str]      ,      lowerCAmelCase_   :					Dict      ,      lowerCAmelCase_   :					int      ,      lowerCAmelCase_   :					List[Any]      ,      lowerCAmelCase_   :					Dict		)		->     Dict:
				UpperCAmelCase_	:					Optional[Any]     	=   TFDistilBertForQuestionAnswering(config=lowerCAmelCase_		)
				UpperCAmelCase_	:					List[Any]     	=   {
				    "input_ids": input_ids,
				    "attention_mask": input_mask,
				}
				UpperCAmelCase_	:					Any     	=   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 	_SCREAMING_SNAKE_CASE ( self   :					int      ,      lowerCAmelCase_   :					Optional[int]      ,      lowerCAmelCase_   :					Optional[int]      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					List[Any]      ,      lowerCAmelCase_   :					Dict      ,      lowerCAmelCase_   :					Optional[Any]		)		->     Optional[int]:
				UpperCAmelCase_	:					List[Any]     	=   self.num_labels
				UpperCAmelCase_	:					Tuple     	=   TFDistilBertForSequenceClassification(lowerCAmelCase_		)
				UpperCAmelCase_	:					int     	=   {"input_ids": input_ids, "attention_mask": input_mask}
				UpperCAmelCase_	:					Optional[Any]     	=   model(lowerCAmelCase_		)
				self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.num_labels)		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Optional[int]      ,      lowerCAmelCase_   :					str      ,      lowerCAmelCase_   :					Optional[int]      ,      lowerCAmelCase_   :					Optional[Any]      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					Union[str, Any]		)		->     Optional[Any]:
				UpperCAmelCase_	:					Union[str, Any]     	=   self.num_choices
				UpperCAmelCase_	:					List[Any]     	=   TFDistilBertForMultipleChoice(lowerCAmelCase_		)
				UpperCAmelCase_	:					List[Any]     	=   tf.tile(tf.expand_dims(lowerCAmelCase_      ,      1		)      ,      (1, self.num_choices, 1)		)
				UpperCAmelCase_	:					List[Any]     	=   tf.tile(tf.expand_dims(lowerCAmelCase_      ,      1		)      ,      (1, self.num_choices, 1)		)
				UpperCAmelCase_	:					Any     	=   {
				    "input_ids": multiple_choice_inputs_ids,
				    "attention_mask": multiple_choice_input_mask,
				}
				UpperCAmelCase_	:					List[Any]     	=   model(lowerCAmelCase_		)
				self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.num_choices)		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Tuple      ,      lowerCAmelCase_   :					Union[str, Any]      ,      lowerCAmelCase_   :					Tuple      ,      lowerCAmelCase_   :					List[Any]      ,      lowerCAmelCase_   :					Any      ,      lowerCAmelCase_   :					Union[str, Any]      ,      lowerCAmelCase_   :					Union[str, Any]		)		->     Tuple:
				UpperCAmelCase_	:					Union[str, Any]     	=   self.num_labels
				UpperCAmelCase_	:					List[str]     	=   TFDistilBertForTokenClassification(lowerCAmelCase_		)
				UpperCAmelCase_	:					int     	=   {"input_ids": input_ids, "attention_mask": input_mask}
				UpperCAmelCase_	:					Optional[Any]     	=   model(lowerCAmelCase_		)
				self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.seq_length, self.num_labels)		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Any		)		->     Dict:
				UpperCAmelCase_	:					Optional[int]     	=   self.prepare_config_and_inputs()
				((UpperCAmelCase_)	,      (UpperCAmelCase_)	,      (UpperCAmelCase_)	,      (UpperCAmelCase_)	,      (UpperCAmelCase_)	,      (UpperCAmelCase_))	:					str     	=   config_and_inputs
				UpperCAmelCase_	:					List[str]     	=   {"input_ids": input_ids, "attention_mask": input_mask}
				return config, inputs_dict







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





	def 	_SCREAMING_SNAKE_CASE ( self   :					List[str]		)		->     Tuple:
				UpperCAmelCase_	:					Any     	=   TFDistilBertModelTester(self		)
				UpperCAmelCase_	:					List[str]     	=   ConfigTester(self      ,      config_class=lowerCAmelCase_      ,      dim=37		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Optional[Any]		)		->     Optional[int]:
				self.config_tester.run_common_tests()





	def 	_SCREAMING_SNAKE_CASE ( self   :					List[str]		)		->     int:
				UpperCAmelCase_	:					str     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_model(*lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					int		)		->     Union[str, Any]:
				UpperCAmelCase_	:					List[Any]     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_for_masked_lm(*lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					int		)		->     Optional[Any]:
				UpperCAmelCase_	:					str     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_for_question_answering(*lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Any		)		->     Union[str, Any]:
				UpperCAmelCase_	:					Optional[Any]     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_for_sequence_classification(*lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					Union[str, Any]		)		->     int:
				UpperCAmelCase_	:					Optional[Any]     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_for_multiple_choice(*lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					List[str]		)		->     Tuple:
				UpperCAmelCase_	:					str     	=   self.model_tester.prepare_config_and_inputs()
				self.model_tester.create_and_check_distilbert_for_token_classification(*lowerCAmelCase_		)





	@slow
	def 	_SCREAMING_SNAKE_CASE ( self   :					List[Any]		)		->     Dict:
				for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]		):
							UpperCAmelCase_	:					Tuple     	=   TFDistilBertModel.from_pretrained(lowerCAmelCase_		)
							self.assertIsNotNone(lowerCAmelCase_		)







@require_tf
class      UpperCamelCase_			(unittest.TestCase	):





	@slow
	def 	_SCREAMING_SNAKE_CASE ( self   :					Dict		)		->     Optional[int]:
				UpperCAmelCase_	:					Optional[int]     	=   TFDistilBertModel.from_pretrained("distilbert-base-uncased"		)
				UpperCAmelCase_	:					Tuple     	=   tf.constant([[0, 1, 2, 3, 4, 5]]		)
				UpperCAmelCase_	:					Dict     	=   model(lowerCAmelCase_		)[0]

				UpperCAmelCase_	:					Union[str, Any]     	=   [1, 6, 768]
				self.assertEqual(output.shape      ,      lowerCAmelCase_		)

				UpperCAmelCase_	:					Dict     	=   tf.constant(
				    [
				        [
				            [0.1_9_2_6_1_8_8_5, -0.1_3_7_3_2_9_5_5, 0.4_1_1_9_7_9_9],
				            [0.2_2_1_5_0_1_5_6, -0.0_7_4_2_2_6_6_1, 0.3_9_0_3_7_2_0_4],
				            [0.2_2_7_5_6_0_1_8, -0.0_8_9_6_4_1_4, 0.3_7_0_1_4_6_7],
				        ]
				    ]		)
				tf.debugging.assert_near(output[:, :3, :3]      ,      lowerCAmelCase_      ,      atol=1e-4		)



