
import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


_SCREAMING_SNAKE_CASE    :      Union[str, Any]          =			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE    :      int          =			{
    'SenseTime/deformable-detr': 'https://huggingface.co/sensetime/deformable-detr/resolve/main/config.json',
    # See all Deformable DETR models at https://huggingface.co/models?filter=deformable-detr
}







class  UpperCamelCase__		(    SCREAMING_SNAKE_CASE_   ):







	'''simple docstring'''
	_lowerCAmelCase							       =				"deformable_detr"
	_lowerCAmelCase							       =				{
	    "hidden_size": "d_model",
	    "num_attention_heads": "encoder_attention_heads",
	}





	def __init__(			self				,       UpperCamelCase__=True				,       UpperCamelCase__=None				,       UpperCamelCase__=3				,       UpperCamelCase__=300				,       UpperCamelCase__=1024				,       UpperCamelCase__=6				,       UpperCamelCase__=1024				,       UpperCamelCase__=8				,       UpperCamelCase__=6				,       UpperCamelCase__=1024				,       UpperCamelCase__=8				,       UpperCamelCase__=0.0				,       UpperCamelCase__=True				,       UpperCamelCase__="relu"				,       UpperCamelCase__=256				,       UpperCamelCase__=0.1				,       UpperCamelCase__=0.0				,       UpperCamelCase__=0.0				,       UpperCamelCase__=0.0_2				,       UpperCamelCase__=1.0				,       UpperCamelCase__=True				,       UpperCamelCase__=False				,       UpperCamelCase__="sine"				,       UpperCamelCase__="resnet50"				,       UpperCamelCase__=True				,       UpperCamelCase__=False				,       UpperCamelCase__=4				,       UpperCamelCase__=4				,       UpperCamelCase__=4				,       UpperCamelCase__=False				,       UpperCamelCase__=300				,       UpperCamelCase__=False				,       UpperCamelCase__=1				,       UpperCamelCase__=5				,       UpperCamelCase__=2				,       UpperCamelCase__=1				,       UpperCamelCase__=1				,       UpperCamelCase__=5				,       UpperCamelCase__=2				,       UpperCamelCase__=0.1				,       UpperCamelCase__=0.2_5				,       UpperCamelCase__=False				,       **UpperCamelCase__				,       ):
					if backbone_config is not None and use_timm_backbone:
									raise ValueError('''You can\'t specify both `backbone_config` and `use_timm_backbone`.'''		)

					if not use_timm_backbone:
									if backbone_config is None:
													logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''		)
													A__  :	int         =							CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']		)
									elif isinstance(UpperCamelCase__				,       UpperCamelCase__		):
													A__  :	Union[str, Any]         =							backbone_config.get('''model_type'''		)
													A__  :	Union[str, Any]         =							CONFIG_MAPPING[backbone_model_type]
													A__  :	Optional[int]         =							config_class.from_dict(UpperCamelCase__		)
					A__  :	Tuple         =							use_timm_backbone
					A__  :	int         =							backbone_config
					A__  :	List[Any]         =							num_channels
					A__  :	List[Any]         =							num_queries
					A__  :	str         =							max_position_embeddings
					A__  :	Tuple         =							d_model
					A__  :	int         =							encoder_ffn_dim
					A__  :	Union[str, Any]         =							encoder_layers
					A__  :	Optional[Any]         =							encoder_attention_heads
					A__  :	List[Any]         =							decoder_ffn_dim
					A__  :	Tuple         =							decoder_layers
					A__  :	Optional[Any]         =							decoder_attention_heads
					A__  :	List[str]         =							dropout
					A__  :	str         =							attention_dropout
					A__  :	List[Any]         =							activation_dropout
					A__  :	Any         =							activation_function
					A__  :	Optional[Any]         =							init_std
					A__  :	Union[str, Any]         =							init_xavier_std
					A__  :	Union[str, Any]         =							encoder_layerdrop
					A__  :	Optional[int]         =							auxiliary_loss
					A__  :	str         =							position_embedding_type
					A__  :	List[Any]         =							backbone
					A__  :	Optional[Any]         =							use_pretrained_backbone
					A__  :	Any         =							dilation
					# deformable attributes
					A__  :	List[Any]         =							num_feature_levels
					A__  :	List[str]         =							encoder_n_points
					A__  :	int         =							decoder_n_points
					A__  :	List[Any]         =							two_stage
					A__  :	Dict         =							two_stage_num_proposals
					A__  :	Optional[int]         =							with_box_refine
					if two_stage is True and with_box_refine is False:
									raise ValueError('''If two_stage is True, with_box_refine must be True.'''		)
					# Hungarian matcher
					A__  :	List[str]         =							class_cost
					A__  :	List[Any]         =							bbox_cost
					A__  :	Any         =							giou_cost
					# Loss coefficients
					A__  :	List[str]         =							mask_loss_coefficient
					A__  :	Union[str, Any]         =							dice_loss_coefficient
					A__  :	List[Any]         =							bbox_loss_coefficient
					A__  :	Tuple         =							giou_loss_coefficient
					A__  :	Optional[Any]         =							eos_coefficient
					A__  :	List[Any]         =							focal_alpha
					A__  :	List[str]         =							disable_custom_kernels
					super().__init__(is_encoder_decoder=UpperCamelCase__				,       **UpperCamelCase__		)





	@property
	def   __snake_case				(			self		):
					return self.encoder_attention_heads





	@property
	def   __snake_case				(			self		):
					return self.d_model





	def   __snake_case				(			self		):
					A__  :	List[str]         =							copy.deepcopy(self.__dict__		)
					if self.backbone_config is not None:
									A__  :	Tuple         =							self.backbone_config.to_dict()
					A__  :	Optional[int]         =							self.__class__.model_type
					return output

