



"""simple docstring"""




import argparse
import json
import os

import numpy as np
import PIL
import requests
import tensorflow.keras.applications.efficientnet as efficientnet
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from tensorflow.keras.preprocessing import image

from transformers import (
    EfficientNetConfig,
    EfficientNetForImageClassification,
    EfficientNetImageProcessor,
)
from transformers.utils import logging


logging.set_verbosity_info()
_lowerCAmelCase    : Optional[Any]							=							logging.get_logger(__name__)

_lowerCAmelCase    : Union[str, Any]							=							{
    'b0': efficientnet.EfficientNetBa,
    'b1': efficientnet.EfficientNetBa,
    'b2': efficientnet.EfficientNetBa,
    'b3': efficientnet.EfficientNetBa,
    'b4': efficientnet.EfficientNetBa,
    'b5': efficientnet.EfficientNetBa,
    'b6': efficientnet.EfficientNetBa,
    'b7': efficientnet.EfficientNetBa,
}

_lowerCAmelCase    : Union[str, Any]							=							{
    'b0': {
        'hidden_dim': 12_80,
        'width_coef': 1.0,
        'depth_coef': 1.0,
        'image_size': 2_24,
        'dropout_rate': 0.2,
        'dw_padding': [],
    },
    'b1': {
        'hidden_dim': 12_80,
        'width_coef': 1.0,
        'depth_coef': 1.1,
        'image_size': 2_40,
        'dropout_rate': 0.2,
        'dw_padding': [16],
    },
    'b2': {
        'hidden_dim': 14_08,
        'width_coef': 1.1,
        'depth_coef': 1.2,
        'image_size': 2_60,
        'dropout_rate': 0.3,
        'dw_padding': [5, 8, 16],
    },
    'b3': {
        'hidden_dim': 15_36,
        'width_coef': 1.2,
        'depth_coef': 1.4,
        'image_size': 3_00,
        'dropout_rate': 0.3,
        'dw_padding': [5, 18],
    },
    'b4': {
        'hidden_dim': 17_92,
        'width_coef': 1.4,
        'depth_coef': 1.8,
        'image_size': 3_80,
        'dropout_rate': 0.4,
        'dw_padding': [6],
    },
    'b5': {
        'hidden_dim': 20_48,
        'width_coef': 1.6,
        'depth_coef': 2.2,
        'image_size': 4_56,
        'dropout_rate': 0.4,
        'dw_padding': [13, 27],
    },
    'b6': {
        'hidden_dim': 23_04,
        'width_coef': 1.8,
        'depth_coef': 2.6,
        'image_size': 5_28,
        'dropout_rate': 0.5,
        'dw_padding': [31],
    },
    'b7': {
        'hidden_dim': 25_60,
        'width_coef': 2.0,
        'depth_coef': 3.1,
        'image_size': 6_00,
        'dropout_rate': 0.5,
        'dw_padding': [18],
    },
}

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       Optional[Any]:





					'''simple docstring'''

					_UpperCAmelCase      :     Optional[Any]        =   EfficientNetConfig()
					_UpperCAmelCase      :     Tuple        =   CONFIG_MAP[model_name]["hidden_dim"]
					_UpperCAmelCase      :     int        =   CONFIG_MAP[model_name]["width_coef"]
					_UpperCAmelCase      :     List[Any]        =   CONFIG_MAP[model_name]["depth_coef"]
					_UpperCAmelCase      :     List[str]        =   CONFIG_MAP[model_name]["image_size"]
					_UpperCAmelCase      :     Dict        =   CONFIG_MAP[model_name]["dropout_rate"]
					_UpperCAmelCase      :     List[str]        =   CONFIG_MAP[model_name]["dw_padding"]

					_UpperCAmelCase      :     str        =   "huggingface/label-files"
					_UpperCAmelCase      :     str        =   "imagenet-1k-id2label.json"
					_UpperCAmelCase      :     Union[str, Any]        =   1_000
					_UpperCAmelCase      :     Tuple        =   json.load(open(hf_hub_download(__snake_case						,  __snake_case						,  repo_type="dataset"    )						,  "r"    )    )
					_UpperCAmelCase      :     Union[str, Any]        =   {int(__snake_case    ): v for k, v in idalabel.items()}

					_UpperCAmelCase      :     Optional[Any]        =   idalabel
					_UpperCAmelCase      :     str        =   {v: k for k, v in idalabel.items()}
					return config

