
from dataclasses import asdict, dataclass
from typing import Optional

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


__lowerCAmelCase					:			Optional[int]			      =		logging.get_logger(__name__)

# TODO Update this
__lowerCAmelCase					:			List[Any]			      =		{
    '''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 						__lowerCAmelCase	(	SCREAMING_SNAKE_CASE__      ):



      """simple docstring"""







      A__	:			Any        =    '''esm'''




      def __init__(      self		:       Union[str, Any]				,       _snake_case		:       List[str]=None				,       _snake_case		:       List[str]=None				,       _snake_case		:       Dict=None				,       _snake_case		:       List[Any]=768				,       _snake_case		:       int=12				,       _snake_case		:       Optional[Any]=12				,       _snake_case		:       str=3072				,       _snake_case		:       Optional[int]=0.1				,       _snake_case		:       Optional[int]=0.1				,       _snake_case		:       List[Any]=1026				,       _snake_case		:       List[str]=0.02				,       _snake_case		:       Union[str, Any]=1E-1_2				,       _snake_case		:       Optional[int]="absolute"				,       _snake_case		:       Optional[Any]=True				,       _snake_case		:       Tuple=None				,       _snake_case		:       str=False				,       _snake_case		:       Dict=False				,       _snake_case		:       Optional[Any]=None				,       _snake_case		:       str=None				,       **_snake_case		:       Dict				,       ):
          super().__init__(pad_token_id=_lowercase				,       mask_token_id=_lowercase				,       **_lowercase				)

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




      def 		snake_case_			(      self		:       Optional[Any]				):
          __lowercase		:			Optional[Any]	    =       super().to_dict()
          if isinstance(self.esmfold_config				,       _lowercase				):
              __lowercase		:			Any	    =       self.esmfold_config.to_dict()
          return output






@dataclass
class 						__lowerCAmelCase	:



      """simple docstring"""







      A__	:			List[str]        =    None
      A__	:			Optional[Any]        =    True
      A__	:			Any        =    False
      A__	:			int        =    False
      A__	:			Union[str, Any]        =    False
      A__	:			Any        =    0

      A__	:			Any        =    True
      A__	:			int        =    False

      A__	:			Dict        =    1_2_8
      A__	:			Union[str, Any]        =    None




      def 		snake_case_			(      self		:       List[str]				):

          if self.trunk is None:
              __lowercase		:			Optional[Any]	    =       TrunkConfig()
          elif isinstance(self.trunk				,       _lowercase				):
              __lowercase		:			Optional[Any]	    =       TrunkConfig(**self.trunk				)




      def 		snake_case_			(      self		:       Optional[int]				):
          __lowercase		:			int	    =       asdict(self				)
          __lowercase		:			List[Any]	    =       self.trunk.to_dict()
          return output






@dataclass
class 						__lowerCAmelCase	:



      """simple docstring"""







      A__	:			Optional[Any]        =    4_8
      A__	:			Any        =    1_0_2_4
      A__	:			Tuple        =    1_2_8
      A__	:			Optional[Any]        =    3_2
      A__	:			Tuple        =    3_2
      A__	:			List[str]        =    3_2
      A__	:			Dict        =    0
      A__	:			Optional[int]        =    0
      A__	:			Optional[Any]        =    False
      A__	:			Dict        =    4
      A__	:			Optional[int]        =    1_2_8
      A__	:			int        =    None




      def 		snake_case_			(      self		:       Dict				):

          if self.structure_module is None:
              __lowercase		:			List[str]	    =       StructureModuleConfig()
          elif isinstance(self.structure_module				,       _lowercase				):
              __lowercase		:			Union[str, Any]	    =       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}.'				)

          __lowercase		:			List[Any]	    =       self.sequence_state_dim // self.sequence_head_width
          __lowercase		:			Tuple	    =       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		:       Dict				):
          __lowercase		:			Optional[int]	    =       asdict(self				)
          __lowercase		:			int	    =       self.structure_module.to_dict()
          return output






@dataclass
class 						__lowerCAmelCase	:



      """simple docstring"""







      A__	:			List[Any]        =    3_8_4
      A__	:			Any        =    1_2_8
      A__	:			Union[str, Any]        =    1_6
      A__	:			int        =    1_2_8
      A__	:			str        =    1_2
      A__	:			str        =    4
      A__	:			Any        =    8
      A__	:			Dict        =    0.1
      A__	:			Union[str, Any]        =    8
      A__	:			Any        =    1
      A__	:			Dict        =    2
      A__	:			Tuple        =    7
      A__	:			List[Any]        =    1_0
      A__	:			Union[str, Any]        =    1E-8
      A__	:			int        =    1E5




      def 		snake_case_			(      self		:       Union[str, Any]				):
          return asdict(self				)






def     UpperCAmelCase_  (						) ->						List[str]:
    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>",
    )




import warnings
from collections import OrderedDict
from typing import Mapping

from packaging import version

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


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

__lowerCAmelCase					:			Optional[int]			      =		{
    "nvidia/segformer-b0-finetuned-ade-512-512": (
        "https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512/resolve/main/config.json"
    ),
    # See all SegFormer models at https://huggingface.co/models?filter=segformer
}


class 						__lowerCAmelCase	(	lowerCAmelCase_      ):



      """simple docstring"""







      A__	:			Dict        =    '''segformer'''




      def __init__(      self		:       Optional[Any]				,       _snake_case		:       List[str]=3				,       _snake_case		:       Union[str, Any]=4				,       _snake_case		:       str=[2, 2, 2, 2]				,       _snake_case		:       Dict=[8, 4, 2, 1]				,       _snake_case		:       List[Any]=[32, 64, 160, 256]				,       _snake_case		:       Dict=[7, 3, 3, 3]				,       _snake_case		:       List[Any]=[4, 2, 2, 2]				,       _snake_case		:       Tuple=[1, 2, 5, 8]				,       _snake_case		:       Optional[Any]=[4, 4, 4, 4]				,       _snake_case		:       Optional[int]="gelu"				,       _snake_case		:       Optional[int]=0.0				,       _snake_case		:       Optional[int]=0.0				,       _snake_case		:       int=0.1				,       _snake_case		:       Any=0.02				,       _snake_case		:       Optional[int]=0.1				,       _snake_case		:       Union[str, Any]=1E-6				,       _snake_case		:       Tuple=256				,       _snake_case		:       str=255				,       **_snake_case		:       Any				,       ):
          super().__init__(**_snake_case				)

          if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
              warnings.warn(
                  '''Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be'''
                  ''' removed, as the behaviour will default to that of reshape_last_stage = True.'''				,       _snake_case				,       )

          __lowercase		:			Any	    =       num_channels
          __lowercase		:			Optional[Any]	    =       num_encoder_blocks
          __lowercase		:			List[str]	    =       depths
          __lowercase		:			str	    =       sr_ratios
          __lowercase		:			List[str]	    =       hidden_sizes
          __lowercase		:			List[str]	    =       patch_sizes
          __lowercase		:			Dict	    =       strides
          __lowercase		:			Optional[int]	    =       mlp_ratios
          __lowercase		:			List[str]	    =       num_attention_heads
          __lowercase		:			Optional[int]	    =       hidden_act
          __lowercase		:			List[Any]	    =       hidden_dropout_prob
          __lowercase		:			Optional[Any]	    =       attention_probs_dropout_prob
          __lowercase		:			List[Any]	    =       classifier_dropout_prob
          __lowercase		:			str	    =       initializer_range
          __lowercase		:			Optional[int]	    =       drop_path_rate
          __lowercase		:			List[str]	    =       layer_norm_eps
          __lowercase		:			List[str]	    =       decoder_hidden_size
          __lowercase		:			Union[str, Any]	    =       kwargs.get('''reshape_last_stage'''				,       _snake_case				)
          __lowercase		:			str	    =       semantic_loss_ignore_index






class 						__lowerCAmelCase	(	lowerCAmelCase_      ):



      """simple docstring"""







      A__	:			Union[str, Any]        =    version.parse('''1.11'''      )




      @property
      def 		snake_case_			(      self		:       Dict				):
          return OrderedDict(
              [
                  ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
              ]				)




      @property
      def 		snake_case_			(      self		:       int				):
          return 1E-4




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


