

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
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCAmelCase							:  int   	=						logging.get_logger(__name__)

lowerCAmelCase							:  List[str]   	=						{
    """microsoft/resnet-50""": """https://huggingface.co/microsoft/resnet-50/blob/main/config.json""",
}



class   __lowercase				( UpperCAmelCase_		,       UpperCAmelCase_	):




			"""simple docstring"""







			_UpperCAmelCase   :							Optional[int]										=     '''resnet'''
			_UpperCAmelCase   :							Optional[Any]										=     ['''basic''', '''bottleneck''']



			def __init__( self  :     str   ,						lowerCAmelCase__  :     Any=3   ,						lowerCAmelCase__  :     Optional[int]=64   ,						lowerCAmelCase__  :     Dict=[256, 512, 1024, 2048]   ,						lowerCAmelCase__  :     List[str]=[3, 4, 6, 3]   ,						lowerCAmelCase__  :     Optional[Any]="bottleneck"   ,						lowerCAmelCase__  :     int="relu"   ,						lowerCAmelCase__  :     Optional[Any]=False   ,						lowerCAmelCase__  :     Dict=None   ,						lowerCAmelCase__  :     Optional[int]=None   ,						**lowerCAmelCase__  :     List[str]   ,						):
									super().__init__(**lowerCAmelCase__)
									if layer_type not in self.layer_types:
															raise ValueError(F"layer_type={layer_type} is not one of {','.join(self.layer_types)}")
									SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       num_channels
									SCREAMING_SNAKE_CASE_: Optional[int]  		=       embedding_size
									SCREAMING_SNAKE_CASE_: Dict  		=       hidden_sizes
									SCREAMING_SNAKE_CASE_: List[Any]  		=       depths
									SCREAMING_SNAKE_CASE_: List[Any]  		=       layer_type
									SCREAMING_SNAKE_CASE_: Any  		=       hidden_act
									SCREAMING_SNAKE_CASE_: Any  		=       downsample_in_first_stage
									SCREAMING_SNAKE_CASE_: Tuple  		=       ["stem"] + [F"stage{idx}" for idx in range(1   ,						len(lowerCAmelCase__) + 1)]
									SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Dict  		=       get_aligned_output_features_output_indices(
									    out_features=lowerCAmelCase__   ,						out_indices=lowerCAmelCase__   ,						stage_names=self.stage_names)







class   __lowercase				( UpperCAmelCase_	):




			"""simple docstring"""







			_UpperCAmelCase   :							Dict										=     version.parse('''1.11'''	)



			@property
			def        _SCREAMING_SNAKE_CASE			( self  :     Union[str, Any]):
									return OrderedDict(
									    [
									        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
									    ])




			@property
			def        _SCREAMING_SNAKE_CASE			( self  :     Optional[int]):
									return 1E-3








import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 			__A( a			):
				snake_case_						   =    ['''image_processor''', '''tokenizer''']
				snake_case_						   =    '''ChineseCLIPImageProcessor'''
				snake_case_						   =    ('''BertTokenizer''', '''BertTokenizerFast''')




				def __init__(     self		,     _snake_case=None		,     _snake_case=None		,     **_snake_case				)    ->      Tuple:


								'''simple docstring'''




								__a										=    None
								if "feature_extractor" in kwargs:
												warnings.warn(
												    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
												    ''' instead.'''		,     _snake_case		,     )
												__a										=    kwargs.pop('''feature_extractor'''				)

								__a										=    image_processor if image_processor is not None else feature_extractor
								if image_processor is None:
												raise ValueError('''You need to specify an `image_processor`.'''				)
								if tokenizer is None:
												raise ValueError('''You need to specify a `tokenizer`.'''				)

								super().__init__(_snake_case		,     _snake_case				)
								__a										=    self.image_processor




				def __call__(     self		,     _snake_case=None		,     _snake_case=None		,     _snake_case=None		,     **_snake_case				)    ->      Optional[Any]:


								'''simple docstring'''




								if text is None and images is None:
												raise ValueError('''You have to specify either text or images. Both cannot be none.'''				)

								if text is not None:
												__a										=    self.tokenizer(_snake_case		,     return_tensors=_snake_case		,     **_snake_case				)

								if images is not None:
												__a										=    self.image_processor(_snake_case		,     return_tensors=_snake_case		,     **_snake_case				)

								if text is not None and images is not None:
												__a										=    image_features.pixel_values
												return encoding
								elif text is not None:
												return encoding
								else:
												return BatchEncoding(data=dict(**_snake_case				)		,     tensor_type=_snake_case				)




				def 				SCREAMING_SNAKE_CASE_		(     self		,     *_snake_case		,     **_snake_case				)    ->      str:


								'''simple docstring'''




								return self.tokenizer.batch_decode(*_snake_case		,     **_snake_case				)




				def 				SCREAMING_SNAKE_CASE_		(     self		,     *_snake_case		,     **_snake_case				)    ->      Dict:


								'''simple docstring'''




								return self.tokenizer.decode(*_snake_case		,     **_snake_case				)




				@property
				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Any:


								'''simple docstring'''




								__a										=    self.tokenizer.model_input_names
								__a										=    self.image_processor.model_input_names
								return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)




				@property
				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Optional[Any]:


								'''simple docstring'''




								warnings.warn(
								    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''		,     _snake_case		,     )
								return self.image_processor_class