code: 
  
  
  import unittest
  
  import numpy as np
  
  from transformers.testing_utils import require_torch, require_vision
  from transformers.utils import is_torch_available, is_vision_available
  
  from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs
  
  
  if is_torch_available():
  	import torch
  
  if is_vision_available():
  	from PIL import Image
  
  	from transformers import OwlViTImageProcessor
  
  
  
  
  
  class 					snake_case__  ( unittest.TestCase       ):
  
  
  
  
  
  	def __init__(  self				,    UpperCamelCase_				,    UpperCamelCase_=7				,    UpperCamelCase_=3				,    UpperCamelCase_=18				,    UpperCamelCase_=30				,    UpperCamelCase_=400				,    UpperCamelCase_=True				,    UpperCamelCase_=None				,    UpperCamelCase_=True				,    UpperCamelCase_=None				,    UpperCamelCase_=True				,    UpperCamelCase_=[0.4814_5466, 0.457_8275, 0.4082_1073]				,    UpperCamelCase_=[0.2686_2954, 0.2613_0258, 0.2757_7711]				,    UpperCamelCase_=True				,    )		->			List[str]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Tuple			=	parent
  								a_       :   Tuple			=	batch_size
  								a_       :   Tuple			=	num_channels
  								a_       :   int			=	image_size
  								a_       :   str			=	min_resolution
  								a_       :   Optional[int]			=	max_resolution
  								a_       :   Dict			=	do_resize
  								a_       :   Union[str, Any]			=	size if size is not None else {"""height""": 18, """width""": 18}
  								a_       :   Any			=	do_center_crop
  								a_       :   List[str]			=	crop_size if crop_size is not None else {"""height""": 18, """width""": 18}
  								a_       :   Dict			=	do_normalize
  								a_       :   List[str]			=	image_mean
  								a_       :   List[str]			=	image_std
  								a_       :   List[str]			=	do_convert_rgb
  
  
  
  
  
  	def     A				(  self							)		->			Optional[Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								return {
  								    "do_resize": self.do_resize,
  								    "size": self.size,
  								    "do_center_crop": self.do_center_crop,
  								    "crop_size": self.crop_size,
  								    "do_normalize": self.do_normalize,
  								    "image_mean": self.image_mean,
  								    "image_std": self.image_std,
  								    "do_convert_rgb": self.do_convert_rgb,
  								}
  
  
  
  
  
  @require_torch
  @require_vision
  class 					snake_case__  ( __A      ,    unittest.TestCase       ):
  	UpperCAmelCase   :							List[str]         = OwlViTImageProcessor if is_vision_available() else None
  
  
  
  
  
  	def     A				(  self							)		->			str:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Any			=	OwlViTImageProcessingTester(self							)
  
  
  
  
  
  	@property
  	def     A				(  self							)		->			int:
  								"""simple docstring"""
  
  
  
  
  
  
  								return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  	def     A				(  self							)		->			str:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Tuple			=	self.image_processing_class(**self.image_processor_dict							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """do_resize"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """size"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """do_center_crop"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """center_crop"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """do_normalize"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """image_mean"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """image_std"""							)							)
  								self.assertTrue(hasattr(UpperCamelCase_				,    """do_convert_rgb"""							)							)
  
  
  
  
  
  	def     A				(  self							)		->			Optional[Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Dict			=	self.image_processing_class.from_dict(self.image_processor_dict							)
  								self.assertEqual(image_processor.size				,    {"""height""": 18, """width""": 18}							)
  								self.assertEqual(image_processor.crop_size				,    {"""height""": 18, """width""": 18}							)
  
  								a_       :   str			=	self.image_processing_class.from_dict(self.image_processor_dict				,    size=42				,    crop_size=84							)
  								self.assertEqual(image_processor.size				,    {"""height""": 42, """width""": 42}							)
  								self.assertEqual(image_processor.crop_size				,    {"""height""": 84, """width""": 84}							)
  
  
  
  
  
  	def     A				(  self							)		->			List[str]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Any			=	self.image_processing_class(**self.image_processor_dict							)
  								# create random PIL images
  								a_       :   Dict			=	prepare_image_inputs(self.image_processor_tester				,    equal_resolution=UpperCamelCase_							)
  
  								for image in image_inputs:
  															self.assertIsInstance(UpperCamelCase_				,    Image.Image							)
  
  								# Test not batched input
  								a_       :   List[str]			=	image_processing(image_inputs[0]				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        1,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  								# Test batched
  								a_       :   int			=	image_processing(UpperCamelCase_				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        self.image_processor_tester.batch_size,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  
  
  
  
  	def     A				(  self							)		->			Union[str, Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   List[Any]			=	self.image_processing_class(**self.image_processor_dict							)
  								# create random numpy tensors
  								a_       :   Dict			=	prepare_image_inputs(self.image_processor_tester				,    equal_resolution=UpperCamelCase_				,    numpify=UpperCamelCase_							)
  								for image in image_inputs:
  															self.assertIsInstance(UpperCamelCase_				,    np.ndarray							)
  
  								# Test not batched input
  								a_       :   List[str]			=	image_processing(image_inputs[0]				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        1,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  								# Test batched
  								a_       :   Optional[int]			=	image_processing(UpperCamelCase_				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        self.image_processor_tester.batch_size,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  
  
  
  
  	def     A				(  self							)		->			Dict:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Dict			=	self.image_processing_class(**self.image_processor_dict							)
  								# create random PyTorch tensors
  								a_       :   Union[str, Any]			=	prepare_image_inputs(self.image_processor_tester				,    equal_resolution=UpperCamelCase_				,    torchify=UpperCamelCase_							)
  								for image in image_inputs:
  															self.assertIsInstance(UpperCamelCase_				,    torch.Tensor							)
  
  								# Test not batched input
  								a_       :   Optional[int]			=	image_processing(image_inputs[0]				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        1,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  								# Test batched
  								a_       :   Union[str, Any]			=	image_processing(UpperCamelCase_				,    return_tensors="""pt"""							).pixel_values
  								self.assertEqual(
  								    encoded_images.shape				,    (
  								        self.image_processor_tester.batch_size,
  								        self.image_processor_tester.num_channels,
  								        self.image_processor_tester.crop_size["""height"""],
  								        self.image_processor_tester.crop_size["""width"""],
  								    )				,    )
  
  
  
style_context: 
  
  
  from collections import OrderedDict
  from typing import Mapping
  
  from packaging import version
  
  from ...configuration_utils import PretrainedConfig
  from ...onnx import OnnxConfig
  from ...utils import logging
  
  
  SCREAMING_SNAKE_CASE : Dict          =    logging.get_logger(__name__)
  
  SCREAMING_SNAKE_CASE : str          =    {
      "apple/mobilevit-small": "https://huggingface.co/apple/mobilevit-small/resolve/main/config.json",
      "apple/mobilevit-x-small": "https://huggingface.co/apple/mobilevit-x-small/resolve/main/config.json",
      "apple/mobilevit-xx-small": "https://huggingface.co/apple/mobilevit-xx-small/resolve/main/config.json",
      "apple/deeplabv3-mobilevit-small": (
          "https://huggingface.co/apple/deeplabv3-mobilevit-small/resolve/main/config.json"
      ),
      "apple/deeplabv3-mobilevit-x-small": (
          "https://huggingface.co/apple/deeplabv3-mobilevit-x-small/resolve/main/config.json"
      ),
      "apple/deeplabv3-mobilevit-xx-small": (
          "https://huggingface.co/apple/deeplabv3-mobilevit-xx-small/resolve/main/config.json"
      ),
      # See all MobileViT models at https://huggingface.co/models?filter=mobilevit
  }
  
  
  
  
  
  class 					snake_case__  ( __A       ):
  	UpperCAmelCase   :							List[str]         = """mobilevit"""
  
  
  
  
  
  	def __init__(  self				,    UpperCamelCase_=3				,    UpperCamelCase_=256				,    UpperCamelCase_=2				,    UpperCamelCase_=[144, 192, 240]				,    UpperCamelCase_=[16, 32, 64, 96, 128, 160, 640]				,    UpperCamelCase_=4				,    UpperCamelCase_=2.0				,    UpperCamelCase_=4.0				,    UpperCamelCase_="silu"				,    UpperCamelCase_=3				,    UpperCamelCase_=32				,    UpperCamelCase_=0.1				,    UpperCamelCase_=0.0				,    UpperCamelCase_=0.1				,    UpperCamelCase_=0.02				,    UpperCamelCase_=1e-5				,    UpperCamelCase_=True				,    UpperCamelCase_=256				,    UpperCamelCase_=[6, 12, 18]				,    UpperCamelCase_=0.1				,    UpperCamelCase_=255				,    **UpperCamelCase_				,    )		->			str:
  								"""simple docstring"""
  
  
  
  
  
  
  								super().__init__(**UpperCamelCase_							)
  
  								a_       :   Optional[int]			=	num_channels
  								a_       :   Optional[Any]			=	image_size
  								a_       :   int			=	patch_size
  								a_       :   List[str]			=	hidden_sizes
  								a_       :   Optional[int]			=	neck_hidden_sizes
  								a_       :   List[Any]			=	num_attention_heads
  								a_       :   Union[str, Any]			=	mlp_ratio
  								a_       :   List[str]			=	expand_ratio
  								a_       :   str			=	hidden_act
  								a_       :   Union[str, Any]			=	conv_kernel_size
  								a_       :   Optional[Any]			=	output_stride
  								a_       :   Union[str, Any]			=	hidden_dropout_prob
  								a_       :   List[Any]			=	attention_probs_dropout_prob
  								a_       :   List[Any]			=	classifier_dropout_prob
  								a_       :   Union[str, Any]			=	initializer_range
  								a_       :   List[Any]			=	layer_norm_eps
  								a_       :   str			=	qkv_bias
  
  								# decode head attributes for semantic segmentation
  								a_       :   Optional[Any]			=	aspp_out_channels
  								a_       :   Any			=	atrous_rates
  								a_       :   Union[str, Any]			=	aspp_dropout_prob
  								a_       :   Any			=	semantic_loss_ignore_index
  
  
  
  
  
  class 					snake_case__  ( __A       ):
  	UpperCAmelCase   :							Optional[int]         = version.parse("""1.11"""       )
  
  
  
  
  
  	@property
  	def     A				(  self							)		->			Mapping[str, Mapping[int, str]]:
  								"""simple docstring"""
  
  
  
  
  
  
  								return OrderedDict([("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""})]							)
  
  
  
  
  
  	@property
  	def     A				(  self							)		->			Mapping[str, Mapping[int, str]]:
  								"""simple docstring"""
  
  
  
  
  
  
  								if self.task == "image-classification":
  															return OrderedDict([("""logits""", {0: """batch"""})]							)
  								else:
  															return OrderedDict([("""last_hidden_state""", {0: """batch"""}), ("""pooler_output""", {0: """batch"""})]							)
  
  
  
  
  
  	@property
  	def     A				(  self							)		->			float:
  								"""simple docstring"""
  
  
  
  
  
  
  								return 1e-4
  
  
  