code: 
  
  
  from __future__ import annotations
  
  import inspect
  import unittest
  
  from transformers import MobileViTConfig
  from transformers.file_utils import is_tf_available, is_vision_available
  from transformers.testing_utils import require_tf, slow
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_tf_available():
  		import numpy as np
  		import tensorflow as tf
  
  		from transformers import TFMobileViTForImageClassification, TFMobileViTForSemanticSegmentation, TFMobileViTModel
  		from transformers.models.mobilevit.modeling_tf_mobilevit import TF_MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST
  
  
  if is_vision_available():
  		from PIL import Image
  
  		from transformers import MobileViTImageProcessor
  
  
  
  class 			a      (      UpperCamelCase_   ):
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			str:
  						'''simple docstring'''
  
  
  						A__     :							List[str]   				=self.config_class(**self.inputs_dict							)
  						self.parent.assertTrue(hasattr(__UpperCamelCase	,     '''hidden_sizes'''							)							)
  						self.parent.assertTrue(hasattr(__UpperCamelCase	,     '''neck_hidden_sizes'''							)							)
  						self.parent.assertTrue(hasattr(__UpperCamelCase	,     '''num_attention_heads'''							)							)
  
  
  
  
  
  
  
  class 			a      :
  
  
  
  
  
  
  		def __init__(  self	,     __UpperCamelCase	,     __UpperCamelCase=13	,     __UpperCamelCase=32	,     __UpperCamelCase=2	,     __UpperCamelCase=3	,     __UpperCamelCase=6_40	,     __UpperCamelCase=4	,     __UpperCamelCase="silu"	,     __UpperCamelCase=3	,     __UpperCamelCase=32	,     __UpperCamelCase=0.1	,     __UpperCamelCase=0.1	,     __UpperCamelCase=0.1	,     __UpperCamelCase=0.02	,     __UpperCamelCase=True	,     __UpperCamelCase=True	,     __UpperCamelCase=10	,     __UpperCamelCase=None	,     )->			Optional[Any]:
  						'''simple docstring'''
  
  
  						A__     :							Tuple   				=parent
  						A__     :							Dict   				=batch_size
  						A__     :							Any   				=image_size
  						A__     :							str   				=patch_size
  						A__     :							Union[str, Any]   				=num_channels
  						A__     :							Optional[int]   				=last_hidden_size
  						A__     :							Optional[Any]   				=num_attention_heads
  						A__     :							Any   				=hidden_act
  						A__     :							List[str]   				=conv_kernel_size
  						A__     :							str   				=output_stride
  						A__     :							List[Any]   				=hidden_dropout_prob
  						A__     :							Any   				=attention_probs_dropout_prob
  						A__     :							List[Any]   				=classifier_dropout_prob
  						A__     :							int   				=use_labels
  						A__     :							Optional[Any]   				=is_training
  						A__     :							Union[str, Any]   				=num_labels
  						A__     :							Tuple   				=initializer_range
  						A__     :							Optional[Any]   				=scope
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Optional[Any]:
  						'''simple docstring'''
  
  
  						A__     :							Dict   				=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)
  
  						A__     :							int   				=None
  						A__     :							Optional[Any]   				=None
  						if self.use_labels:
  										A__     :							int   				=ids_tensor([self.batch_size]	,     self.num_labels							)
  										A__     :							Tuple   				=ids_tensor([self.batch_size, self.image_size, self.image_size]	,     self.num_labels							)
  
  						A__     :							Optional[int]   				=self.get_config()
  
  						return config, pixel_values, labels, pixel_labels
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Dict:
  						'''simple docstring'''
  
  
  						return MobileViTConfig(
  						    image_size=self.image_size	,     patch_size=self.patch_size	,     num_channels=self.num_channels	,     num_attention_heads=self.num_attention_heads	,     hidden_act=self.hidden_act	,     conv_kernel_size=self.conv_kernel_size	,     output_stride=self.output_stride	,     hidden_dropout_prob=self.hidden_dropout_prob	,     attention_probs_dropout_prob=self.attention_probs_dropout_prob	,     classifier_dropout_prob=self.classifier_dropout_prob	,     initializer_range=self.initializer_range	,     )
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							)->			Union[str, Any]:
  						'''simple docstring'''
  
  
  						A__     :							str   				=TFMobileViTModel(config=__UpperCamelCase							)
  						A__     :							List[str]   				=model(__UpperCamelCase	,     training=__UpperCamelCase							)
  						A__     :							Tuple   				=self.image_size // self.output_stride
  						self.parent.assertEqual(
  						    result.last_hidden_state.shape	,     (self.batch_size, self.last_hidden_size, expected_height, expected_width)							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							)->			Any:
  						'''simple docstring'''
  
  
  						A__     :							List[str]   				=self.num_labels
  						A__     :							List[Any]   				=TFMobileViTForImageClassification(__UpperCamelCase							)
  						A__     :							Optional[Any]   				=model(__UpperCamelCase	,     labels=__UpperCamelCase	,     training=__UpperCamelCase							)
  						self.parent.assertEqual(result.logits.shape	,     (self.batch_size, self.num_labels)							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							)->			Optional[Any]:
  						'''simple docstring'''
  
  
  						A__     :							Tuple   				=self.num_labels
  						A__     :							Tuple   				=TFMobileViTForSemanticSegmentation(__UpperCamelCase							)
  						A__     :							List[Any]   				=self.image_size // self.output_stride
  
  						A__     :							Any   				=model(__UpperCamelCase	,     training=__UpperCamelCase							)
  						self.parent.assertEqual(
  						    result.logits.shape	,     (self.batch_size, self.num_labels, expected_height, expected_width)							)
  
  						A__     :							Dict   				=model(__UpperCamelCase	,     labels=__UpperCamelCase	,     training=__UpperCamelCase							)
  						self.parent.assertEqual(
  						    result.logits.shape	,     (self.batch_size, self.num_labels, expected_height, expected_width)							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Dict:
  						'''simple docstring'''
  
  
  						A__     :							str   				=self.prepare_config_and_inputs()
  						A__     :							Dict   				=config_and_inputs
  						A__     :							List[str]   				={'''pixel_values''': pixel_values}
  						return config, inputs_dict
  
  
  
  
  
  
  
  @require_tf
  class 			a      (      UpperCamelCase_      ,UpperCamelCase_      ,unittest.TestCase   ):
  		__lowercase													=		(
  		    (TFMobileViTModel, TFMobileViTForImageClassification, TFMobileViTForSemanticSegmentation)
  		    if is_tf_available()
  		    else ()
  		)
  		__lowercase													=		(
  		    {"""feature-extraction""": TFMobileViTModel, """image-classification""": TFMobileViTForImageClassification}
  		    if is_tf_available()
  		    else {}
  		)
  
  		__lowercase													=		False
  		__lowercase													=		False
  		__lowercase													=		False
  		__lowercase													=		False
  		__lowercase													=		False
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			str:
  						'''simple docstring'''
  
  
  						A__     :							Optional[int]   				=TFMobileViTModelTester(self							)
  						A__     :							Union[str, Any]   				=TFMobileViTConfigTester(self	,     config_class=__UpperCamelCase	,     has_text_modality=__UpperCamelCase							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			List[str]:
  						'''simple docstring'''
  
  
  						self.config_tester.run_common_tests()
  
  
  
  
  
  
  		@unittest.skip(reason='''MobileViT does not use inputs_embeds'''							)
  		def       lowerCAmelCase_  (  self							)->			List[str]:
  						'''simple docstring'''
  
  
  						pass
  
  
  
  
  
  
  		@unittest.skip(reason='''MobileViT does not support input and output embeddings'''							)
  		def       lowerCAmelCase_  (  self							)->			Optional[Any]:
  						'''simple docstring'''
  
  
  						pass
  
  
  
  
  
  
  		@unittest.skip(reason='''MobileViT does not output attentions'''							)
  		def       lowerCAmelCase_  (  self							)->			Tuple:
  						'''simple docstring'''
  
  
  						pass
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Any:
  						'''simple docstring'''
  
  
  						A__     :							Tuple   				=self.model_tester.prepare_config_and_inputs_for_common()
  
  						for model_class in self.all_model_classes:
  										A__     :							Union[str, Any]   				=model_class(__UpperCamelCase							)
  										A__     :							List[Any]   				=inspect.signature(model.call							)
  										# signature.parameters is an OrderedDict => so arg_names order is deterministic
  										A__     :							Optional[int]   				=[*signature.parameters.keys()]
  
  										A__     :							Union[str, Any]   				=['''pixel_values''']
  										self.assertListEqual(arg_names[:1]	,     __UpperCamelCase							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Union[str, Any]:
  						'''simple docstring'''
  
  
  						A__     :							str   				=self.model_tester.prepare_config_and_inputs()
  						self.model_tester.create_and_check_model(*__UpperCamelCase							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Optional[Any]:
  						'''simple docstring'''
  
  
  						def check_hidden_states_output(__UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							):
  										A__     :							Optional[Any]   				=model_class(__UpperCamelCase							)
  
  										A__     :							Union[str, Any]   				=model(**self._prepare_for_class(__UpperCamelCase	,     __UpperCamelCase							)							)
  
  										A__     :							Tuple   				=outputs.hidden_states
  
  										A__     :							Optional[Any]   				=5
  										self.assertEqual(len(__UpperCamelCase							)	,     __UpperCamelCase							)
  
  										# MobileViT's feature maps are of shape (batch_size, num_channels, height, width)
  										# with the width and height being successively divided by 2.
  										A__     :							Tuple   				=2
  										for i in range(len(__UpperCamelCase							)							):
  														self.assertListEqual(
  														    list(hidden_states[i].shape[-2:]							)	,     [self.model_tester.image_size // divisor, self.model_tester.image_size // divisor]	,     )
  														divisor *= 2
  
  										self.assertEqual(self.model_tester.output_stride	,     divisor // 2							)
  
  						A__     :							List[Any]   				=self.model_tester.prepare_config_and_inputs_for_common()
  
  						for model_class in self.all_model_classes:
  										A__     :							List[Any]   				=True
  										check_hidden_states_output(__UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							)
  
  										# check that output_hidden_states also work using config
  										del inputs_dict["output_hidden_states"]
  										A__     :							List[str]   				=True
  
  										check_hidden_states_output(__UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Union[str, Any]:
  						'''simple docstring'''
  
  
  						A__     :							Any   				=self.model_tester.prepare_config_and_inputs()
  						self.model_tester.create_and_check_for_image_classification(*__UpperCamelCase							)
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			List[Any]:
  						'''simple docstring'''
  
  
  						A__     :							List[Any]   				=self.model_tester.prepare_config_and_inputs()
  						self.model_tester.create_and_check_for_semantic_segmentation(*__UpperCamelCase							)
  
  
  
  
  
  
  		@unittest.skipIf(
  		    not is_tf_available() or len(tf.config.list_physical_devices('''GPU'''							)							) == 0	,     reason='''TF does not support backprop for grouped convolutions on CPU.'''	,     )
  		def       lowerCAmelCase_  (  self							)->			List[str]:
  						'''simple docstring'''
  
  
  						super().test_dataset_conversion()
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self	,     __UpperCamelCase	,     __UpperCamelCase	,     __UpperCamelCase=2E-1	,     __UpperCamelCase=2E-1							)->			List[str]:
  						'''simple docstring'''
  
  
  						self.assertTrue(np.allclose(__UpperCamelCase	,     __UpperCamelCase	,     atol=__UpperCamelCase	,     rtol=__UpperCamelCase							)							)
  
  
  
  
  
  
  		@unittest.skipIf(
  		    not is_tf_available() or len(tf.config.list_physical_devices('''GPU'''							)							) == 0	,     reason='''TF does not support backprop for grouped convolutions on CPU.'''	,     )
  		@slow
  		def       lowerCAmelCase_  (  self							)->			Tuple:
  						'''simple docstring'''
  
  
  						A__     :							str   				=self.model_tester.prepare_config_and_inputs_for_common()
  
  						for model_class in self.all_model_classes:
  										# Since `TFMobileViTModel` cannot operate with the default `fit()` method.
  										if model_class.__name__ != "TFMobileViTModel":
  														A__     :							Optional[Any]   				=model_class(__UpperCamelCase							)
  														if getattr(__UpperCamelCase	,     '''hf_compute_loss'''	,     __UpperCamelCase							):
  																		super().test_keras_fit()
  
  
  
  
  
  
  		def       lowerCAmelCase_  (  self							)->			Optional[int]:
  						'''simple docstring'''
  
  
  						A__     :							str   				=self.model_tester.prepare_config_and_inputs_for_common()
  						for model_class in self.all_model_classes:
  										# set an ignore index to correctly test the masked loss used in
  										# `TFMobileViTForSemanticSegmentation`.
  										if model_class.__name__ != "TFMobileViTForSemanticSegmentation":
  														A__     :							List[str]   				=5
  
  										A__     :							Tuple   				=model_class(__UpperCamelCase							)
  										if getattr(__UpperCamelCase	,     '''hf_compute_loss'''	,     __UpperCamelCase							):
  														# The number of elements in the loss should be the same as the number of elements in the label
  														A__     :							Any   				=self._prepare_for_class(inputs_dict.copy()	,     __UpperCamelCase	,     return_labels=__UpperCamelCase							)
  														A__     :							Optional[Any]   				=prepared_for_class[
  														    sorted(prepared_for_class.keys() - inputs_dict.keys()	,     reverse=__UpperCamelCase							)[0]
  														]
  														A__     :							Union[str, Any]   				=added_label.shape.as_list()[:1]
  
  														# Test that model correctly compute the loss with kwargs
  														A__     :							Dict   				=self._prepare_for_class(inputs_dict.copy()	,     __UpperCamelCase	,     return_labels=__UpperCamelCase							)
  														A__     :							str   				={'''input_ids''', '''pixel_values''', '''input_features'''}
  														A__     :							str   				=possible_input_names.intersection(set(__UpperCamelCase							)							).pop()
  														A__     :							Union[str, Any]   				=prepared_for_class.pop(__UpperCamelCase							)
  
  														A__     :							Any   				=model(__UpperCamelCase	,     **__UpperCamelCase							)[0]
  														self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]							)
  
  														# Test that model correctly compute the loss when we mask some positions
  														A__     :							Tuple   				=self._prepare_for_class(inputs_dict.copy()	,     __UpperCamelCase	,     return_labels=__UpperCamelCase							)
  														A__     :							int   				={'''input_ids''', '''pixel_values''', '''input_features'''}
  														A__     :							Tuple   				=possible_input_names.intersection(set(__UpperCamelCase							)							).pop()
  														A__     :							Optional[int]   				=prepared_for_class.pop(__UpperCamelCase							)
  														if "labels" in prepared_for_class:
  																		A__     :							Dict   				=prepared_for_class['''labels'''].numpy()
  																		if len(labels.shape							) > 1 and labels.shape[1] != 1:
  																						# labels[0] = -100
  																						A__     :							Any   				=tf.convert_to_tensor(__UpperCamelCase							)
  																						A__     :							Optional[Any]   				=model(__UpperCamelCase	,     **__UpperCamelCase							)[0]
  																						self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]							)
  																						self.assertTrue(not np.any(np.isnan(loss.numpy()							)							)							)
  
                  # Test that model correctly compute the loss with a dict
  														A__     :							List[Any]   				=self._prepare_for_class(inputs_dict.copy()	,     __UpperCamelCase	,     return_labels=__UpperCamelCase							)
  														A__     :							List[str]   				=model(__UpperCamelCase							)[0]
  														self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]							)
  
  														# Test that model correctly compute the loss with a tuple
  														A__     :							str   				=self._prepare_for_class(inputs_dict.copy()	,     __UpperCamelCase	,     return_labels=__UpperCamelCase							)
  
  														# Get keys that were added with the _prepare_for_class function
  														A__     :							Optional[Any]   				=prepared_for_class.keys() - inputs_dict.keys()
  														A__     :							Union[str, Any]   				=inspect.signature(model.call							).parameters
  														A__     :							Dict   				=list(signature.keys()							)
  
  														# Create a dictionary holding the location of the tensors in the tuple
  														A__     :							Optional[int]   				={0: input_name}
  														for label_key in label_keys:
  																		A__     :							Optional[int]   				=signature_names.index(__UpperCamelCase							)
  																		A__     :							Optional[Any]   				=label_key
  														A__     :							int   				=sorted(tuple_index_mapping.items()							)
  														# Initialize a list with their default values, update the values and convert to a tuple
  														A__     :							Any   				=[]
  
  														for name in signature_names:
  																		if name != "kwargs":
  																						list_input.append(signature[name].default							)
  
  														for index, value in sorted_tuple_index_mapping:
  																		A__     :							Tuple   				=prepared_for_class[value]
  
  														A__     :							List[str]   				=tuple(__UpperCamelCase							)
  
  														# Send to model
  														A__     :							Optional[int]   				=model(tuple_input[:-1]							)[0]
  
  														self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]							)
  
  
  
  
  
  
  		@slow
  		def       lowerCAmelCase_  (  self							)->			Any:
  						'''simple docstring'''
  
  
  						for model_name in TF_MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  										A__     :							List[str]   				=TFMobileViTModel.from_pretrained(__UpperCamelCase							)
  										self.assertIsNotNone(__UpperCamelCase							)
  
  
  
  
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							)			->							Optional[int]:
  				A__     :							Dict   				=Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''	)
  				return image
  
  
  
  
  @require_tf
  class 			a      (      unittest.TestCase   ):
  
  
  
  
  
  
  		@slow
  		def       lowerCAmelCase_  (  self							)->			List[Any]:
  						'''simple docstring'''
  
  
  						A__     :							Union[str, Any]   				=TFMobileViTForImageClassification.from_pretrained('''apple/mobilevit-xx-small'''							)
  
  						A__     :							Dict   				=MobileViTImageProcessor.from_pretrained('''apple/mobilevit-xx-small'''							)
  						A__     :							List[Any]   				=prepare_img()
  						A__     :							List[str]   				=image_processor(images=__UpperCamelCase	,     return_tensors='''tf'''							)
  
  						# forward pass
  						A__     :							Any   				=model(**__UpperCamelCase	,     training=__UpperCamelCase							)
  
  						# verify the logits
  						A__     :							Dict   				=tf.TensorShape((1, 10_00)							)
  						self.assertEqual(outputs.logits.shape	,     __UpperCamelCase							)
  
  						A__     :							List[str]   				=tf.constant([-1.9364, -1.2327, -0.4653]							)
  
  						tf.debugging.assert_near(outputs.logits[0, :3]	,     __UpperCamelCase	,     atol=1E-4	,     rtol=1E-04							)
  
  
  
  
  
  
  		@slow
  		def       lowerCAmelCase_  (  self							)->			int:
  						'''simple docstring'''
  
  
  						A__     :							Tuple   				=TFMobileViTForSemanticSegmentation.from_pretrained('''apple/deeplabv3-mobilevit-xx-small'''							)
  
  						A__     :							Union[str, Any]   				=MobileViTImageProcessor.from_pretrained('''apple/deeplabv3-mobilevit-xx-small'''							)
  
  						A__     :							List[str]   				=prepare_img()
  						A__     :							str   				=image_processor(images=__UpperCamelCase	,     return_tensors='''tf'''							)
  
  						# forward pass
  						A__     :							Any   				=model(inputs.pixel_values	,     training=__UpperCamelCase							)
  						A__     :							Optional[int]   				=outputs.logits
  
  						# verify the logits
  						A__     :							List[Any]   				=tf.TensorShape((1, 21, 32, 32)							)
  						self.assertEqual(logits.shape	,     __UpperCamelCase							)
  
  						A__     :							Tuple   				=tf.constant(
  						    [
  						        [[6.9713, 6.9786, 7.2422], [7.2893, 7.2825, 7.4446], [7.6580, 7.8797, 7.9420]],
  						        [[-10.6869, -10.3250, -10.3471], [-10.4228, -9.9868, -9.7132], [-11.0405, -11.0221, -10.7318]],
  						        [[-3.3089, -2.8539, -2.6740], [-3.2706, -2.5621, -2.5108], [-3.2534, -2.6615, -2.6651]],
  						    ]							)
  
  						tf.debugging.assert_near(logits[0, :3, :3, :3]	,     __UpperCamelCase	,     rtol=1E-4	,     atol=1E-4							)
  
  
  
  