def 						__snake_case						(				)  ->       List[str]:





					'''simple docstring'''

					_UpperCAmelCase      :     int        =   "http://images.cocodataset.org/val2017/000000039769.jpg"
					_UpperCAmelCase      :     List[Any]        =   Image.open(requests.get(__snake_case						,  stream=__snake_case    ).raw    )
					return im

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Union[str, Any]    )  ->       str:





					'''simple docstring'''

					_UpperCAmelCase      :     Any        =   CONFIG_MAP[model_name]["image_size"]
					_UpperCAmelCase      :     Tuple        =   EfficientNetImageProcessor(
					    size={"height": size, "width": size}						,  image_mean=[0.485, 0.456, 0.406]						,  image_std=[0.47_853_944, 0.4_732_864, 0.47_434_163]						,  do_center_crop=__snake_case						,  )
					return preprocessor

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						str    )  ->       Any:





					'''simple docstring'''

					_UpperCAmelCase      :     Optional[int]        =   [v.split("_"    )[0].split("block"    )[1] for v in original_param_names if v.startswith("block"    )]
					_UpperCAmelCase      :     Optional[int]        =   sorted(set(__snake_case    )    )
					_UpperCAmelCase      :     Tuple        =   len(__snake_case    )
					_UpperCAmelCase      :     int        =   {b: str(__snake_case    ) for b, i in zip(__snake_case						,  range(__snake_case    )    )}

					_UpperCAmelCase      :     List[Any]        =   []
					rename_keys.append(("stem_conv/kernel:0", "embeddings.convolution.weight")    )
					rename_keys.append(("stem_bn/gamma:0", "embeddings.batchnorm.weight")    )
					rename_keys.append(("stem_bn/beta:0", "embeddings.batchnorm.bias")    )
					rename_keys.append(("stem_bn/moving_mean:0", "embeddings.batchnorm.running_mean")    )
					rename_keys.append(("stem_bn/moving_variance:0", "embeddings.batchnorm.running_var")    )

					for b in block_names:
										_UpperCAmelCase      :     List[str]        =   block_name_mapping[b]
										rename_keys.append((f'block{b}_expand_conv/kernel:0', f'encoder.blocks.{hf_b}.expansion.expand_conv.weight')    )
										rename_keys.append((f'block{b}_expand_bn/gamma:0', f'encoder.blocks.{hf_b}.expansion.expand_bn.weight')    )
										rename_keys.append((f'block{b}_expand_bn/beta:0', f'encoder.blocks.{hf_b}.expansion.expand_bn.bias')    )
										rename_keys.append(
										    (f'block{b}_expand_bn/moving_mean:0', f'encoder.blocks.{hf_b}.expansion.expand_bn.running_mean')    )
										rename_keys.append(
										    (f'block{b}_expand_bn/moving_variance:0', f'encoder.blocks.{hf_b}.expansion.expand_bn.running_var')    )
										rename_keys.append(
										    (f'block{b}_dwconv/depthwise_kernel:0', f'encoder.blocks.{hf_b}.depthwise_conv.depthwise_conv.weight')    )
										rename_keys.append((f'block{b}_bn/gamma:0', f'encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.weight')    )
										rename_keys.append((f'block{b}_bn/beta:0', f'encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.bias')    )
										rename_keys.append(
										    (f'block{b}_bn/moving_mean:0', f'encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.running_mean')    )
										rename_keys.append(
										    (f'block{b}_bn/moving_variance:0', f'encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.running_var')    )

										rename_keys.append((f'block{b}_se_reduce/kernel:0', f'encoder.blocks.{hf_b}.squeeze_excite.reduce.weight')    )
										rename_keys.append((f'block{b}_se_reduce/bias:0', f'encoder.blocks.{hf_b}.squeeze_excite.reduce.bias')    )
										rename_keys.append((f'block{b}_se_expand/kernel:0', f'encoder.blocks.{hf_b}.squeeze_excite.expand.weight')    )
										rename_keys.append((f'block{b}_se_expand/bias:0', f'encoder.blocks.{hf_b}.squeeze_excite.expand.bias')    )
										rename_keys.append(
										    (f'block{b}_project_conv/kernel:0', f'encoder.blocks.{hf_b}.projection.project_conv.weight')    )
										rename_keys.append((f'block{b}_project_bn/gamma:0', f'encoder.blocks.{hf_b}.projection.project_bn.weight')    )
										rename_keys.append((f'block{b}_project_bn/beta:0', f'encoder.blocks.{hf_b}.projection.project_bn.bias')    )
										rename_keys.append(
										    (f'block{b}_project_bn/moving_mean:0', f'encoder.blocks.{hf_b}.projection.project_bn.running_mean')    )
										rename_keys.append(
										    (f'block{b}_project_bn/moving_variance:0', f'encoder.blocks.{hf_b}.projection.project_bn.running_var')    )

					rename_keys.append(("top_conv/kernel:0", "encoder.top_conv.weight")    )
					rename_keys.append(("top_bn/gamma:0", "encoder.top_bn.weight")    )
					rename_keys.append(("top_bn/beta:0", "encoder.top_bn.bias")    )
					rename_keys.append(("top_bn/moving_mean:0", "encoder.top_bn.running_mean")    )
					rename_keys.append(("top_bn/moving_variance:0", "encoder.top_bn.running_var")    )

					_UpperCAmelCase      :     Dict        =   {}
					for item in rename_keys:
										if item[0] in original_param_names:
															_UpperCAmelCase      :     int        =   "efficientnet." + item[1]

					_UpperCAmelCase      :     Dict        =   "classifier.weight"
					_UpperCAmelCase      :     List[Any]        =   "classifier.bias"
					return key_mapping

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						str						,  SCREAMING_SNAKE_CASE__     :						int    )  ->       List[Any]:





					'''simple docstring'''

					for key, value in tf_params.items():
										if "normalization" in key:
															continue

										_UpperCAmelCase      :     Dict        =   key_mapping[key]
										if "_conv" in key and "kernel" in key:
															_UpperCAmelCase      :     List[str]        =   torch.from_numpy(__snake_case    ).permute(3						,  2						,  0						,  1    )
										elif "depthwise_kernel" in key:
															_UpperCAmelCase      :     List[str]        =   torch.from_numpy(__snake_case    ).permute(2						,  3						,  0						,  1    )
										elif "kernel" in key:
															_UpperCAmelCase      :     Optional[Any]        =   torch.from_numpy(np.transpose(__snake_case    )    )
										else:
															_UpperCAmelCase      :     Optional[Any]        =   torch.from_numpy(__snake_case    )

										# Replace HF parameters with original TF model parameters
										assert hf_params[hf_key].shape == new_hf_value.shape
										hf_params[hf_key].copy_(__snake_case    )

