



'''simple docstring'''






from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


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

# General docstring
UpperCamelCase__:   int								=			"RegNetConfig"

# Base docstring
UpperCamelCase__:   Optional[int]								=			"facebook/regnet-y-040"
UpperCamelCase__:   List[str]								=			[1, 1088, 7, 7]

# Image classification docstring
UpperCamelCase__:   Dict								=			"facebook/regnet-y-040"
UpperCamelCase__:   Union[str, Any]								=			"tabby, tabby cat"

UpperCamelCase__:   List[str]								=			[
    "facebook/regnet-y-040",
    # See all regnet models at https://huggingface.co/models?filter=regnet
]

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     Tuple		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int = 3		,			__snake_case			:     int = 1		,			__snake_case			:     int = 1		,			__snake_case			:     Optional[str] = "relu"		,			)			->		List[Any]:
								super().__init__()
								UpperCAmelCase :       Tuple 							=		nn.Convad(
								    __snake_case		,			__snake_case		,			kernel_size=__snake_case		,			stride=__snake_case		,			padding=kernel_size // 2		,			groups=__snake_case		,			bias=__snake_case		,			)
								UpperCAmelCase :       int 							=		nn.BatchNormad(__snake_case		)
								UpperCAmelCase :       List[str] 							=		ACTaFN[activation] if activation is not None else nn.Identity()







	def      A	(						self			:     int		,			__snake_case			:     Any		)			->		Tuple:
								UpperCAmelCase :       str 							=		self.convolution(__snake_case		)
								UpperCAmelCase :       Optional[int] 							=		self.normalization(__snake_case		)
								UpperCAmelCase :       List[Any] 							=		self.activation(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     Dict		,			__snake_case			:     RegNetConfig		)			->		str:
								super().__init__()
								UpperCAmelCase :       Optional[Any] 							=		RegNetConvLayer(
								    config.num_channels		,			config.embedding_size		,			kernel_size=3		,			stride=2		,			activation=config.hidden_act		)
								UpperCAmelCase :       Optional[Any] 							=		config.num_channels







	def      A	(						self			:     Union[str, Any]		,			__snake_case			:     Tuple		)			->		Tuple:
								UpperCAmelCase :       List[Any] 							=		pixel_values.shape[1]
								if num_channels != self.num_channels:
															raise ValueError(
															    '''Make sure that the channel dimension of the pixel values match with the one set in the configuration.'''		)
								UpperCAmelCase :       List[str] 							=		self.embedder(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     Any		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int = 2		)			->		Optional[Any]:
								super().__init__()
								UpperCAmelCase :       str 							=		nn.Convad(__snake_case		,			__snake_case		,			kernel_size=1		,			stride=__snake_case		,			bias=__snake_case		)
								UpperCAmelCase :       List[Any] 							=		nn.BatchNormad(__snake_case		)







	def      A	(						self			:     Any		,			__snake_case			:     Tensor		)			->		Tensor:
								UpperCAmelCase :       int 							=		self.convolution(__snake_case		)
								UpperCAmelCase :       Union[str, Any] 							=		self.normalization(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     List[Any]		,			__snake_case			:     int		,			__snake_case			:     int		)			->		Tuple:
								super().__init__()

								UpperCAmelCase :       Dict 							=		nn.AdaptiveAvgPoolad((1, 1)		)
								UpperCAmelCase :       Any 							=		nn.Sequential(
								    nn.Convad(__snake_case		,			__snake_case		,			kernel_size=1		)		,			nn.ReLU()		,			nn.Convad(__snake_case		,			__snake_case		,			kernel_size=1		)		,			nn.Sigmoid()		,			)







	def      A	(						self			:     str		,			__snake_case			:     Optional[int]		)			->		Optional[int]:
								# b c h w -> b c 1 1
								UpperCAmelCase :       str 							=		self.pooler(__snake_case		)
								UpperCAmelCase :       Optional[int] 							=		self.attention(__snake_case		)
								UpperCAmelCase :       int 							=		hidden_state * attention
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     str		,			__snake_case			:     RegNetConfig		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int = 1		)			->		Any:
								super().__init__()
								UpperCAmelCase :       int 							=		in_channels != out_channels or stride != 1
								UpperCAmelCase :       Union[str, Any] 							=		max(1		,			out_channels // config.groups_width		)
								UpperCAmelCase :       str 							=		(
								    RegNetShortCut(__snake_case		,			__snake_case		,			stride=__snake_case		) if should_apply_shortcut else nn.Identity()
								)
								UpperCAmelCase :       Union[str, Any] 							=		nn.Sequential(
								    RegNetConvLayer(__snake_case		,			__snake_case		,			kernel_size=1		,			activation=config.hidden_act		)		,			RegNetConvLayer(__snake_case		,			__snake_case		,			stride=__snake_case		,			groups=__snake_case		,			activation=config.hidden_act		)		,			RegNetConvLayer(__snake_case		,			__snake_case		,			kernel_size=1		,			activation=__snake_case		)		,			)
								UpperCAmelCase :       Optional[int] 							=		ACTaFN[config.hidden_act]







	def      A	(						self			:     List[Any]		,			__snake_case			:     Any		)			->		Union[str, Any]:
								UpperCAmelCase :       Dict 							=		hidden_state
								UpperCAmelCase :       int 							=		self.layer(__snake_case		)
								UpperCAmelCase :       Union[str, Any] 							=		self.shortcut(__snake_case		)
								hidden_state += residual
								UpperCAmelCase :       str 							=		self.activation(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     Optional[Any]		,			__snake_case			:     RegNetConfig		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int = 1		)			->		List[str]:
								super().__init__()
								UpperCAmelCase :       Any 							=		in_channels != out_channels or stride != 1
								UpperCAmelCase :       List[str] 							=		max(1		,			out_channels // config.groups_width		)
								UpperCAmelCase :       List[str] 							=		(
								    RegNetShortCut(__snake_case		,			__snake_case		,			stride=__snake_case		) if should_apply_shortcut else nn.Identity()
								)
								UpperCAmelCase :       int 							=		nn.Sequential(
								    RegNetConvLayer(__snake_case		,			__snake_case		,			kernel_size=1		,			activation=config.hidden_act		)		,			RegNetConvLayer(__snake_case		,			__snake_case		,			stride=__snake_case		,			groups=__snake_case		,			activation=config.hidden_act		)		,			RegNetSELayer(__snake_case		,			reduced_channels=int(round(in_channels / 4		)		)		)		,			RegNetConvLayer(__snake_case		,			__snake_case		,			kernel_size=1		,			activation=__snake_case		)		,			)
								UpperCAmelCase :       List[Any] 							=		ACTaFN[config.hidden_act]







	def      A	(						self			:     Dict		,			__snake_case			:     Any		)			->		int:
								UpperCAmelCase :       List[str] 							=		hidden_state
								UpperCAmelCase :       Optional[int] 							=		self.layer(__snake_case		)
								UpperCAmelCase :       Tuple 							=		self.shortcut(__snake_case		)
								hidden_state += residual
								UpperCAmelCase :       Any 							=		self.activation(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     Union[str, Any]		,			__snake_case			:     RegNetConfig		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int = 2		,			__snake_case			:     int = 2		,			)			->		int:
								super().__init__()

								UpperCAmelCase :       Any 							=		RegNetXLayer if config.layer_type == '''x''' else RegNetYLayer

								UpperCAmelCase :       str 							=		nn.Sequential(
								    # downsampling is done in the first layer with stride of 2
								    layer(
								        __snake_case		,			__snake_case		,			__snake_case		,			stride=__snake_case		,			)		,			*[layer(__snake_case		,			__snake_case		,			__snake_case		) for _ in range(depth - 1		)]		,			)







	def      A	(						self			:     List[str]		,			__snake_case			:     str		)			->		Any:
								UpperCAmelCase :       int 							=		self.layers(__snake_case		)
								return hidden_state

class 				SCREAMING_SNAKE_CASE(							nn.Module			):







	"""simple docstring"""






	def __init__(						self			:     List[Any]		,			__snake_case			:     RegNetConfig		)			->		Dict:
								super().__init__()
								UpperCAmelCase :       Optional[Any] 							=		nn.ModuleList([]		)
								# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
								self.stages.append(
								    RegNetStage(
								        __snake_case		,			config.embedding_size		,			config.hidden_sizes[0]		,			stride=2 if config.downsample_in_first_stage else 1		,			depth=config.depths[0]		,			)		)
								UpperCAmelCase :       str 							=		zip(config.hidden_sizes		,			config.hidden_sizes[1:]		)
								for (in_channels, out_channels), depth in zip(__snake_case		,			config.depths[1:]		):
															self.stages.append(RegNetStage(__snake_case		,			__snake_case		,			__snake_case		,			depth=__snake_case		)		)







	def      A	(						self			:     Dict		,			__snake_case			:     Tensor		,			__snake_case			:     bool = False		,			__snake_case			:     bool = True		)			->		BaseModelOutputWithNoAttention:
								UpperCAmelCase :       Any 							=		() if output_hidden_states else None

								for stage_module in self.stages:
															if output_hidden_states:
																						UpperCAmelCase :       str 							=		hidden_states + (hidden_state,)

															UpperCAmelCase :       Any 							=		stage_module(__snake_case		)

								if output_hidden_states:
															UpperCAmelCase :       str 							=		hidden_states + (hidden_state,)

								if not return_dict:
															return tuple(v for v in [hidden_state, hidden_states] if v is not None		)

								return BaseModelOutputWithNoAttention(last_hidden_state=__snake_case		,			hidden_states=__snake_case		)

class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	lowerCamelCase__			 =       RegNetConfig
	lowerCamelCase__			 =       """regnet"""
	lowerCamelCase__			 =       """pixel_values"""
	lowerCamelCase__			 =       True







	def      A	(						self			:     List[Any]		,			__snake_case			:     Union[str, Any]		)			->		Dict:
								if isinstance(__snake_case		,			nn.Convad		):
															nn.init.kaiming_normal_(module.weight		,			mode='''fan_out'''		,			nonlinearity='''relu'''		)
								elif isinstance(__snake_case		,			(nn.BatchNormad, nn.GroupNorm)		):
															nn.init.constant_(module.weight		,			1		)
															nn.init.constant_(module.bias		,			0		)







	def      A	(						self			:     int		,			__snake_case			:     Dict		,			__snake_case			:     List[str]=False		)			->		str:
								if isinstance(__snake_case		,			__snake_case		):
															UpperCAmelCase :       Dict 							=		value

UpperCamelCase__:   List[str]								=			r"\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`RegNetConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n"

UpperCamelCase__:   Any								=			r"\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.\n"

@add_start_docstrings(
    """The bare RegNet model outputting raw features without any specific head on top."""							,		A__							,		)
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	def __init__(						self			:     Optional[int]		,			__snake_case			:     Dict		)			->		int:
								super().__init__(__snake_case		)
								UpperCAmelCase :       Dict 							=		config
								UpperCAmelCase :       List[Any] 							=		RegNetEmbeddings(__snake_case		)
								UpperCAmelCase :       int 							=		RegNetEncoder(__snake_case		)
								UpperCAmelCase :       Optional[Any] 							=		nn.AdaptiveAvgPoolad((1, 1)		)
								# Initialize weights and apply final processing
								self.post_init()







	@add_start_docstrings_to_model_forward(__snake_case		)
	@add_code_sample_docstrings(
	    checkpoint=_CHECKPOINT_FOR_DOC		,			output_type=__snake_case		,			config_class=_CONFIG_FOR_DOC		,			modality='''vision'''		,			expected_output=_EXPECTED_OUTPUT_SHAPE		,			)
	def      A	(						self			:     Optional[Any]		,			__snake_case			:     Tensor		,			__snake_case			:     Optional[bool] = None		,			__snake_case			:     Optional[bool] = None		)			->		BaseModelOutputWithPoolingAndNoAttention:
								UpperCAmelCase :       str 							=		(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								UpperCAmelCase :       Optional[int] 							=		return_dict if return_dict is not None else self.config.use_return_dict

								UpperCAmelCase :       Optional[Any] 							=		self.embedder(__snake_case		)

								UpperCAmelCase :       Dict 							=		self.encoder(
								    __snake_case		,			output_hidden_states=__snake_case		,			return_dict=__snake_case		)

								UpperCAmelCase :       List[Any] 							=		encoder_outputs[0]

								UpperCAmelCase :       Optional[int] 							=		self.pooler(__snake_case		)

								if not return_dict:
															return (last_hidden_state, pooled_output) + encoder_outputs[1:]

								return BaseModelOutputWithPoolingAndNoAttention(
								    last_hidden_state=__snake_case		,			pooler_output=__snake_case		,			hidden_states=encoder_outputs.hidden_states		,			)

@add_start_docstrings(
    """
    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    """							,		A__							,		)
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	def __init__(						self			:     List[str]		,			__snake_case			:     List[str]		)			->		Optional[int]:
								super().__init__(__snake_case		)
								UpperCAmelCase :       Any 							=		config.num_labels
								UpperCAmelCase :       List[str] 							=		RegNetModel(__snake_case		)
								# classification head
								UpperCAmelCase :       str 							=		nn.Sequential(
								    nn.Flatten()		,			nn.Linear(config.hidden_sizes[-1]		,			config.num_labels		) if config.num_labels > 0 else nn.Identity()		,			)
								# initialize weights and apply final processing
								self.post_init()







	@add_start_docstrings_to_model_forward(__snake_case		)
	@add_code_sample_docstrings(
	    checkpoint=_IMAGE_CLASS_CHECKPOINT		,			output_type=__snake_case		,			config_class=_CONFIG_FOR_DOC		,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT		,			)
	def      A	(						self			:     Union[str, Any]		,			__snake_case			:     Optional[torch.FloatTensor] = None		,			__snake_case			:     Optional[torch.LongTensor] = None		,			__snake_case			:     Optional[bool] = None		,			__snake_case			:     Optional[bool] = None		,			)			->		ImageClassifierOutputWithNoAttention:
								UpperCAmelCase :       Dict 							=		return_dict if return_dict is not None else self.config.use_return_dict

								UpperCAmelCase :       str 							=		self.regnet(__snake_case		,			output_hidden_states=__snake_case		,			return_dict=__snake_case		)

								UpperCAmelCase :       Dict 							=		outputs.pooler_output if return_dict else outputs[1]

								UpperCAmelCase :       Union[str, Any] 							=		self.classifier(__snake_case		)

								UpperCAmelCase :       Optional[int] 							=		None

								if labels is not None:
															if self.config.problem_type is None:
																						if self.num_labels == 1:
																													UpperCAmelCase :       Optional[Any] 							=		'''regression'''
																						elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
																													UpperCAmelCase :       Any 							=		'''single_label_classification'''
																						else:
																													UpperCAmelCase :       Any 							=		'''multi_label_classification'''
															if self.config.problem_type == "regression":
																						UpperCAmelCase :       Optional[int] 							=		MSELoss()
																						if self.num_labels == 1:
																													UpperCAmelCase :       List[str] 							=		loss_fct(logits.squeeze()		,			labels.squeeze()		)
																						else:
																													UpperCAmelCase :       str 							=		loss_fct(__snake_case		,			__snake_case		)
															elif self.config.problem_type == "single_label_classification":
																						UpperCAmelCase :       Union[str, Any] 							=		CrossEntropyLoss()
																						UpperCAmelCase :       List[Any] 							=		loss_fct(logits.view(-1		,			self.num_labels		)		,			labels.view(-1		)		)
															elif self.config.problem_type == "multi_label_classification":
																						UpperCAmelCase :       Optional[int] 							=		BCEWithLogitsLoss()
																						UpperCAmelCase :       Optional[Any] 							=		loss_fct(__snake_case		,			__snake_case		)

								if not return_dict:
															UpperCAmelCase :       Optional[int] 							=		(logits,) + outputs[2:]
															return (loss,) + output if loss is not None else output

								return ImageClassifierOutputWithNoAttention(loss=__snake_case		,			logits=__snake_case		,			hidden_states=outputs.hidden_states		)








import unittest

from transformers import EsmConfig, is_torch_available
from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
			import torch

			from transformers.models.esm.modeling_esmfold import EsmForProteinFolding

class 				UpperCAmelCase_		:
							"""simple docstring"""







							def __init__(			self       ,							_a       ,							_a=1_3       ,							_a=7       ,							_a=False       ,							_a=True       ,							_a=False       ,							_a=False       ,							_a=1_9       ,							_a=3_2       ,							_a=5       ,							_a=4       ,							_a=3_7       ,							_a="gelu"       ,							_a=0.1       ,							_a=0.1       ,							_a=5_1_2       ,							_a=1_6       ,							_a=2       ,							_a=0.02       ,							_a=3       ,							_a=4       ,							_a=None       ,							)    ->    Union[str, Any]:
												_a	:    Optional[Any]         =		parent
												_a	:    Union[str, Any]         =		batch_size
												_a	:    List[Any]         =		seq_length
												_a	:    Dict         =		is_training
												_a	:    int         =		use_input_mask
												_a	:    str         =		use_token_type_ids
												_a	:    Any         =		use_labels
												_a	:    List[Any]         =		vocab_size
												_a	:    Any         =		hidden_size
												_a	:    int         =		num_hidden_layers
												_a	:    str         =		num_attention_heads
												_a	:    Dict         =		intermediate_size
												_a	:    List[str]         =		hidden_act
												_a	:    Optional[Any]         =		hidden_dropout_prob
												_a	:    Optional[Any]         =		attention_probs_dropout_prob
												_a	:    int         =		max_position_embeddings
												_a	:    Tuple         =		type_vocab_size
												_a	:    str         =		type_sequence_label_size
												_a	:    Any         =		initializer_range
												_a	:    Union[str, Any]         =		num_labels
												_a	:    Dict         =		num_choices
												_a	:    Union[str, Any]         =		scope


							def 				__lowercase				(			self       )    ->    List[Any]:
												_a	:    str         =		ids_tensor([self.batch_size, self.seq_length]       ,							self.vocab_size       )

												_a	:    Dict         =		None
												if self.use_input_mask:
																	_a	:    int         =		random_attention_mask([self.batch_size, self.seq_length]       )

												_a	:    List[Any]         =		None
												_a	:    Tuple         =		None
												_a	:    Any         =		None
												if self.use_labels:
																	_a	:    Tuple         =		ids_tensor([self.batch_size]       ,							self.type_sequence_label_size       )
																	_a	:    Union[str, Any]         =		ids_tensor([self.batch_size, self.seq_length]       ,							self.num_labels       )
																	_a	:    List[Any]         =		ids_tensor([self.batch_size]       ,							self.num_choices       )

												_a	:    str         =		self.get_config()

												return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels


							def 				__lowercase				(			self       )    ->    str:
												_a	:    Optional[int]         =		EsmConfig(
												    vocab_size=3_3       ,							hidden_size=self.hidden_size       ,							pad_token_id=1       ,							num_hidden_layers=self.num_hidden_layers       ,							num_attention_heads=self.num_attention_heads       ,							intermediate_size=self.intermediate_size       ,							hidden_act=self.hidden_act       ,							hidden_dropout_prob=self.hidden_dropout_prob       ,							attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,							max_position_embeddings=self.max_position_embeddings       ,							type_vocab_size=self.type_vocab_size       ,							initializer_range=self.initializer_range       ,							is_folding_model=_a       ,							esmfold_config={'''trunk''': {'''num_blocks''': 2}, '''fp16_esm''': False}       ,							)
												return config


							def 				__lowercase				(			self       ,							_a       ,							_a       ,							_a       ,							_a       ,							_a       ,							_a       )    ->    str:
												_a	:    Union[str, Any]         =		EsmForProteinFolding(config=_a       ).float()
												model.to(_a       )
												model.eval()
												_a	:    str         =		model(_a       ,							attention_mask=_a       )
												_a	:    Union[str, Any]         =		model(_a       )
												_a	:    Optional[int]         =		model(_a       )

												self.parent.assertEqual(result.positions.shape       ,							(8, self.batch_size, self.seq_length, 1_4, 3)       )
												self.parent.assertEqual(result.angles.shape       ,							(8, self.batch_size, self.seq_length, 7, 2)       )




							def 				__lowercase				(			self       )    ->    str:
												_a	:    List[str]         =		self.prepare_config_and_inputs()
												(
												    (
												    _a
												)      ,					(
												    _a
												)      ,					(
												    _a
												)      ,					(
												    _a
												)      ,					(
												    _a
												)      ,					(
												    _a
												)      ,					
												)	:    Optional[Any]         =		config_and_inputs
												_a	:    List[Any]         =		{'''input_ids''': input_ids, '''attention_mask''': input_mask}
												return config, inputs_dict



@require_torch
class 				UpperCAmelCase_		(			__lowercase				,       __lowercase				,       unittest.TestCase   ):
							"""simple docstring"""







							UpperCAmelCase__       :						Any	    =    False

							UpperCAmelCase__       :						Any	    =    (EsmForProteinFolding,) if is_torch_available() else ()
							UpperCAmelCase__       :						Union[str, Any]	    =    ()
							UpperCAmelCase__       :						int	    =    {} if is_torch_available() else {}
							UpperCAmelCase__       :						Optional[int]	    =    False


							def 				__lowercase				(			self       )    ->    List[Any]:
												_a	:    Optional[int]         =		EsmFoldModelTester(self       )
												_a	:    Dict         =		ConfigTester(self       ,							config_class=_a       ,							hidden_size=3_7       )


							def 				__lowercase				(			self       )    ->    List[str]:
												self.config_tester.run_common_tests()


							def 				__lowercase				(			self       )    ->    str:
												_a	:    str         =		self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*_a       )


							@unittest.skip('''Does not support attention outputs'''       )
							def 				__lowercase				(			self       )    ->    int:
												pass


							@unittest.skip
							def 				__lowercase				(			self       )    ->    List[str]:
												pass


							@unittest.skip('''Esm does not support embedding resizing'''       )
							def 				__lowercase				(			self       )    ->    int:
												pass


							@unittest.skip('''Esm does not support embedding resizing'''       )
							def 				__lowercase				(			self       )    ->    Optional[Any]:
												pass


							@unittest.skip('''ESMFold does not support passing input embeds!'''       )
							def 				__lowercase				(			self       )    ->    int:
												pass


							@unittest.skip('''ESMFold does not support head pruning.'''       )
							def 				__lowercase				(			self       )    ->    str:
												pass


							@unittest.skip('''ESMFold does not support head pruning.'''       )
							def 				__lowercase				(			self       )    ->    Optional[Any]:
												pass


							@unittest.skip('''ESMFold does not support head pruning.'''       )
							def 				__lowercase				(			self       )    ->    Optional[Any]:
												pass


							@unittest.skip('''ESMFold does not support head pruning.'''       )
							def 				__lowercase				(			self       )    ->    Any:
												pass


							@unittest.skip('''ESMFold does not support head pruning.'''       )
							def 				__lowercase				(			self       )    ->    Tuple:
												pass


							@unittest.skip('''ESMFold does not output hidden states in the normal way.'''       )
							def 				__lowercase				(			self       )    ->    Tuple:
												pass


							@unittest.skip('''ESMfold does not output hidden states in the normal way.'''       )
							def 				__lowercase				(			self       )    ->    Tuple:
												pass


							@unittest.skip('''ESMFold only has one output format.'''       )
							def 				__lowercase				(			self       )    ->    Tuple:
												pass


							@unittest.skip('''This test doesn\'t work for ESMFold and doesn\'t test core functionality'''       )
							def 				__lowercase				(			self       )    ->    Dict:
												pass


							@unittest.skip('''ESMFold does not support input chunking.'''       )
							def 				__lowercase				(			self       )    ->    Tuple:
												pass


							@unittest.skip('''ESMFold doesn\'t respect you and it certainly doesn\'t respect your initialization arguments.'''       )
							def 				__lowercase				(			self       )    ->    Optional[Any]:
												pass


							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''       )
							def 				__lowercase				(			self       )    ->    List[str]:
												pass


							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''       )
							def 				__lowercase				(			self       )    ->    List[str]:
												pass


							@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''       )
							def 				__lowercase				(			self       )    ->    List[Any]:
												pass


							@unittest.skip('''ESMFold doesn\'t support data parallel.'''       )
							def 				__lowercase				(			self       )    ->    Union[str, Any]:
												pass




							@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''       )
							def 				__lowercase				(			self       )    ->    Optional[Any]:
												pass



@require_torch
class 				UpperCAmelCase_		(			__lowercase   ):
							"""simple docstring"""







							@slow
							def 				__lowercase				(			self       )    ->    Optional[int]:
												_a	:    Dict         =		EsmForProteinFolding.from_pretrained('''facebook/esmfold_v1'''       ).float()
												model.eval()
												_a	:    Tuple         =		torch.tensor([[0, 6, 4, 1_3, 5, 4, 1_6, 1_2, 1_1, 7, 2]]       )
												_a	:    Optional[Any]         =		model(_a       )['''positions''']
												_a	:    Union[str, Any]         =		torch.tensor([2.5828, 0.7993, -10.9334]       ,							dtype=torch.floataa       )
												self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]       ,							_a       ,							atol=1e-4       )       )



