


from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


lowerCamelCase		=	logging.get_logger(__name__)

lowerCamelCase		=	{
    '''facebook/mbart-large-cc25''': '''https://huggingface.co/facebook/mbart-large-cc25/resolve/main/config.json''',
    # See all MBART models at https://huggingface.co/models?filter=mbart
}





class       _a							(       _lowercase):
	_a						:						List[Any]   					=							'''mbart'''
	_a						:						Dict   					=							['''past_key_values''']
	_a						:						Any   					=							{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}




	def __init__(      self		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=5_0265	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=1024	,      _SCREAMING_SNAKE_CASE		:	List[Any]=12	,      _SCREAMING_SNAKE_CASE		:	Tuple=4096	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=16	,      _SCREAMING_SNAKE_CASE		:	List[Any]=12	,      _SCREAMING_SNAKE_CASE		:	Tuple=4096	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=16	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=0.0	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=0.0	,      _SCREAMING_SNAKE_CASE		:	List[str]=True	,      _SCREAMING_SNAKE_CASE		:	str=True	,      _SCREAMING_SNAKE_CASE		:	List[str]="gelu"	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=1024	,      _SCREAMING_SNAKE_CASE		:	List[Any]=0.1	,      _SCREAMING_SNAKE_CASE		:	Any=0.0	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=0.0	,      _SCREAMING_SNAKE_CASE		:	Dict=0.02	,      _SCREAMING_SNAKE_CASE		:	List[str]=0.0	,      _SCREAMING_SNAKE_CASE		:	Any=False	,      _SCREAMING_SNAKE_CASE		:	Dict=1	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=0	,      _SCREAMING_SNAKE_CASE		:	List[Any]=2	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=2	,      **_SCREAMING_SNAKE_CASE		:	List[str]	,      )-> int:
			lowerCAmelCase__     :    List[Any]					  =      vocab_size
			lowerCAmelCase__     :    Optional[int]					  =      max_position_embeddings
			lowerCAmelCase__     :    int					  =      d_model
			lowerCAmelCase__     :    Any					  =      encoder_ffn_dim
			lowerCAmelCase__     :    List[str]					  =      encoder_layers
			lowerCAmelCase__     :    List[Any]					  =      encoder_attention_heads
			lowerCAmelCase__     :    List[str]					  =      decoder_ffn_dim
			lowerCAmelCase__     :    Any					  =      decoder_layers
			lowerCAmelCase__     :    Dict					  =      decoder_attention_heads
			lowerCAmelCase__     :    List[Any]					  =      dropout
			lowerCAmelCase__     :    List[Any]					  =      attention_dropout
			lowerCAmelCase__     :    str					  =      activation_dropout
			lowerCAmelCase__     :    str					  =      activation_function
			lowerCAmelCase__     :    Any					  =      init_std
			lowerCAmelCase__     :    str					  =      encoder_layerdrop
			lowerCAmelCase__     :    Tuple					  =      decoder_layerdrop
			lowerCAmelCase__     :    Any					  =      classifier_dropout
			lowerCAmelCase__     :    str					  =      use_cache
			lowerCAmelCase__     :    int					  =      encoder_layers
			lowerCAmelCase__     :    int					  =      scale_embedding  # scale factor will be sqrt(d_model) if True
			super().__init__(
			    pad_token_id=_SCREAMING_SNAKE_CASE	,      bos_token_id=_SCREAMING_SNAKE_CASE	,      eos_token_id=_SCREAMING_SNAKE_CASE	,      is_encoder_decoder=_SCREAMING_SNAKE_CASE	,      forced_eos_token_id=_SCREAMING_SNAKE_CASE	,      **_SCREAMING_SNAKE_CASE	,      )