from dataclasses import asdict, dataclass
from typing import Optional

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


_SCREAMING_SNAKE_CASE    :      Dict          =			logging.get_logger(__name__)

# TODO Update this
_SCREAMING_SNAKE_CASE    :      Optional[int]          =			{
    'facebook/esm-1b': 'https://huggingface.co/facebook/esm-1b/resolve/main/config.json',
    # See all ESM models at https://huggingface.co/models?filter=esm
}







class  UpperCamelCase__		(    SCREAMING_SNAKE_CASE_   ):







	'''simple docstring'''
	_lowerCAmelCase							       =				"esm"





	def __init__(			self				,       UpperCamelCase__=None				,       UpperCamelCase__=None				,       UpperCamelCase__=None				,       UpperCamelCase__=768				,       UpperCamelCase__=12				,       UpperCamelCase__=12				,       UpperCamelCase__=3072				,       UpperCamelCase__=0.1				,       UpperCamelCase__=0.1				,       UpperCamelCase__=1026				,       UpperCamelCase__=0.0_2				,       UpperCamelCase__=1e-12				,       UpperCamelCase__="absolute"				,       UpperCamelCase__=True				,       UpperCamelCase__=None				,       UpperCamelCase__=False				,       UpperCamelCase__=False				,       UpperCamelCase__=None				,       UpperCamelCase__=None				,       **UpperCamelCase__				,       ):
					super().__init__(pad_token_id=UpperCamelCase__				,       mask_token_id=UpperCamelCase__				,       **UpperCamelCase__		)

					A__  :	Optional[Any]         =							vocab_size
					A__  :	int         =							hidden_size
					A__  :	List[str]         =							num_hidden_layers
					A__  :	Tuple         =							num_attention_heads
					A__  :	str         =							intermediate_size
					A__  :	List[str]         =							hidden_dropout_prob
					A__  :	Optional[Any]         =							attention_probs_dropout_prob
					A__  :	int         =							max_position_embeddings
					A__  :	List[str]         =							initializer_range
					A__  :	List[Any]         =							layer_norm_eps
					A__  :	int         =							position_embedding_type
					A__  :	Optional[Any]         =							use_cache
					A__  :	Optional[int]         =							emb_layer_norm_before
					A__  :	List[str]         =							token_dropout
					A__  :	Tuple         =							is_folding_model
					if is_folding_model:
									if esmfold_config is None:
													logger.info('''No esmfold_config supplied for folding model, using default values.'''		)
													A__  :	List[Any]         =							EsmFoldConfig()
									elif isinstance(UpperCamelCase__				,       UpperCamelCase__		):
													A__  :	Optional[int]         =							EsmFoldConfig(**UpperCamelCase__		)
									A__  :	int         =							esmfold_config
									if vocab_list is None:
													logger.warning('''No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!'''		)
													A__  :	Any         =							get_default_vocab_list()
									else:
													A__  :	Dict         =							vocab_list
					else:
									A__  :	Optional[Any]         =							None
									A__  :	Tuple         =							None
					if self.esmfold_config is not None and getattr(self.esmfold_config				,       '''use_esm_attn_map'''				,       UpperCamelCase__		):
									raise ValueError('''The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!'''		)





	def   __snake_case				(			self		):
					A__  :	Optional[int]         =							super().to_dict()
					if isinstance(self.esmfold_config				,       UpperCamelCase__		):
									A__  :	Dict         =							self.esmfold_config.to_dict()
					return output