@torch.no_grad()
def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						List[Any]    )  ->       str:





					'''simple docstring'''

					_UpperCAmelCase      :     Dict        =   model_classes[model_name](
					    include_top=__snake_case						,  weights="imagenet"						,  input_tensor=__snake_case						,  input_shape=__snake_case						,  pooling=__snake_case						,  classes=1_000						,  classifier_activation="softmax"						,  )

					_UpperCAmelCase      :     Tuple        =   original_model.trainable_variables
					_UpperCAmelCase      :     Union[str, Any]        =   original_model.non_trainable_variables
					_UpperCAmelCase      :     Any        =   {param.name: param.numpy() for param in tf_params}
					for param in tf_non_train_params:
										_UpperCAmelCase      :     Union[str, Any]        =   param.numpy()
					_UpperCAmelCase      :     Optional[int]        =   list(tf_params.keys()    )

					# Load HuggingFace model
					_UpperCAmelCase      :     str        =   get_efficientnet_config(__snake_case    )
					_UpperCAmelCase      :     Optional[int]        =   EfficientNetForImageClassification(__snake_case    ).eval()
					_UpperCAmelCase      :     Optional[Any]        =   hf_model.state_dict()

					# Create src-to-dst parameter name mapping dictionary
					print("Converting parameters..."    )
					_UpperCAmelCase      :     Optional[Any]        =   rename_keys(__snake_case    )
					replace_params(__snake_case						,  __snake_case						,  __snake_case    )

					# Initialize preprocessor and preprocess input image
					_UpperCAmelCase      :     int        =   convert_image_processor(__snake_case    )
					_UpperCAmelCase      :     Tuple        =   preprocessor(images=prepare_img()						,  return_tensors="pt"    )

					# HF model inference
					hf_model.eval()
					with torch.no_grad():
										_UpperCAmelCase      :     Optional[int]        =   hf_model(**__snake_case    )
					_UpperCAmelCase      :     Any        =   outputs.logits.detach().numpy()

					# Original model inference
					_UpperCAmelCase      :     Dict        =   False
					_UpperCAmelCase      :     Union[str, Any]        =   CONFIG_MAP[model_name]["image_size"]
					_UpperCAmelCase      :     Optional[int]        =   prepare_img().resize((image_size, image_size)						,  resample=PIL.Image.NEAREST    )
					_UpperCAmelCase      :     str        =   image.img_to_array(__snake_case    )
					_UpperCAmelCase      :     List[Any]        =   np.expand_dims(__snake_case						,  axis=0    )
					_UpperCAmelCase      :     Tuple        =   original_model.predict(__snake_case    )

					# Check whether original and HF model outputs match  -> np.allclose
					assert np.allclose(__snake_case						,  __snake_case						,  atol=1E-3    ), "The predicted logits are not the same."
					print("Model outputs match!"    )

					if save_model:
										# Create folder to save model
										if not os.path.isdir(__snake_case    ):
															os.mkdir(__snake_case    )
										# Save converted model and image processor
										hf_model.save_pretrained(__snake_case    )
										preprocessor.save_pretrained(__snake_case    )

					if push_to_hub:
										# Push model and image processor to hub
										print(f'Pushing converted {model_name} to the hub...'    )
										_UpperCAmelCase      :     Dict        =   f'efficientnet-{model_name}'
										preprocessor.push_to_hub(__snake_case    )
										hf_model.push_to_hub(__snake_case    )