class       _a							(       _lowercase):




	@property
	def 							UpperCAmelCase__(      self		:	List[Any]	)-> Mapping[str, Mapping[int, str]]:
			if self.task in ["default", "seq2seq-lm"]:
					lowerCAmelCase__     :    Dict					  =      OrderedDict(
					    [
					        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
					        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
					    ]	)

					if self.use_past:
							lowerCAmelCase__     :    Union[str, Any]					  =      {0: '''batch'''}
							lowerCAmelCase__     :    str					  =      {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
					else:
							lowerCAmelCase__     :    str					  =      {0: '''batch''', 1: '''decoder_sequence'''}
							lowerCAmelCase__     :    Any					  =      {0: '''batch''', 1: '''decoder_sequence'''}

					if self.use_past:
							self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE	,      direction='''inputs'''	)
			elif self.task == "causal-lm":
					# TODO: figure this case out.
					lowerCAmelCase__     :    Optional[Any]					  =      OrderedDict(
					    [
					        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
					        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
					    ]	)
					if self.use_past:
							lowerCAmelCase__  ,			lowerCAmelCase__     :    List[str]					  =      self.num_layers
							for i in range(_SCREAMING_SNAKE_CASE	):
									lowerCAmelCase__     :    int					  =      {0: '''batch''', 2: '''past_sequence + sequence'''}
									lowerCAmelCase__     :    Optional[Any]					  =      {0: '''batch''', 2: '''past_sequence + sequence'''}
			else:
					lowerCAmelCase__     :    Any					  =      OrderedDict(
					    [
					        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
					        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
					        ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
					        ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
					    ]	)

			return common_inputs




	@property
	def 							UpperCAmelCase__(      self		:	List[str]	)-> Mapping[str, Mapping[int, str]]:
			if self.task in ["default", "seq2seq-lm"]:
					lowerCAmelCase__     :    str					  =      super().outputs
			else:
					lowerCAmelCase__     :    List[str]					  =      super(_SCREAMING_SNAKE_CASE	,      self	).outputs
					if self.use_past:
							lowerCAmelCase__  ,			lowerCAmelCase__     :    List[Any]					  =      self.num_layers
							for i in range(_SCREAMING_SNAKE_CASE	):
									lowerCAmelCase__     :    Optional[int]					  =      {0: '''batch''', 2: '''past_sequence + sequence'''}
									lowerCAmelCase__     :    Union[str, Any]					  =      {0: '''batch''', 2: '''past_sequence + sequence'''}
			return common_outputs




	def 							UpperCAmelCase__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	PreTrainedTokenizer	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	bool = False	,      _SCREAMING_SNAKE_CASE		:	Optional[TensorType] = None	,      )-> Mapping[str, Any]:
			lowerCAmelCase__     :    List[Any]					  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
			    _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)

			# Generate decoder inputs
			lowerCAmelCase__     :    Dict					  =      seq_length if not self.use_past else 1
			lowerCAmelCase__     :    Optional[Any]					  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
			    _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Any					  =      {F'decoder_{name}': tensor for name, tensor in decoder_inputs.items()}
			lowerCAmelCase__     :    Tuple					  =      dict(**_SCREAMING_SNAKE_CASE	,      **_SCREAMING_SNAKE_CASE	)

			if self.use_past:
					if not is_torch_available():
							raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''	)
					else:
							import torch
					lowerCAmelCase__  ,			lowerCAmelCase__     :    Optional[int]					  =      common_inputs['''input_ids'''].shape
					lowerCAmelCase__     :    Union[str, Any]					  =      common_inputs['''decoder_input_ids'''].shape[1]
					lowerCAmelCase__  ,			lowerCAmelCase__     :    str					  =      self.num_attention_heads
					lowerCAmelCase__     :    Dict					  =      (
					    batch,
					    num_encoder_attention_heads,
					    encoder_seq_length,
					    self._config.hidden_size // num_encoder_attention_heads,
					)
					lowerCAmelCase__     :    Optional[Any]					  =      decoder_seq_length + 3
					lowerCAmelCase__     :    str					  =      (
					    batch,
					    num_decoder_attention_heads,
					    decoder_past_length,
					    self._config.hidden_size // num_decoder_attention_heads,
					)

					lowerCAmelCase__     :    str					  =      torch.cat(
					    [common_inputs['''decoder_attention_mask'''], torch.ones(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)]	,      dim=1	)

					lowerCAmelCase__     :    Optional[int]					  =      []
					# If the number of encoder and decoder layers are present in the model configuration, both are considered
					lowerCAmelCase__  ,			lowerCAmelCase__     :    Tuple					  =      self.num_layers
					lowerCAmelCase__     :    str					  =      min(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)
					lowerCAmelCase__     :    Union[str, Any]					  =      max(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	) - min_num_layers
					lowerCAmelCase__     :    Dict					  =      '''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

					for _ in range(_SCREAMING_SNAKE_CASE	):
							common_inputs["past_key_values"].append(
							    (
							        torch.zeros(_SCREAMING_SNAKE_CASE	),
							        torch.zeros(_SCREAMING_SNAKE_CASE	),
							        torch.zeros(_SCREAMING_SNAKE_CASE	),
							        torch.zeros(_SCREAMING_SNAKE_CASE	),
							    )	)
					# TODO: test this.
					lowerCAmelCase__     :    Dict					  =      encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
					for _ in range(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
							common_inputs["past_key_values"].append((torch.zeros(_SCREAMING_SNAKE_CASE	), torch.zeros(_SCREAMING_SNAKE_CASE	))	)
			return common_inputs




	def 							UpperCAmelCase__(      self		:	Dict	,      _SCREAMING_SNAKE_CASE		:	PreTrainedTokenizer	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	bool = False	,      _SCREAMING_SNAKE_CASE		:	Optional[TensorType] = None	,      )-> Mapping[str, Any]:
			lowerCAmelCase__     :    Optional[Any]					  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
			    _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)

			if self.use_past:
					if not is_torch_available():
							raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''	)
					else:
							import torch
					lowerCAmelCase__  ,			lowerCAmelCase__     :    List[str]					  =      common_inputs['''input_ids'''].shape
					# Not using the same length for past_key_values
					lowerCAmelCase__     :    Any					  =      seqlen + 2
					lowerCAmelCase__  ,			lowerCAmelCase__     :    Union[str, Any]					  =      self.num_layers
					lowerCAmelCase__  ,			lowerCAmelCase__     :    Union[str, Any]					  =      self.num_attention_heads
					lowerCAmelCase__     :    Tuple					  =      (
					    batch,
					    num_encoder_attention_heads,
					    past_key_values_length,
					    self._config.hidden_size // num_encoder_attention_heads,
					)

					lowerCAmelCase__     :    Any					  =      common_inputs['''attention_mask'''].dtype
					lowerCAmelCase__     :    Union[str, Any]					  =      torch.cat(
					    [common_inputs['''attention_mask'''], torch.ones(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      dtype=_SCREAMING_SNAKE_CASE	)]	,      dim=1	)
					lowerCAmelCase__     :    int					  =      [
					    (torch.zeros(_SCREAMING_SNAKE_CASE	), torch.zeros(_SCREAMING_SNAKE_CASE	)) for _ in range(_SCREAMING_SNAKE_CASE	)
					]
			return common_inputs




	def 							UpperCAmelCase__(      self		:	Any	,      _SCREAMING_SNAKE_CASE		:	PreTrainedTokenizer	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	bool = False	,      _SCREAMING_SNAKE_CASE		:	Optional[TensorType] = None	,      )-> Mapping[str, Any]:
			# Copied from OnnxConfig.generate_dummy_inputs
			# Did not use super(OnnxConfigWithPast, self).generate_dummy_inputs for code clarity.
			# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
			lowerCAmelCase__     :    Any					  =      compute_effective_axis_dimension(
			    _SCREAMING_SNAKE_CASE	,      fixed_dimension=OnnxConfig.default_fixed_batch	,      num_token_to_add=0	)

			# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
			lowerCAmelCase__     :    List[Any]					  =      tokenizer.num_special_tokens_to_add(_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[str]					  =      compute_effective_axis_dimension(
			    _SCREAMING_SNAKE_CASE	,      fixed_dimension=OnnxConfig.default_fixed_sequence	,      num_token_to_add=_SCREAMING_SNAKE_CASE	)

			# Generate dummy inputs according to compute batch and sequence
			lowerCAmelCase__     :    int					  =      [''' '''.join([tokenizer.unk_token]	) * seq_length] * batch_size
			lowerCAmelCase__     :    Union[str, Any]					  =      dict(tokenizer(_SCREAMING_SNAKE_CASE	,      return_tensors=_SCREAMING_SNAKE_CASE	)	)
			return common_inputs




	def 							UpperCAmelCase__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	PreTrainedTokenizer	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	int = -1	,      _SCREAMING_SNAKE_CASE		:	bool = False	,      _SCREAMING_SNAKE_CASE		:	Optional[TensorType] = None	,      )-> Mapping[str, Any]:
			if self.task in ["default", "seq2seq-lm"]:
					lowerCAmelCase__     :    List[Any]					  =      self._generate_dummy_inputs_for_default_and_seqaseq_lm(
					    _SCREAMING_SNAKE_CASE	,      batch_size=_SCREAMING_SNAKE_CASE	,      seq_length=_SCREAMING_SNAKE_CASE	,      is_pair=_SCREAMING_SNAKE_CASE	,      framework=_SCREAMING_SNAKE_CASE	)

			elif self.task == "causal-lm":
					lowerCAmelCase__     :    Union[str, Any]					  =      self._generate_dummy_inputs_for_causal_lm(
					    _SCREAMING_SNAKE_CASE	,      batch_size=_SCREAMING_SNAKE_CASE	,      seq_length=_SCREAMING_SNAKE_CASE	,      is_pair=_SCREAMING_SNAKE_CASE	,      framework=_SCREAMING_SNAKE_CASE	)
			else:
					lowerCAmelCase__     :    Dict					  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
					    _SCREAMING_SNAKE_CASE	,      batch_size=_SCREAMING_SNAKE_CASE	,      seq_length=_SCREAMING_SNAKE_CASE	,      is_pair=_SCREAMING_SNAKE_CASE	,      framework=_SCREAMING_SNAKE_CASE	)

			return common_inputs




	def 							UpperCAmelCase__(      self		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	Dict	,      _SCREAMING_SNAKE_CASE		:	str	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	List[Any]	)-> Optional[int]:
			if self.task in ["default", "seq2seq-lm"]:
					lowerCAmelCase__     :    Tuple					  =      super()._flatten_past_key_values_(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)
			else:
					lowerCAmelCase__     :    List[str]					  =      super(_SCREAMING_SNAKE_CASE	,      self	)._flatten_past_key_values_(
					    _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	)








import copy

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


lowerCamelCase		=	logging.get_logger(__name__)

lowerCamelCase		=	{
    '''facebook/sam-vit-huge''': '''https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json''',
    '''facebook/sam-vit-large''': '''https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json''',
    '''facebook/sam-vit-base''': '''https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json''',
}





class       _a							(       _lowercase):




	def __init__(      self		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple=256	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=1024	,      _SCREAMING_SNAKE_CASE		:	List[Any]=16	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=16	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=4	,      _SCREAMING_SNAKE_CASE		:	Any="gelu"	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=1E-6	,      **_SCREAMING_SNAKE_CASE		:	List[Any]	,      )-> Tuple:
			super().__init__(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Any					  =      hidden_size
			lowerCAmelCase__     :    Tuple					  =      image_size
			lowerCAmelCase__     :    List[Any]					  =      patch_size
			lowerCAmelCase__     :    Any					  =      image_size // patch_size
			lowerCAmelCase__     :    Dict					  =      mask_input_channels
			lowerCAmelCase__     :    Dict					  =      num_point_embeddings
			lowerCAmelCase__     :    str					  =      hidden_act
			lowerCAmelCase__     :    List[Any]					  =      layer_norm_eps





class       _a							(       _lowercase):




	def __init__(      self		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=256	,      _SCREAMING_SNAKE_CASE		:	Dict="relu"	,      _SCREAMING_SNAKE_CASE		:	str=2048	,      _SCREAMING_SNAKE_CASE		:	List[Any]=2	,      _SCREAMING_SNAKE_CASE		:	Dict=8	,      _SCREAMING_SNAKE_CASE		:	str=2	,      _SCREAMING_SNAKE_CASE		:	Tuple=3	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=3	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=256	,      _SCREAMING_SNAKE_CASE		:	Dict=1E-6	,      **_SCREAMING_SNAKE_CASE		:	Any	,      )-> List[Any]:
			super().__init__(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[str]					  =      hidden_size
			lowerCAmelCase__     :    Union[str, Any]					  =      hidden_act
			lowerCAmelCase__     :    str					  =      mlp_dim
			lowerCAmelCase__     :    Optional[int]					  =      num_hidden_layers
			lowerCAmelCase__     :    int					  =      num_attention_heads
			lowerCAmelCase__     :    List[str]					  =      attention_downsample_rate
			lowerCAmelCase__     :    str					  =      num_multimask_outputs
			lowerCAmelCase__     :    Optional[int]					  =      iou_head_depth
			lowerCAmelCase__     :    Union[str, Any]					  =      iou_head_hidden_dim
			lowerCAmelCase__     :    Tuple					  =      layer_norm_eps





class       _a							(       _lowercase):




	def __init__(      self		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	int=768	,      _SCREAMING_SNAKE_CASE		:	str=256	,      _SCREAMING_SNAKE_CASE		:	int=12	,      _SCREAMING_SNAKE_CASE		:	Tuple=12	,      _SCREAMING_SNAKE_CASE		:	Dict=3	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=1024	,      _SCREAMING_SNAKE_CASE		:	Tuple=16	,      _SCREAMING_SNAKE_CASE		:	List[Any]="gelu"	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=1E-06	,      _SCREAMING_SNAKE_CASE		:	int=0.0	,      _SCREAMING_SNAKE_CASE		:	int=1E-10	,      _SCREAMING_SNAKE_CASE		:	List[Any]=True	,      _SCREAMING_SNAKE_CASE		:	Any=4.0	,      _SCREAMING_SNAKE_CASE		:	List[str]=True	,      _SCREAMING_SNAKE_CASE		:	int=True	,      _SCREAMING_SNAKE_CASE		:	List[str]=14	,      _SCREAMING_SNAKE_CASE		:	Dict=[2, 5, 8, 11]	,      _SCREAMING_SNAKE_CASE		:	List[Any]=128	,      _SCREAMING_SNAKE_CASE		:	Dict=None	,      **_SCREAMING_SNAKE_CASE		:	str	,      )-> Any:
			super().__init__(**_SCREAMING_SNAKE_CASE	)

			lowerCAmelCase__     :    Optional[Any]					  =      hidden_size
			lowerCAmelCase__     :    Any					  =      output_channels
			lowerCAmelCase__     :    Optional[int]					  =      num_hidden_layers
			lowerCAmelCase__     :    Dict					  =      num_attention_heads
			lowerCAmelCase__     :    List[Any]					  =      num_channels
			lowerCAmelCase__     :    int					  =      image_size
			lowerCAmelCase__     :    Tuple					  =      patch_size
			lowerCAmelCase__     :    Union[str, Any]					  =      hidden_act
			lowerCAmelCase__     :    List[str]					  =      layer_norm_eps
			lowerCAmelCase__     :    Any					  =      attention_dropout
			lowerCAmelCase__     :    int					  =      initializer_range
			lowerCAmelCase__     :    List[Any]					  =      qkv_bias
			lowerCAmelCase__     :    List[Any]					  =      mlp_ratio
			lowerCAmelCase__     :    List[Any]					  =      use_abs_pos
			lowerCAmelCase__     :    Union[str, Any]					  =      use_rel_pos
			lowerCAmelCase__     :    Optional[Any]					  =      window_size
			lowerCAmelCase__     :    Union[str, Any]					  =      global_attn_indexes
			lowerCAmelCase__     :    Union[str, Any]					  =      num_pos_feats
			lowerCAmelCase__     :    str					  =      int(hidden_size * mlp_ratio	) if mlp_dim is None else mlp_dim





class       _a							(       _lowercase):
	_a						:						Tuple   					=							'''sam'''
	_a						:						Optional[Any]   					=							True




	def __init__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Any=None	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=None	,      _SCREAMING_SNAKE_CASE		:	int=None	,      _SCREAMING_SNAKE_CASE		:	Tuple=0.02	,      **_SCREAMING_SNAKE_CASE		:	int	,      )-> Optional[int]:
			super().__init__(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Tuple					  =      vision_config if vision_config is not None else {}
			lowerCAmelCase__     :    List[str]					  =      prompt_encoder_config if prompt_encoder_config is not None else {}
			lowerCAmelCase__     :    List[str]					  =      mask_decoder_config if mask_decoder_config is not None else {}

			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    Any					  =      vision_config.to_dict()
			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    Any					  =      prompt_encoder_config.to_dict()
			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    List[Any]					  =      mask_decoder_config.to_dict()

			lowerCAmelCase__     :    Any					  =      SamVisionConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[Any]					  =      SamPromptEncoderConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Dict					  =      SamMaskDecoderConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[Any]					  =      initializer_range




	def 							UpperCAmelCase__(      self		:	Any	)-> int:
			lowerCAmelCase__     :    Optional[int]					  =      copy.deepcopy(self.__dict__	)
			lowerCAmelCase__     :    Any					  =      self.vision_config.to_dict()
			lowerCAmelCase__     :    Optional[Any]					  =      self.prompt_encoder_config.to_dict()
			lowerCAmelCase__     :    str					  =      self.mask_decoder_config.to_dict()
			lowerCAmelCase__     :    Any					  =      self.__class__.model_type
			return output