@dataclass
class  UpperCamelCase__		:







	'''simple docstring'''
	_lowerCAmelCase							       =				None
	_lowerCAmelCase							       =				True
	_lowerCAmelCase							       =				False
	_lowerCAmelCase							       =				False
	_lowerCAmelCase							       =				False
	_lowerCAmelCase							       =				0

	_lowerCAmelCase							       =				True
	_lowerCAmelCase							       =				False

	_lowerCAmelCase							       =				128
	_lowerCAmelCase							       =				None





	def   __snake_case				(			self		):
					if self.trunk is None:
									A__  :	Tuple         =							TrunkConfig()
					elif isinstance(self.trunk				,       UpperCamelCase__		):
									A__  :	List[Any]         =							TrunkConfig(**self.trunk		)





	def   __snake_case				(			self		):
					A__  :	Optional[int]         =							asdict(self		)
					A__  :	int         =							self.trunk.to_dict()
					return output







@dataclass
class  UpperCamelCase__		:







	'''simple docstring'''
	_lowerCAmelCase							       =				48
	_lowerCAmelCase							       =				1_024
	_lowerCAmelCase							       =				128
	_lowerCAmelCase							       =				32
	_lowerCAmelCase							       =				32
	_lowerCAmelCase							       =				32
	_lowerCAmelCase							       =				0
	_lowerCAmelCase							       =				0
	_lowerCAmelCase							       =				False
	_lowerCAmelCase							       =				4
	_lowerCAmelCase							       =				128
	_lowerCAmelCase							       =				None





	def   __snake_case				(			self		):
					if self.structure_module is None:
									A__  :	str         =							StructureModuleConfig()
					elif isinstance(self.structure_module				,       UpperCamelCase__		):
									A__  :	str         =							StructureModuleConfig(**self.structure_module		)

					if self.max_recycles <= 0:
									raise ValueError(F"`max_recycles` should be positive, got {self.max_recycles}."		)
					if self.sequence_state_dim % self.sequence_state_dim != 0:
									raise ValueError(
									    '''`sequence_state_dim` should be a round multiple of `sequence_state_dim`, got'''
									    F" {self.sequence_state_dim} and {self.sequence_state_dim}."		)
					if self.pairwise_state_dim % self.pairwise_state_dim != 0:
									raise ValueError(
									    '''`pairwise_state_dim` should be a round multiple of `pairwise_state_dim`, got'''
									    F" {self.pairwise_state_dim} and {self.pairwise_state_dim}."		)

					A__  :	Tuple         =							self.sequence_state_dim // self.sequence_head_width
					A__  :	int         =							self.pairwise_state_dim // self.pairwise_head_width

					if self.sequence_state_dim != sequence_num_heads * self.sequence_head_width:
									raise ValueError(
									    '''`sequence_state_dim` should be equal to `sequence_num_heads * sequence_head_width, got'''
									    F" {self.sequence_state_dim} != {sequence_num_heads} * {self.sequence_head_width}."		)
					if self.pairwise_state_dim != pairwise_num_heads * self.pairwise_head_width:
									raise ValueError(
									    '''`pairwise_state_dim` should be equal to `pairwise_num_heads * pairwise_head_width, got'''
									    F" {self.pairwise_state_dim} != {pairwise_num_heads} * {self.pairwise_head_width}."		)
					if self.pairwise_state_dim % 2 != 0:
									raise ValueError(F"`pairwise_state_dim` should be even, got {self.pairwise_state_dim}."		)

					if self.dropout >= 0.4:
									raise ValueError(F"`dropout` should not be greater than 0.4, got {self.dropout}."		)





	def   __snake_case				(			self		):
					A__  :	List[Any]         =							asdict(self		)
					A__  :	Optional[int]         =							self.structure_module.to_dict()
					return output







@dataclass
class  UpperCamelCase__		:







	'''simple docstring'''
	_lowerCAmelCase							       =				384
	_lowerCAmelCase							       =				128
	_lowerCAmelCase							       =				16
	_lowerCAmelCase							       =				128
	_lowerCAmelCase							       =				12
	_lowerCAmelCase							       =				4
	_lowerCAmelCase							       =				8
	_lowerCAmelCase							       =				0.1
	_lowerCAmelCase							       =				8
	_lowerCAmelCase							       =				1
	_lowerCAmelCase							       =				2
	_lowerCAmelCase							       =				7
	_lowerCAmelCase							       =				10
	_lowerCAmelCase							       =				1e-8
	_lowerCAmelCase							       =				1e5





	def   __snake_case				(			self		):
					return asdict(self		)




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

				"""simple docstring"""







				return (
				    "<cls>",
				    "<pad>",
				    "<eos>",
				    "<unk>",
				    "L",
				    "A",
				    "G",
				    "V",
				    "S",
				    "E",
				    "R",
				    "T",
				    "I",
				    "D",
				    "P",
				    "K",
				    "Q",
				    "N",
				    "F",
				    "Y",
				    "M",
				    "H",
				    "W",
				    "C",
				    "X",
				    "B",
				    "U",
				    "Z",
				    "O",
				    ".",
				    "-",
				    "<null_1>",
				    "<mask>",
				)