if __name__ == "__main__":
	_lowerCAmelCase    : Optional[Any]							=							argparse.ArgumentParser()
	# Required parameters
	parser.add_argument(
	    "--model_name",
	    default="b0",
	    type=str,
	    help="Version name of the EfficientNet model you want to convert, select from [b0, b1, b2, b3, b4, b5, b6, b7].",
	)
	parser.add_argument(
	    "--pytorch_dump_folder_path",
	    default="hf_model",
	    type=str,
	    help="Path to the output PyTorch model directory.",
	)
	parser.add_argument("--save_model", action="store_true", help="Save model to local")
	parser.add_argument("--push_to_hub", action="store_true", help="Push model and image processor to the hub")

	_lowerCAmelCase    : Any							=							parser.parse_args()
	convert_efficientnet_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.save_model, args.push_to_hub)





"""simple docstring"""




import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
 from ...processing_utils import ProcessorMixin
 from ...utils import TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_lowerCAmelCase    : Dict							=							logging.get_logger(__name__)

_lowerCAmelCase    : List[str]							=							{
    "google/owlvit-base-patch32": "https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json",
    "google/owlvit-base-patch16": "https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json",
    "google/owlvit-large-patch14": "https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json",
}






class      UpperCAmelCase_  (    _UpperCamelCase						):
      __SCREAMING_SNAKE_CASE						:       int								=			'owlvit_text_model'



      def __init__(					self					:     int					,     A					:     int=4_9_4_0_8					,     A					:     Optional[Any]=5_1_2					,     A					:     Optional[Any]=2_0_4_8					,     A					:     str=1_2					,     A					:     int=8					,     A					:     Tuple=1_6					,     A					:     List[Any]="quick_gelu"					,     A					:     Tuple=1e-5					,     A					:     Union[str, Any]=0.0					,     A					:     List[Any]=0.02					,     A					:     str=1.0					,     A					:     str=0					,     A					:     List[str]=4_9_4_0_6					,     A					:     str=4_9_4_0_7					,     **A					:     Optional[Any]					,     ):
           super().__init__(pad_token_id=A					,     bos_token_id=A					,     eos_token_id=A					,     **A						)

           _UpperCAmelCase      :     Union[str, Any]        =   vocab_size
           _UpperCAmelCase      :     str        =   hidden_size
           _UpperCAmelCase      :     List[Any]        =   intermediate_size
           _UpperCAmelCase      :     Any        =   num_hidden_layers
           _UpperCAmelCase      :     str        =   num_attention_heads
           _UpperCAmelCase      :     List[str]        =   max_position_embeddings
           _UpperCAmelCase      :     List[Any]        =   hidden_act
           _UpperCAmelCase      :     Tuple        =   layer_norm_eps
           _UpperCAmelCase      :     List[str]        =   attention_dropout
           _UpperCAmelCase      :     Optional[Any]        =   initializer_range
           _UpperCAmelCase      :     List[Any]        =   initializer_factor



      @classmethod
      def 						snake_case_ (					cls					:     Any					,     A					:     Union[str, os.PathLike]					,     **A					:     Dict						):
           cls._set_token_in_kwargs(A						)

           _UpperCAmelCase    ,	_UpperCAmelCase      :     List[str]        =   cls.get_config_dict(A					,     **A						)

           # get the text config dict if we are loading from OwlViTConfig
           if config_dict.get("model_type"						) == "owlvit":
                _UpperCAmelCase      :     int        =   config_dict["text_config"]

           if "model_type" in config_dict and hasattr(cls					,     "model_type"						) and config_dict["model_type"] != cls.model_type:
                logger.warning(
                    f'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                    f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'						)

           return cls.from_dict(A					,     **A						)







