


"""simple docstring"""







from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType




class  UpperCamelCase_	( UpperCamelCase):

	"""simple docstring"""





	snake_case__				:  List[str]    					=			["image_processor", "tokenizer"]
	snake_case__				:  Any    					=			"BlipImageProcessor"
	snake_case__				:  Any    					=			("BertTokenizer", "BertTokenizerFast")




	def __init__( self			:				str			,			UpperCAmelCase__			:				Dict			,			UpperCAmelCase__			:				Any   )       ->	Any:
						__SCREAMING_SNAKE_CASE						   =				False
						super().__init__(UpperCAmelCase__			,			UpperCAmelCase__   )
						__SCREAMING_SNAKE_CASE						   =				self.image_processor




	def __call__( self			:				Union[str, Any]			,			UpperCAmelCase__			:				ImageInput = None			,			UpperCAmelCase__			:				Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None			,			UpperCAmelCase__			:				bool = True			,			UpperCAmelCase__			:				Union[bool, str, PaddingStrategy] = False			,			UpperCAmelCase__			:				Union[bool, str, TruncationStrategy] = None			,			UpperCAmelCase__			:				Optional[int] = None			,			UpperCAmelCase__			:				int = 0			,			UpperCAmelCase__			:				Optional[int] = None			,			UpperCAmelCase__			:				Optional[bool] = None			,			UpperCAmelCase__			:				bool = False			,			UpperCAmelCase__			:				bool = False			,			UpperCAmelCase__			:				bool = False			,			UpperCAmelCase__			:				bool = False			,			UpperCAmelCase__			:				bool = False			,			UpperCAmelCase__			:				bool = True			,			UpperCAmelCase__			:				Optional[Union[str, TensorType]] = None			,			**UpperCAmelCase__			:				Union[str, Any]			,			)       ->	BatchEncoding:
						if images is None and text is None:
											raise ValueError("You have to specify either images or text."   )

						# Get only text
						if images is None:
											__SCREAMING_SNAKE_CASE						   =				self.tokenizer
											__SCREAMING_SNAKE_CASE						   =				self.tokenizer(
											    text=UpperCAmelCase__			,			add_special_tokens=UpperCAmelCase__			,			padding=UpperCAmelCase__			,			truncation=UpperCAmelCase__			,			max_length=UpperCAmelCase__			,			stride=UpperCAmelCase__			,			pad_to_multiple_of=UpperCAmelCase__			,			return_attention_mask=UpperCAmelCase__			,			return_overflowing_tokens=UpperCAmelCase__			,			return_special_tokens_mask=UpperCAmelCase__			,			return_offsets_mapping=UpperCAmelCase__			,			return_token_type_ids=UpperCAmelCase__			,			return_length=UpperCAmelCase__			,			verbose=UpperCAmelCase__			,			return_tensors=UpperCAmelCase__			,			**UpperCAmelCase__			,			)
											return text_encoding

						# add pixel_values
						__SCREAMING_SNAKE_CASE						   =				self.image_processor(UpperCAmelCase__			,			return_tensors=UpperCAmelCase__   )

						if text is not None:
											__SCREAMING_SNAKE_CASE						   =				self.tokenizer(
											    text=UpperCAmelCase__			,			add_special_tokens=UpperCAmelCase__			,			padding=UpperCAmelCase__			,			truncation=UpperCAmelCase__			,			max_length=UpperCAmelCase__			,			stride=UpperCAmelCase__			,			pad_to_multiple_of=UpperCAmelCase__			,			return_attention_mask=UpperCAmelCase__			,			return_overflowing_tokens=UpperCAmelCase__			,			return_special_tokens_mask=UpperCAmelCase__			,			return_offsets_mapping=UpperCAmelCase__			,			return_token_type_ids=UpperCAmelCase__			,			return_length=UpperCAmelCase__			,			verbose=UpperCAmelCase__			,			return_tensors=UpperCAmelCase__			,			**UpperCAmelCase__			,			)
						else:
											__SCREAMING_SNAKE_CASE						   =				None

						if text_encoding is not None:
											encoding_image_processor.update(UpperCAmelCase__   )

						return encoding_image_processor




	def   UpperCAmelCase_      ( self			:				str			,			*UpperCAmelCase__			:				str			,			**UpperCAmelCase__			:				List[Any]   )       ->	List[str]:
						return self.tokenizer.batch_decode(*UpperCAmelCase__			,			**UpperCAmelCase__   )




	def   UpperCAmelCase_      ( self			:				str			,			*UpperCAmelCase__			:				Tuple			,			**UpperCAmelCase__			:				Tuple   )       ->	List[str]:
						return self.tokenizer.decode(*UpperCAmelCase__			,			**UpperCAmelCase__   )




	@property
	def   UpperCAmelCase_      ( self			:				Dict   )       ->	Union[str, Any]:
						__SCREAMING_SNAKE_CASE						   =				self.tokenizer.model_input_names
						__SCREAMING_SNAKE_CASE						   =				self.image_processor.model_input_names
						return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )



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


lowercase_       		=  logging.get_logger(__name__)

lowercase_       		=  {
    "microsoft/resnet-50": "https://huggingface.co/microsoft/resnet-50/blob/main/config.json",
}


class  A						(							_UpperCAmelCase    ,							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							'resnet'
    lowerCamelCase			=							['basic', 'bottleneck']


    def __init__(      self :       Optional[Any],lowercase_ :       int=3,lowercase_ :       List[str]=6_4,lowercase_ :       int=[2_5_6, 5_1_2, 1_0_2_4, 2_0_4_8],lowercase_ :       Tuple=[3, 4, 6, 3],lowercase_ :       Union[str, Any]="bottleneck",lowercase_ :       List[str]="relu",lowercase_ :       Tuple=False,lowercase_ :       List[str]=None,lowercase_ :       List[Any]=None,**lowercase_ :       str,)->    Optional[Any]:





        '''simple docstring'''







        super().__init__(**lowercase_		)
        if layer_type not in self.layer_types:
            raise ValueError(F'layer_type={layer_type} is not one of {",".join(self.layer_types		)}'		)
        A__          =   num_channels
        A__          =   embedding_size
        A__          =   hidden_sizes
        A__          =   depths
        A__          =   layer_type
        A__          =   hidden_act
        A__          =   downsample_in_first_stage
        A__          =   ['stem'] + [F'stage{idx}' for idx in range(1,len(lowercase_		) + 1		)]
        A__      ,						A__          =   get_aligned_output_features_output_indices(
            out_features=lowercase_,out_indices=lowercase_,stage_names=self.stage_names		)




class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							version.parse('1.11' )


    @property
    def 						snake_case__     (      self :       List[Any]		)->    Mapping[str, Mapping[int, str]]:





        '''simple docstring'''







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


    @property
    def 						snake_case__     (      self :       Any		)->    float:





        '''simple docstring'''







        return 1E-3