style_context: 
  
  
  import argparse
  import copy
  import json
  import multiprocessing
  import os
  import time
  
  from create_dummy_models import COMPOSITE_MODELS, create_tiny_models
  from huggingface_hub import ModelFilter, hf_api
  
  import transformers
  from transformers import AutoFeatureExtractor, AutoImageProcessor, AutoTokenizer
  from transformers.image_processing_utils import BaseImageProcessor
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							)			->							Tuple:
  				A__     :							List[Any]   				=set()
  				# Each auto modeling files contains multiple mappings. Let's get them in a dynamic way.
  				for module_name in ["modeling_auto", "modeling_tf_auto", "modeling_flax_auto"]:
  								A__     :							Optional[int]   				=getattr(transformers.models.auto,	snake_case_,	snake_case_	)
  								if module is None:
  												continue
  								# all mappings in a single auto modeling file
  								A__     :							Optional[int]   				=[
  								    x
  								    for x in dir(snake_case_	)
  								    if x.endswith('''_MAPPING_NAMES'''	)
  								    and (x.startswith('''MODEL_'''	) or x.startswith('''TF_MODEL_'''	) or x.startswith('''FLAX_MODEL_'''	))
  								]
  								for name in mapping_names:
  												A__     :							Any   				=getattr(snake_case_,	snake_case_	)
  												if mapping is not None:
  																for v in mapping.values():
  																				if isinstance(snake_case_,	(list, tuple)	):
  																								model_names.update(snake_case_	)
  																				elif isinstance(snake_case_,	snake_case_	):
  																								model_names.add(snake_case_	)
  
  				return sorted(snake_case_	)
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							)			->							Optional[Any]:
  				# All model names defined in auto mappings
  				A__     :							int   				=set(get_all_model_names()	)
  
  				with open('''tests/utils/tiny_model_summary.json'''	) as fp:
  								A__     :							Union[str, Any]   				=json.load(snake_case_	)
  				A__     :							int   				=set()
  				for model_base_name in tiny_model_info:
  								tiny_models_names.update(tiny_model_info[model_base_name]['''model_classes''']	)
  
  				# Remove a tiny model name if one of its framework implementation hasn't yet a tiny version on the Hub.
  				A__     :							Optional[Any]   				=model_names.difference(snake_case_	)
  				for model_name in copy.copy(snake_case_	):
  								if not model_name.startswith('''TF'''	) and f'TF{model_name}' in not_on_hub:
  												tiny_models_names.remove(snake_case_	)
  								elif model_name.startswith('''TF'''	) and model_name[2:] in not_on_hub:
  												tiny_models_names.remove(snake_case_	)
  
  				return sorted(snake_case_	)
  
  
  
  def   SCREAMING_SNAKE_CASE__						(							snake_case_	)			->							Tuple:
  				A__     :							Dict   				=COMPOSITE_MODELS.values()
  
  				# All tiny model base names on Hub
  				A__     :							Union[str, Any]   				=get_all_model_names()
  				A__     :							Optional[Any]   				=hf_api.list_models(
  				    filter=ModelFilter(
  				        author='''hf-internal-testing''',	)	)
  				A__     :							str   				=set()
  				for x in models:
  								A__     :							List[Any]   				=x.modelId
  								A__				,  A__     :							List[str]   				=model.split('''/'''	)
  								if not model.startswith('''tiny-random-'''	):
  												continue
  								A__     :							str   				=model.replace('''tiny-random-''',	''''''	)
  								if not model[0].isupper():
  												continue
  								if model not in model_names and model not in special_models:
  												continue
  								_models.add(snake_case_	)
  
  				A__     :							Dict   				=sorted(_models	)
  				# All tiny model names on Hub
  				A__     :							Optional[int]   				={}
  				for model in models:
  								A__     :							Optional[int]   				=f'hf-internal-testing/tiny-random-{model}'
  								A__     :							str   				=model.split('''-'''	)[0]
  								try:
  												A__     :							int   				=hf_api.repo_info(snake_case_	)
  												A__     :							Optional[int]   				={
  												    '''tokenizer_classes''': set(),
  												    '''processor_classes''': set(),
  												    '''model_classes''': set(),
  												    '''sha''': repo_info.sha,
  												}
  								except Exception:
  												continue
  								try:
  												time.sleep(1	)
  												A__     :							List[str]   				=AutoTokenizer.from_pretrained(snake_case_	)
  												content["tokenizer_classes"].add(tokenizer_fast.__class__.__name__	)
  								except Exception:
  												pass
  								try:
  												time.sleep(1	)
  												A__     :							int   				=AutoTokenizer.from_pretrained(snake_case_,	use_fast=snake_case_	)
  												content["tokenizer_classes"].add(tokenizer_slow.__class__.__name__	)
  								except Exception:
  												pass
  								try:
  												time.sleep(1	)
  												A__     :							int   				=AutoImageProcessor.from_pretrained(snake_case_	)
  												content["processor_classes"].add(img_p.__class__.__name__	)
  								except Exception:
  												pass
  								try:
  												time.sleep(1	)
  												A__     :							Optional[int]   				=AutoFeatureExtractor.from_pretrained(snake_case_	)
  												if not isinstance(snake_case_,	snake_case_	):
  																content["processor_classes"].add(feat_p.__class__.__name__	)
  								except Exception:
  												pass
  								try:
  												time.sleep(1	)
  												A__     :							Tuple   				=getattr(snake_case_,	snake_case_	)
  												A__     :							Tuple   				=model_class.from_pretrained(snake_case_	)
  												content["model_classes"].add(m.__class__.__name__	)
  								except Exception:
  												pass
  								try:
  												time.sleep(1	)
  												A__     :							int   				=getattr(snake_case_,	f'TF{model}'	)
  												A__     :							Union[str, Any]   				=model_class.from_pretrained(snake_case_	)
  												content["model_classes"].add(m.__class__.__name__	)
  								except Exception:
  												pass
  
  								A__     :							List[str]   				=sorted(content['''tokenizer_classes''']	)
  								A__     :							Tuple   				=sorted(content['''processor_classes''']	)
  								A__     :							Optional[Any]   				=sorted(content['''model_classes''']	)
  
  								A__     :							List[Any]   				=content
  								with open(os.path.join(snake_case_,	'''hub_tiny_model_summary.json'''	),	'''w'''	) as fp:
  												json.dump(snake_case_,	snake_case_,	ensure_ascii=snake_case_,	indent=4	)
  
  
  if __name__ == "__main__":
  						__lowerCamelCase       :       Any				   =			argparse.ArgumentParser()
  						parser.add_argument("--num_workers", default=1, type=int, help="The number of workers to run.")
  						__lowerCamelCase       :       int				   =			parser.parse_args()
  
  						# This has to be `spawn` to avoid hanging forever!
  						multiprocessing.set_start_method("spawn")
  
  						__lowerCamelCase       :       Any				   =			"tiny_models"
  						__lowerCamelCase       :       Optional[int]				   =			True
  						__lowerCamelCase       :       int				   =			None
  						__lowerCamelCase       :       str				   =			get_tiny_model_names_from_repo()
  						__lowerCamelCase       :       List[Any]				   =			True
  						__lowerCamelCase       :       List[Any]				   =			True
  						__lowerCamelCase       :       Optional[Any]				   =			"hf-internal-testing"
  
  						create_tiny_models(
  						    output_path,
  						    all,
  						    model_types,
  						    models_to_skip,
  						    no_check,
  						    upload,
  						    organization,
  						    token=os.environ.get("TOKEN", None),
  						    num_workers=args.num_workers,
  						)
  
  
  
  