class      UpperCAmelCase_  (    _UpperCamelCase						):
      __SCREAMING_SNAKE_CASE						:       Tuple								=			'owlvit_vision_model'



      def __init__(					self					:     Union[str, Any]					,     A					:     Optional[int]=7_6_8					,     A					:     int=3_0_7_2					,     A					:     List[str]=1_2					,     A					:     List[str]=1_2					,     A					:     Optional[int]=3					,     A					:     Optional[int]=7_6_8					,     A					:     str=3_2					,     A					:     Tuple="quick_gelu"					,     A					:     Dict=1e-5					,     A					:     Optional[int]=0.0					,     A					:     List[Any]=0.02					,     A					:     str=1.0					,     **A					:     Tuple					,     ):
           super().__init__(**A						)

           _UpperCAmelCase      :     List[str]        =   hidden_size
           _UpperCAmelCase      :     Tuple        =   intermediate_size
           _UpperCAmelCase      :     Optional[Any]        =   num_hidden_layers
           _UpperCAmelCase      :     Dict        =   num_attention_heads
           _UpperCAmelCase      :     Optional[Any]        =   num_channels
           _UpperCAmelCase      :     Union[str, Any]        =   image_size
           _UpperCAmelCase      :     Dict        =   patch_size
           _UpperCAmelCase      :     List[str]        =   hidden_act
           _UpperCAmelCase      :     Union[str, Any]        =   layer_norm_eps
           _UpperCAmelCase      :     Any        =   attention_dropout
           _UpperCAmelCase      :     Tuple        =   initializer_range
           _UpperCAmelCase      :     Tuple        =   initializer_factor



      @classmethod
      def 						snake_case_ (					cls					:     Optional[int]					,     A					:     Union[str, os.PathLike]					,     **A					:     int						):
           cls._set_token_in_kwargs(A						)

           _UpperCAmelCase    ,	_UpperCAmelCase      :     Dict        =   cls.get_config_dict(A					,     **A						)

           # get the vision config dict if we are loading from OwlViTConfig
           if config_dict.get("model_type"						) == "owlvit":
                _UpperCAmelCase      :     Tuple        =   config_dict["vision_config"]

           if "model_type" in config_dict and hasattr(cls					,     "model_type"						) and config_dict["model_type"] != cls.model_type:
                logger.warning(
                    f'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                    f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'						)

           return cls.from_dict(A					,     **A						)







