





'''simple docstring'''




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


__UpperCAmelCase         =   logging.get_logger(__name__)

__UpperCAmelCase         =   {
    """apple/mobilevitv2-1.0""": """https://huggingface.co/apple/mobilevitv2-1.0/resolve/main/config.json""",
}




class       UpperCamelCase__			(			lowercase_	):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__						=					'''mobilevitv2'''


					def __init__(		self							:	Union[str, Any]     ,		lowerCamelCase_							:	Union[str, Any]=3     ,		lowerCamelCase_							:	str=2_56     ,		lowerCamelCase_							:	List[str]=2     ,		lowerCamelCase_							:	str=2.0     ,		lowerCamelCase_							:	List[Any]="swish"     ,		lowerCamelCase_							:	Any=3     ,		lowerCamelCase_							:	Any=32     ,		lowerCamelCase_							:	Optional[Any]=0.1     ,		lowerCamelCase_							:	List[Any]=0.02     ,		lowerCamelCase_							:	Dict=1e-5     ,		lowerCamelCase_							:	Dict=5_12     ,		lowerCamelCase_							:	Any=[6, 12, 18]     ,		lowerCamelCase_							:	str=0.1     ,		lowerCamelCase_							:	Optional[Any]=2_55     ,		lowerCamelCase_							:	Optional[int]=[2, 4, 3]     ,		lowerCamelCase_							:	Optional[Any]=[1_28, 1_92, 2_56]     ,		lowerCamelCase_							:	Dict=1.0     ,		lowerCamelCase_							:	str=2     ,		lowerCamelCase_							:	int=0.0     ,		lowerCamelCase_							:	str=0.0     ,		**lowerCamelCase_							:	int     ,		):

							'''simple docstring'''



							super().__init__(**lowerCamelCase_		)

							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	num_channels
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	image_size
							SCREAMING_SNAKE_CASE				:							List[str]						=	patch_size
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	expand_ratio
							SCREAMING_SNAKE_CASE				:							List[str]						=	hidden_act
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	conv_kernel_size
							SCREAMING_SNAKE_CASE				:							Dict						=	output_stride
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	initializer_range
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	layer_norm_eps
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	n_attn_blocks
							SCREAMING_SNAKE_CASE				:							int						=	base_attn_unit_dims
							SCREAMING_SNAKE_CASE				:							int						=	width_multiplier
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	ffn_multiplier
							SCREAMING_SNAKE_CASE				:							Tuple						=	ffn_dropout
							SCREAMING_SNAKE_CASE				:							Any						=	attn_dropout
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	classifier_dropout_prob

							# decode head attributes for semantic segmentation
							SCREAMING_SNAKE_CASE				:							int						=	aspp_out_channels
							SCREAMING_SNAKE_CASE				:							List[Any]						=	atrous_rates
							SCREAMING_SNAKE_CASE				:							int						=	aspp_dropout_prob
							SCREAMING_SNAKE_CASE				:							str						=	semantic_loss_ignore_index







class       UpperCamelCase__			(			lowercase_	):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__						=					version.parse('''1.11'''	)


					@property
					def lowerCamelCase_	(		self							:	List[str]		):

							'''simple docstring'''



							return OrderedDict([("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""})]		)


					@property
					def lowerCamelCase_	(		self							:	int		):

							'''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 lowerCamelCase_	(		self							:	str		):

							'''simple docstring'''



							return 1e-4










'''simple docstring'''




import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
							from PIL import Image




class       UpperCamelCase__			(			unittest.TestCase		,			lowercase_	):




					"""simple docstring"""


					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							int						=	load_tool("""image-captioning"""		)
							self.tool.setup()
							SCREAMING_SNAKE_CASE				:							str						=	load_tool("""image-captioning"""     ,		remote=lowerCamelCase_		)


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Optional[int]						=	self.tool(lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)


					def lowerCamelCase_	(		self							:	str		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	self.remote_tool(lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)


					def lowerCamelCase_	(		self							:	List[Any]		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							str						=	self.tool(image=lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)



					def lowerCamelCase_	(		self							:	Any		):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
							SCREAMING_SNAKE_CASE				:							Optional[Any]						=	self.remote_tool(image=lowerCamelCase_		)
							self.assertEqual(lowerCamelCase_     ,		"""two cats sleeping on a couch"""		)



