



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


snake_case__       :  str     		= logging.get_logger(__name__)

snake_case__       :  Any     		= {
    """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 	_A (			A__						):


						'''simple docstring'''





						_snake_case      :  Dict   				=   """owlvit_text_model"""



						def __init__(						self						:				Optional[Any]				,   lowerCamelCase						:				Tuple=49_408				,   lowerCamelCase						:				List[str]=512				,   lowerCamelCase						:				Dict=2_048				,   lowerCamelCase						:				Union[str, Any]=12				,   lowerCamelCase						:				Union[str, Any]=8				,   lowerCamelCase						:				List[str]=16				,   lowerCamelCase						:				Optional[Any]="quick_gelu"				,   lowerCamelCase						:				str=1e-5				,   lowerCamelCase						:				Optional[Any]=0.0				,   lowerCamelCase						:				Tuple=0.02				,   lowerCamelCase						:				Any=1.0				,   lowerCamelCase						:				Tuple=0				,   lowerCamelCase						:				List[str]=49_406				,   lowerCamelCase						:				Optional[int]=49_407				,   **lowerCamelCase						:				Any				,   ):






							'''simple docstring'''



							super().__init__(pad_token_id=__snake_case				,   bos_token_id=__snake_case				,   eos_token_id=__snake_case				,   **__snake_case						)

							__lowercase									=      vocab_size
							__lowercase									=      hidden_size
							__lowercase									=      intermediate_size
							__lowercase									=      num_hidden_layers
							__lowercase									=      num_attention_heads
							__lowercase									=      max_position_embeddings
							__lowercase									=      hidden_act
							__lowercase									=      layer_norm_eps
							__lowercase									=      attention_dropout
							__lowercase									=      initializer_range
							__lowercase									=      initializer_factor



						@classmethod
						def      _snake_case						(						cls						:				int				,   lowerCamelCase						:				Union[str, os.PathLike]				,   **lowerCamelCase						:				Any						):






							'''simple docstring'''



							cls._set_token_in_kwargs(__snake_case						)

							__lowercase							,     __lowercase									=      cls.get_config_dict(__snake_case				,   **__snake_case						)

							# get the text config dict if we are loading from OwlViTConfig
							if config_dict.get("model_type"						) == "owlvit":
								__lowercase									=      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(__snake_case				,   **__snake_case						)

class 	_A (			A__						):


						'''simple docstring'''





						_snake_case      :  Optional[int]   				=   """owlvit_vision_model"""



						def __init__(						self						:				str				,   lowerCamelCase						:				Dict=768				,   lowerCamelCase						:				List[str]=3_072				,   lowerCamelCase						:				Tuple=12				,   lowerCamelCase						:				Optional[Any]=12				,   lowerCamelCase						:				str=3				,   lowerCamelCase						:				List[str]=768				,   lowerCamelCase						:				int=32				,   lowerCamelCase						:				Any="quick_gelu"				,   lowerCamelCase						:				str=1e-5				,   lowerCamelCase						:				str=0.0				,   lowerCamelCase						:				Optional[Any]=0.02				,   lowerCamelCase						:				Optional[Any]=1.0				,   **lowerCamelCase						:				Union[str, Any]				,   ):






							'''simple docstring'''



							super().__init__(**__snake_case						)

							__lowercase									=      hidden_size
							__lowercase									=      intermediate_size
							__lowercase									=      num_hidden_layers
							__lowercase									=      num_attention_heads
							__lowercase									=      num_channels
							__lowercase									=      image_size
							__lowercase									=      patch_size
							__lowercase									=      hidden_act
							__lowercase									=      layer_norm_eps
							__lowercase									=      attention_dropout
							__lowercase									=      initializer_range
							__lowercase									=      initializer_factor



						@classmethod
						def      _snake_case						(						cls						:				List[Any]				,   lowerCamelCase						:				Union[str, os.PathLike]				,   **lowerCamelCase						:				List[str]						):






							'''simple docstring'''



							cls._set_token_in_kwargs(__snake_case						)

							__lowercase							,     __lowercase									=      cls.get_config_dict(__snake_case				,   **__snake_case						)

							# get the vision config dict if we are loading from OwlViTConfig
							if config_dict.get("model_type"						) == "owlvit":
								__lowercase									=      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(__snake_case				,   **__snake_case						)

class 	_A (			A__						):


						'''simple docstring'''





						_snake_case      :  Union[str, Any]   				=   """owlvit"""
						_snake_case      :  Optional[Any]   				=   True



						def __init__(						self						:				Union[str, Any]				,   lowerCamelCase						:				List[Any]=None				,   lowerCamelCase						:				Tuple=None				,   lowerCamelCase						:				Dict=512				,   lowerCamelCase						:				Any=2.6592				,   lowerCamelCase						:				Optional[Any]=True				,   **lowerCamelCase						:				Union[str, Any]				,   ):






							'''simple docstring'''



							super().__init__(**__snake_case						)

							if text_config is None:
								__lowercase									=      {}
								logger.info("text_config is None. Initializing the OwlViTTextConfig with default values."						)

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

							__lowercase									=      OwlViTTextConfig(**__snake_case						)
							__lowercase									=      OwlViTVisionConfig(**__snake_case						)

							__lowercase									=      projection_dim
							__lowercase									=      logit_scale_init_value
							__lowercase									=      return_dict
							__lowercase									=      1.0



						@classmethod
						def      _snake_case						(						cls						:				Tuple				,   lowerCamelCase						:				Union[str, os.PathLike]				,   **lowerCamelCase						:				List[Any]						):






							'''simple docstring'''



							cls._set_token_in_kwargs(__snake_case						)

							__lowercase							,     __lowercase									=      cls.get_config_dict(__snake_case				,   **__snake_case						)

							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(__snake_case				,   **__snake_case						)



						@classmethod
						def      _snake_case						(						cls						:				List[str]				,   lowerCamelCase						:				Dict				,   lowerCamelCase						:				Dict				,   **lowerCamelCase						:				Optional[Any]						):






							'''simple docstring'''



							__lowercase									=      {}
							__lowercase									=      text_config
							__lowercase									=      vision_config

							return cls.from_dict(__snake_case				,   **__snake_case						)



						def      _snake_case						(						self						:				Union[str, Any]						):






							'''simple docstring'''



							__lowercase									=      copy.deepcopy(self.__dict__						)
							__lowercase									=      self.text_config.to_dict()
							__lowercase									=      self.vision_config.to_dict()
							__lowercase									=      self.__class__.model_type
							return output

class 	_A (			A__						):


						'''simple docstring'''





						@property
						def      _snake_case						(						self						:				Any						):






							'''simple docstring'''



							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]						):






							'''simple docstring'''



							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						:				List[str]						):






							'''simple docstring'''



							return 1e-4



						def      _snake_case						(						self						:				Dict				,   lowerCamelCase						:				"ProcessorMixin"				,   lowerCamelCase						:				int = -1				,   lowerCamelCase						:				int = -1				,   lowerCamelCase						:				Optional["TensorType"] = None				,   ):






							'''simple docstring'''



							__lowercase									=      super().generate_dummy_inputs(
							    processor.tokenizer				,   batch_size=__snake_case				,   seq_length=__snake_case				,   framework=__snake_case						)
							__lowercase									=      super().generate_dummy_inputs(
							    processor.image_processor				,   batch_size=__snake_case				,   framework=__snake_case						)
							return {**text_input_dict, **image_input_dict}



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






							'''simple docstring'''



							return 14










'''simple docstring'''




from ....configuration_utils import PretrainedConfig
from ....utils import logging


_SCREAMING_SNAKE_CASE							     =			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE							     =			{
    "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": (
        "https://huggingface.co/CarlCochet/trajectory-transformer-halfcheetah-medium-v2/resolve/main/config.json"
    ),
    # See all TrajectoryTransformer models at https://huggingface.co/models?filter=trajectory_transformer
}
class 			_lowerCAmelCase		(			A__	):






     """simple docstring"""






     snake_case_						      =   "trajectory_transformer"
     snake_case_						      =   ["past_key_values"]
     snake_case_						      =   {
         "hidden_size": "n_embd",
         "num_attention_heads": "n_head",
         "num_hidden_layers": "n_layer",
     }



     def __init__(   self							:			Optional[Any]   ,       __snake_case							:			int=1_00   ,       __snake_case							:			List[str]=5   ,       __snake_case							:			str=1   ,       __snake_case							:			Union[str, Any]=1   ,       __snake_case							:			Union[str, Any]=2_49   ,       __snake_case							:			List[Any]=6   ,       __snake_case							:			Optional[int]=17   ,       __snake_case							:			Optional[Any]=25   ,       __snake_case							:			Union[str, Any]=4   ,       __snake_case							:			List[Any]=4   ,       __snake_case							:			Optional[int]=1_28   ,       __snake_case							:			Optional[Any]=0.1   ,       __snake_case							:			Any=0.1   ,       __snake_case							:			int=0.1   ,       __snake_case							:			Union[str, Any]=0.00_06   ,       __snake_case							:			Tuple=5_12   ,       __snake_case							:			int=0.02   ,       __snake_case							:			Any=1e-12   ,       __snake_case							:			Optional[Any]=1   ,       __snake_case							:			List[Any]=True   ,       __snake_case							:			Dict=1   ,       __snake_case							:			Dict=5_02_56   ,       __snake_case							:			Union[str, Any]=5_02_56   ,       **__snake_case							:			Tuple   ,       )->	Optional[int]:
        snake_case 						=   vocab_size
        snake_case 						=   action_weight
        snake_case 						=   reward_weight
        snake_case 						=   value_weight
        snake_case 						=   max_position_embeddings
        snake_case 						=   block_size
        snake_case 						=   action_dim
        snake_case 						=   observation_dim
        snake_case 						=   transition_dim
        snake_case 						=   learning_rate
        snake_case 						=   n_layer
        snake_case 						=   n_head
        snake_case 						=   n_embd
        snake_case 						=   embd_pdrop
        snake_case 						=   attn_pdrop
        snake_case 						=   resid_pdrop
        snake_case 						=   initializer_range
        snake_case 						=   layer_norm_eps
        snake_case 						=   kaiming_initializer_range
        snake_case 						=   use_cache
        super().__init__(pad_token_id=__snake_case   ,       bos_token_id=__snake_case   ,       eos_token_id=__snake_case   ,       **__snake_case						)