class      UpperCAmelCase_  (    _UpperCamelCase						):
      __SCREAMING_SNAKE_CASE						:       List[str]								=			'owlvit'
      __SCREAMING_SNAKE_CASE						:       Optional[Any]								=			True



      def __init__(					self					:     Optional[Any]					,     A					:     Dict=None					,     A					:     Tuple=None					,     A					:     Optional[Any]=5_1_2					,     A					:     Optional[Any]=2.6_592					,     A					:     int=True					,     **A					:     Tuple					,     ):
           super().__init__(**A						)

           if text_config is None:
                _UpperCAmelCase      :     List[Any]        =   {}
                logger.info("text_config is None. Initializing the OwlViTTextConfig with default values."						)

           if vision_config is None:
                _UpperCAmelCase      :     Tuple        =   {}
                logger.info("vision_config is None. initializing the OwlViTVisionConfig with default values."						)

           _UpperCAmelCase      :     str        =   OwlViTTextConfig(**A						)
           _UpperCAmelCase      :     int        =   OwlViTVisionConfig(**A						)

           _UpperCAmelCase      :     Optional[Any]        =   projection_dim
           _UpperCAmelCase      :     str        =   logit_scale_init_value
           _UpperCAmelCase      :     Optional[Any]        =   return_dict
           _UpperCAmelCase      :     str        =   1.0



      @classmethod
      def 						snake_case_ (					cls					:     Dict					,     A					:     Union[str, os.PathLike]					,     **A					:     Any						):
           cls._set_token_in_kwargs(A						)

           _UpperCAmelCase    ,	_UpperCAmelCase      :     str        =   cls.get_config_dict(A					,     **A						)

           if "model_type" in config_dict and hasattr(cls					,     "model_type"						) and config_dict["model_type"] != cls.model_type:
                logger.warning(
                    f'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                    f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'						)

           return cls.from_dict(A					,     **A						)



      @classmethod
      def 						snake_case_ (					cls					:     Optional[int]					,     A					:     Dict					,     A					:     Dict					,     **A					:     Optional[Any]						):
           _UpperCAmelCase      :     Optional[Any]        =   {}
           _UpperCAmelCase      :     int        =   text_config
           _UpperCAmelCase      :     Dict        =   vision_config

           return cls.from_dict(A					,     **A						)



      def 						snake_case_ (					self					:     Optional[int]						):
           _UpperCAmelCase      :     str        =   copy.deepcopy(self.__dict__						)
           _UpperCAmelCase      :     Optional[int]        =   self.text_config.to_dict()
           _UpperCAmelCase      :     Optional[int]        =   self.vision_config.to_dict()
           _UpperCAmelCase      :     List[Any]        =   self.__class__.model_type
           return output







class      UpperCAmelCase_  (    _UpperCamelCase						):



      @property
      def 						snake_case_ (					self					:     List[str]						):
           return OrderedDict(
               [
                   ("input_ids", {0: "batch", 1: "sequence"}),
                   ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
                   ("attention_mask", {0: "batch", 1: "sequence"}),
               ]						)



      @property
      def 						snake_case_ (					self					:     Optional[int]						):
           return OrderedDict(
               [
                   ("logits_per_image", {0: "batch"}),
                   ("logits_per_text", {0: "batch"}),
                   ("text_embeds", {0: "batch"}),
                   ("image_embeds", {0: "batch"}),
               ]						)



      @property
      def 						snake_case_ (					self					:     str						):
           return 1e-4



      def 						snake_case_ (					self					:     str					,     A					:     "ProcessorMixin"					,     A					:     int = -1					,     A					:     int = -1					,     A					:     Optional["TensorType"] = None					,     ):
           _UpperCAmelCase      :     Optional[Any]        =   super().generate_dummy_inputs(
               processor.tokenizer					,     batch_size=A					,     seq_length=A					,     framework=A						)
           _UpperCAmelCase      :     Union[str, Any]        =   super().generate_dummy_inputs(
               processor.image_processor					,     batch_size=A					,     framework=A						)
           return {**text_input_dict, **image_input_dict}



      @property
      def 						snake_case_ (					self					:     List[Any]						):
           return 1_4
