




"""simple docstring"""






from dataclasses import asdict, dataclass
from typing import Optional

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


UpperCamelCase__						=			logging.get_logger(__name__)

# TODO Update this
UpperCamelCase__						=			{
    '''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   a__			(       UpperCamelCase_  ):
						snake_case__             = '''esm'''





						def __init__(							self      :	List[str]     ,a__      :	Dict=None     ,a__      :	List[str]=None     ,a__      :	str=None     ,a__      :	int=768     ,a__      :	Optional[int]=12     ,a__      :	Tuple=12     ,a__      :	Any=3072     ,a__      :	int=0.1     ,a__      :	str=0.1     ,a__      :	List[Any]=1026     ,a__      :	int=0.02     ,a__      :	List[str]=1E-12     ,a__      :	Tuple="absolute"     ,a__      :	Optional[int]=True     ,a__      :	Optional[int]=None     ,a__      :	List[str]=False     ,a__      :	List[Any]=False     ,a__      :	str=None     ,a__      :	int=None     ,**a__      :	List[str]     ,)						->       List[str]:




											"""simple docstring"""







											super().__init__(pad_token_id=a__     ,mask_token_id=a__     ,**a__)

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







						def       __UpperCamelCase     (							self      :	Tuple)						->       Tuple:




											"""simple docstring"""







											_lowerCAmelCase:Optional[int]									=  super().to_dict()
											if isinstance(self.esmfold_config     ,a__):
																_lowerCAmelCase:Dict									=  self.esmfold_config.to_dict()
											return output




@dataclass
class   a__			:
						snake_case__             = None
						snake_case__             = True
						snake_case__             = False
						snake_case__             = False
						snake_case__             = False
						snake_case__             = 0

						snake_case__             = True
						snake_case__             = False

						snake_case__             = 1_2_8
						snake_case__             = None





						def       __UpperCamelCase     (							self      :	str)						->       Any:




											"""simple docstring"""







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







						def       __UpperCamelCase     (							self      :	Dict)						->       str:




											"""simple docstring"""







											_lowerCAmelCase:Dict									=  asdict(self)
											_lowerCAmelCase:List[str]									=  self.trunk.to_dict()
											return output




@dataclass
class   a__			:
						snake_case__             = 4_8
						snake_case__             = 1_0_2_4
						snake_case__             = 1_2_8
						snake_case__             = 3_2
						snake_case__             = 3_2
						snake_case__             = 3_2
						snake_case__             = 0
						snake_case__             = 0
						snake_case__             = False
						snake_case__             = 4
						snake_case__             = 1_2_8
						snake_case__             = None





						def       __UpperCamelCase     (							self      :	Dict)						->       Optional[int]:




											"""simple docstring"""







											if self.structure_module is None:
																_lowerCAmelCase:Any									=  StructureModuleConfig()
											elif isinstance(self.structure_module     ,a__):
																_lowerCAmelCase:Tuple									=  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}.')

											_lowerCAmelCase:Optional[Any]									=  self.sequence_state_dim // self.sequence_head_width
											_lowerCAmelCase:List[Any]									=  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       __UpperCamelCase     (							self      :	Dict)						->       Tuple:




											"""simple docstring"""







											_lowerCAmelCase:Dict									=  asdict(self)
											_lowerCAmelCase:str									=  self.structure_module.to_dict()
											return output




@dataclass
class   a__			:
						snake_case__             = 3_8_4
						snake_case__             = 1_2_8
						snake_case__             = 1_6
						snake_case__             = 1_2_8
						snake_case__             = 1_2
						snake_case__             = 4
						snake_case__             = 8
						snake_case__             = 0.1
						snake_case__             = 8
						snake_case__             = 1
						snake_case__             = 2
						snake_case__             = 7
						snake_case__             = 1_0
						snake_case__             = 1E-8
						snake_case__             = 1E5





						def       __UpperCamelCase     (							self      :	Dict)						->       Any:




											"""simple docstring"""







											return asdict(self)





def 							UpperCAmelCase		(		):
					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>",
					)












"""simple docstring"""






from argparse import ArgumentParser

from .add_new_model import AddNewModelCommand
from .add_new_model_like import AddNewModelLikeCommand
from .convert import ConvertCommand
from .download import DownloadCommand
from .env import EnvironmentCommand
from .lfs import LfsCommands
from .pt_to_tf import PTtoTFCommand
from .run import RunCommand
from .serving import ServeCommand
from .user import UserCommands





def 							UpperCAmelCase		(		):
					_lowerCAmelCase:List[Any]									=  ArgumentParser('''Transformers CLI tool'''      ,       usage='''transformers-cli <command> [<args>]'''    )
					_lowerCAmelCase:Union[str, Any]									=  parser.add_subparsers(help='''transformers-cli command helpers'''    )

					# Register commands
					ConvertCommand.register_subcommand(snake_case    )
					DownloadCommand.register_subcommand(snake_case    )
					EnvironmentCommand.register_subcommand(snake_case    )
					RunCommand.register_subcommand(snake_case    )
					ServeCommand.register_subcommand(snake_case    )
					UserCommands.register_subcommand(snake_case    )
					AddNewModelCommand.register_subcommand(snake_case    )
					AddNewModelLikeCommand.register_subcommand(snake_case    )
					LfsCommands.register_subcommand(snake_case    )
					PTtoTFCommand.register_subcommand(snake_case    )

					# Let's go
					_lowerCAmelCase:Union[str, Any]									=  parser.parse_args()

					if not hasattr(snake_case      ,       '''func'''    ):
										parser.print_help()
										exit(1    )

					# Run
					_lowerCAmelCase:Any									=  args.func(snake_case    )
					service.run()


if __name__ == "__main__":
				main()






