


'''simple docstring'''


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


lowerCamelCase__    	=     logging.get_logger(__name__)

lowerCamelCase__    	=     {
    'edbeeching/decision-transformer-gym-hopper-medium': (
        'https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json'
    ),
    # See all DecisionTransformer models at https://huggingface.co/models?filter=decision_transformer
}






class 	lowerCAmelCase__			(			UpperCAmelCase__	):
   lowerCAmelCase :	Tuple          =     "decision_transformer"
   lowerCAmelCase :	Dict          =     ["past_key_values"]
   lowerCAmelCase :	int          =     {
       "max_position_embeddings": "n_positions",
       "num_attention_heads": "n_head",
       "num_hidden_layers": "n_layer",
   }




   def __init__(		self  :     List[Any]	,  lowerCamelCase__  :     List[Any]=17	,  lowerCamelCase__  :     Union[str, Any]=4	,  lowerCamelCase__  :     Tuple=1_28	,  lowerCamelCase__  :     str=40_96	,  lowerCamelCase__  :     Any=True	,  lowerCamelCase__  :     List[str]=1	,  lowerCamelCase__  :     List[str]=10_24	,  lowerCamelCase__  :     List[str]=3	,  lowerCamelCase__  :     Optional[Any]=1	,  lowerCamelCase__  :     Optional[int]=None	,  lowerCamelCase__  :     Optional[int]="relu"	,  lowerCamelCase__  :     Any=0.1	,  lowerCamelCase__  :     List[str]=0.1	,  lowerCamelCase__  :     List[Any]=0.1	,  lowerCamelCase__  :     List[Any]=1E-5	,  lowerCamelCase__  :     List[str]=0.0_2	,  lowerCamelCase__  :     Optional[Any]=True	,  lowerCamelCase__  :     str=True	,  lowerCamelCase__  :     Union[str, Any]=5_02_56	,  lowerCamelCase__  :     Any=5_02_56	,  lowerCamelCase__  :     Optional[int]=False	,  lowerCamelCase__  :     Tuple=False	,  **lowerCamelCase__  :     Dict	,  )   ->str:



     '''simple docstring'''







     _UpperCAmelCase		:       Optional[int]								=      state_dim
     _UpperCAmelCase		:       List[Any]								=      act_dim
     _UpperCAmelCase		:       Dict								=      hidden_size
     _UpperCAmelCase		:       Union[str, Any]								=      max_ep_len
     _UpperCAmelCase		:       Dict								=      action_tanh
     _UpperCAmelCase		:       List[str]								=      vocab_size
     _UpperCAmelCase		:       Any								=      n_positions
     _UpperCAmelCase		:       Tuple								=      n_layer
     _UpperCAmelCase		:       List[str]								=      n_head
     _UpperCAmelCase		:       str								=      n_inner
     _UpperCAmelCase		:       int								=      activation_function
     _UpperCAmelCase		:       Optional[int]								=      resid_pdrop
     _UpperCAmelCase		:       Any								=      embd_pdrop
     _UpperCAmelCase		:       Union[str, Any]								=      attn_pdrop
     _UpperCAmelCase		:       Optional[Any]								=      layer_norm_epsilon
     _UpperCAmelCase		:       Tuple								=      initializer_range
     _UpperCAmelCase		:       str								=      scale_attn_weights
     _UpperCAmelCase		:       Tuple								=      use_cache
     _UpperCAmelCase		:       str								=      scale_attn_by_inverse_layer_idx
     _UpperCAmelCase		:       Union[str, Any]								=      reorder_and_upcast_attn

     _UpperCAmelCase		:       List[Any]								=      bos_token_id
     _UpperCAmelCase		:       int								=      eos_token_id

     super().__init__(bos_token_id=lowerCamelCase__	,  eos_token_id=lowerCamelCase__	,  **lowerCamelCase__ )







'''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 	lowerCAmelCase__			(			UpperCAmelCase__	):
			lowerCAmelCase :	Any          =     ["image_processor", "tokenizer"]
			lowerCAmelCase :	List[Any]          =     "BlipImageProcessor"
			lowerCAmelCase :	Union[str, Any]          =     "AutoTokenizer"




			def __init__(		self  :     Any	,  lowerCamelCase__  :     Tuple	,  lowerCamelCase__  :     int )   ->Optional[int]:



					'''simple docstring'''







					_UpperCAmelCase		:       Optional[int]								=      False
					super().__init__(lowerCamelCase__	,  lowerCamelCase__ )
					_UpperCAmelCase		:       Tuple								=      self.image_processor




			def __call__(		self  :     Dict	,  lowerCamelCase__  :     ImageInput = None	,  lowerCamelCase__  :     Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None	,  lowerCamelCase__  :     bool = True	,  lowerCamelCase__  :     Union[bool, str, PaddingStrategy] = False	,  lowerCamelCase__  :     Union[bool, str, TruncationStrategy] = None	,  lowerCamelCase__  :     Optional[int] = None	,  lowerCamelCase__  :     int = 0	,  lowerCamelCase__  :     Optional[int] = None	,  lowerCamelCase__  :     Optional[bool] = None	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     bool = True	,  lowerCamelCase__  :     Optional[Union[str, TensorType]] = None	,  **lowerCamelCase__  :     Tuple	,  )   ->BatchEncoding:



					'''simple docstring'''







					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:
							_UpperCAmelCase		:       Optional[int]								=      self.tokenizer
							_UpperCAmelCase		:       List[Any]								=      self.tokenizer(
							    text=lowerCamelCase__	,  add_special_tokens=lowerCamelCase__	,  padding=lowerCamelCase__	,  truncation=lowerCamelCase__	,  max_length=lowerCamelCase__	,  stride=lowerCamelCase__	,  pad_to_multiple_of=lowerCamelCase__	,  return_attention_mask=lowerCamelCase__	,  return_overflowing_tokens=lowerCamelCase__	,  return_special_tokens_mask=lowerCamelCase__	,  return_offsets_mapping=lowerCamelCase__	,  return_token_type_ids=lowerCamelCase__	,  return_length=lowerCamelCase__	,  verbose=lowerCamelCase__	,  return_tensors=lowerCamelCase__	,  **lowerCamelCase__	,  )
							return text_encoding

					# add pixel_values
					_UpperCAmelCase		:       Optional[int]								=      self.image_processor(lowerCamelCase__	,  return_tensors=lowerCamelCase__ )

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

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

					return encoding_image_processor




			def 							lowerCAmelCase__    (		self  :     List[Any]	,  *lowerCamelCase__  :     Optional[int]	,  **lowerCamelCase__  :     Dict )   ->Optional[Any]:



					'''simple docstring'''







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




			def 							lowerCAmelCase__    (		self  :     int	,  *lowerCamelCase__  :     Dict	,  **lowerCamelCase__  :     str )   ->Optional[int]:



					'''simple docstring'''







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






			@property
			# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
			def 							lowerCAmelCase__    (		self  :     Any )   ->Optional[int]:



					'''simple docstring'''







					_UpperCAmelCase		:       Optional[Any]								=      self.tokenizer.model_input_names
					_UpperCAmelCase		:       Dict								=      self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names ) )



