




import argparse
import json
from pathlib import Path

import requests
import timm
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from timm.data import resolve_data_config
from timm.data.transforms_factory import create_transform

from transformers import (
    BitConfig,
    ViTHybridConfig,
    ViTHybridForImageClassification,
    ViTHybridImageProcessor,
    ViTHybridModel,
)
from transformers.image_utils import PILImageResampling
from transformers.utils import logging


logging.set_verbosity_info()
__A								=       logging.get_logger(__name__)







def      lowerCamelCase_						(			UpperCamelCase__							: Optional[Any]					,	UpperCamelCase__							: Optional[int]=False )	->			List[Any]:





				"""simple docstring"""


				__lowerCamelCase									=       []

				# fmt: off
				# stem:
				rename_keys.append(('cls_token', 'vit.embeddings.cls_token') )
				rename_keys.append(('pos_embed', 'vit.embeddings.position_embeddings') )

				rename_keys.append(('patch_embed.proj.weight', 'vit.embeddings.patch_embeddings.projection.weight') )
				rename_keys.append(('patch_embed.proj.bias', 'vit.embeddings.patch_embeddings.projection.bias') )

				# backbone
				rename_keys.append(('patch_embed.backbone.stem.conv.weight', 'vit.embeddings.patch_embeddings.backbone.bit.embedder.convolution.weight') )
				rename_keys.append(('patch_embed.backbone.stem.norm.weight', 'vit.embeddings.patch_embeddings.backbone.bit.embedder.norm.weight') )
				rename_keys.append(('patch_embed.backbone.stem.norm.bias', 'vit.embeddings.patch_embeddings.backbone.bit.embedder.norm.bias') )

				for stage_idx in range(len(config.backbone_config.depths ) ):
								for layer_idx in range(config.backbone_config.depths[stage_idx] ):
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.conv1.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.conv1.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm1.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm1.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm1.bias""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm1.bias""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.conv2.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.conv2.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm2.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm2.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm2.bias""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm2.bias""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.conv3.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.conv3.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm3.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm3.weight""") )
												rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.{layer_idx}.norm3.bias""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.{layer_idx}.norm3.bias""") )

								rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.0.downsample.conv.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.0.downsample.conv.weight""") )
								rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.0.downsample.norm.weight""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.0.downsample.norm.weight""") )
								rename_keys.append((F"""patch_embed.backbone.stages.{stage_idx}.blocks.0.downsample.norm.bias""", F"""vit.embeddings.patch_embeddings.backbone.bit.encoder.stages.{stage_idx}.layers.0.downsample.norm.bias""") )

				# transformer encoder
				for i in range(config.num_hidden_layers ):
								# encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
								rename_keys.append((F"""blocks.{i}.norm1.weight""", F"""vit.encoder.layer.{i}.layernorm_before.weight""") )
								rename_keys.append((F"""blocks.{i}.norm1.bias""", F"""vit.encoder.layer.{i}.layernorm_before.bias""") )
								rename_keys.append((F"""blocks.{i}.attn.proj.weight""", F"""vit.encoder.layer.{i}.attention.output.dense.weight""") )
								rename_keys.append((F"""blocks.{i}.attn.proj.bias""", F"""vit.encoder.layer.{i}.attention.output.dense.bias""") )
								rename_keys.append((F"""blocks.{i}.norm2.weight""", F"""vit.encoder.layer.{i}.layernorm_after.weight""") )
								rename_keys.append((F"""blocks.{i}.norm2.bias""", F"""vit.encoder.layer.{i}.layernorm_after.bias""") )
								rename_keys.append((F"""blocks.{i}.mlp.fc1.weight""", F"""vit.encoder.layer.{i}.intermediate.dense.weight""") )
								rename_keys.append((F"""blocks.{i}.mlp.fc1.bias""", F"""vit.encoder.layer.{i}.intermediate.dense.bias""") )
								rename_keys.append((F"""blocks.{i}.mlp.fc2.weight""", F"""vit.encoder.layer.{i}.output.dense.weight""") )
								rename_keys.append((F"""blocks.{i}.mlp.fc2.bias""", F"""vit.encoder.layer.{i}.output.dense.bias""") )

				if base_model:
								# layernorm + pooler
								rename_keys.extend(
								    [
								        ('norm.weight', 'layernorm.weight'),
								        ('norm.bias', 'layernorm.bias'),
								        ('pre_logits.fc.weight', 'pooler.dense.weight'),
								        ('pre_logits.fc.bias', 'pooler.dense.bias'),
								    ] )

								# if just the base model, we should remove "vit" from all keys that start with "vit"
								__lowerCamelCase									=       [(pair[0], pair[1][4:]) if pair[1].startswith('vit' ) else pair for pair in rename_keys]
				else:
								# layernorm + classification head
								rename_keys.extend(
								    [
								        ('norm.weight', 'vit.layernorm.weight'),
								        ('norm.bias', 'vit.layernorm.bias'),
								        ('head.weight', 'classifier.weight'),
								        ('head.bias', 'classifier.bias'),
								    ] )
				# fmt: on

				return rename_keys







def      lowerCamelCase_						(			UpperCamelCase__							: List[Any]					,	UpperCamelCase__							: List[str]					,	UpperCamelCase__							: List[Any]=False )	->			Tuple:





				"""simple docstring"""


				for i in range(config.num_hidden_layers ):
								if base_model:
												__lowerCamelCase									=       ''
								else:
												__lowerCamelCase									=       'vit.'
								# read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
								__lowerCamelCase									=       state_dict.pop(F"""blocks.{i}.attn.qkv.weight""" )
								__lowerCamelCase									=       state_dict.pop(F"""blocks.{i}.attn.qkv.bias""" )
								# next, add query, keys and values (in that order) to the state dict
								__lowerCamelCase									=       in_proj_weight[
								    : config.hidden_size, :
								]
								__lowerCamelCase									=       in_proj_bias[: config.hidden_size]
								__lowerCamelCase									=       in_proj_weight[
								    config.hidden_size : config.hidden_size * 2, :
								]
								__lowerCamelCase									=       in_proj_bias[
								    config.hidden_size : config.hidden_size * 2
								]
								__lowerCamelCase									=       in_proj_weight[
								    -config.hidden_size :, :
								]
								__lowerCamelCase									=       in_proj_bias[-config.hidden_size :]







def      lowerCamelCase_						(			UpperCamelCase__							: str )	->			str:





				"""simple docstring"""


				__lowerCamelCase									=       ['head.weight', 'head.bias']
				for k in ignore_keys:
								state_dict.pop(UpperCamelCase__					,	UpperCamelCase__ )







def      lowerCamelCase_						(			UpperCamelCase__							: int					,	UpperCamelCase__							: str					,	UpperCamelCase__							: Tuple )	->			List[Any]:





				"""simple docstring"""


				__lowerCamelCase									=       dct.pop(UpperCamelCase__ )
				__lowerCamelCase									=       val







def      lowerCamelCase_						(			)	->			Optional[Any]:





				"""simple docstring"""


				__lowerCamelCase									=       'http://images.cocodataset.org/val2017/000000039769.jpg'
				__lowerCamelCase									=       Image.open(requests.get(UpperCamelCase__					,	stream=UpperCamelCase__ ).raw )
				return im







@torch.no_grad()
def      lowerCamelCase_						(			UpperCamelCase__							: Optional[Any]					,	UpperCamelCase__							: Optional[int]					,	UpperCamelCase__							: Tuple=False )	->			Any:





				"""simple docstring"""


				__lowerCamelCase									=       BitConfig(
				    global_padding='same'					,	layer_type='bottleneck'					,	depths=(3, 4, 9)					,	out_features=['stage3']					,	embedding_dynamic_padding=UpperCamelCase__					,	)
				__lowerCamelCase									=       ViTHybridConfig(backbone_config=UpperCamelCase__					,	image_size=384					,	num_labels=1000 )
				__lowerCamelCase									=       False

				# load original model from timm
				__lowerCamelCase									=       timm.create_model(UpperCamelCase__					,	pretrained=UpperCamelCase__ )
				timm_model.eval()

				# load state_dict of original model, remove and rename some keys
				__lowerCamelCase									=       timm_model.state_dict()
				if base_model:
								remove_classification_head_(UpperCamelCase__ )
				__lowerCamelCase									=       create_rename_keys(UpperCamelCase__					,	UpperCamelCase__ )
				for src, dest in rename_keys:
								rename_key(UpperCamelCase__					,	UpperCamelCase__					,	UpperCamelCase__ )
				read_in_q_k_v(UpperCamelCase__					,	UpperCamelCase__					,	UpperCamelCase__ )

				__lowerCamelCase									=       'huggingface/label-files'
				__lowerCamelCase									=       'imagenet-1k-id2label.json'
				__lowerCamelCase									=       json.load(open(hf_hub_download(UpperCamelCase__					,	UpperCamelCase__					,	repo_type='dataset' )					,	'r' ) )
				__lowerCamelCase									=       {int(UpperCamelCase__ ): v for k, v in idalabel.items()}
				__lowerCamelCase									=       idalabel
				__lowerCamelCase									=       {v: k for k, v in idalabel.items()}

				# load HuggingFace model
				if vit_name[-5:] == "in21k":
								__lowerCamelCase									=       ViTHybridModel(UpperCamelCase__ ).eval()
				else:
								__lowerCamelCase									=       ViTHybridForImageClassification(UpperCamelCase__ ).eval()
				model.load_state_dict(UpperCamelCase__ )

				# create image processor
				__lowerCamelCase									=       create_transform(**resolve_data_config({}					,	model=UpperCamelCase__ ) )
				__lowerCamelCase									=       transform.transforms

				__lowerCamelCase									=       {
				    'bilinear': PILImageResampling.BILINEAR,
				    'bicubic': PILImageResampling.BICUBIC,
				    'nearest': PILImageResampling.NEAREST,
				}

				__lowerCamelCase									=       ViTHybridImageProcessor(
				    do_resize=UpperCamelCase__					,	size={'shortest_edge': timm_transforms[0].size}					,	resample=pillow_resamplings[timm_transforms[0].interpolation.value]					,	do_center_crop=UpperCamelCase__					,	crop_size={'height': timm_transforms[1].size[0], 'width': timm_transforms[1].size[1]}					,	do_normalize=UpperCamelCase__					,	image_mean=timm_transforms[-1].mean.tolist()					,	image_std=timm_transforms[-1].std.tolist()					,	)

				__lowerCamelCase									=       prepare_img()
				__lowerCamelCase									=       transform(UpperCamelCase__ ).unsqueeze(0 )
				__lowerCamelCase									=       processor(UpperCamelCase__					,	return_tensors='pt' ).pixel_values

				# verify pixel values
				assert torch.allclose(UpperCamelCase__					,	UpperCamelCase__ )

				# verify logits
				with torch.no_grad():
								__lowerCamelCase									=       model(UpperCamelCase__ )
								__lowerCamelCase									=       outputs.logits

				print('Predicted class:'					,	logits.argmax(-1 ).item() )
				if base_model:
								__lowerCamelCase									=       timm_model.forward_features(UpperCamelCase__ )
								assert timm_pooled_output.shape == outputs.pooler_output.shape
								assert torch.allclose(UpperCamelCase__					,	outputs.pooler_output					,	atol=1E-3 )
				else:
								__lowerCamelCase									=       timm_model(UpperCamelCase__ )
								assert timm_logits.shape == outputs.logits.shape
								assert torch.allclose(UpperCamelCase__					,	outputs.logits					,	atol=1E-3 )
				print('Looks ok!' )

				if pytorch_dump_folder_path is not None:
								Path(UpperCamelCase__ ).mkdir(exist_ok=UpperCamelCase__ )
								print(F"""Saving model {vit_name} to {pytorch_dump_folder_path}""" )
								model.save_pretrained(UpperCamelCase__ )
								print(F"""Saving processor to {pytorch_dump_folder_path}""" )
								processor.save_pretrained(UpperCamelCase__ )

				if push_to_hub:
								print(F"""Pushing model and processor to the hub {vit_name}""" )
								model.push_to_hub(F"""ybelkada/{vit_name}""" )
								processor.push_to_hub(F"""ybelkada/{vit_name}""" )


if __name__ == "__main__":
					__A								=       argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    "--vit_name",
					    default="vit_base_r50_s16_384",
					    type=str,
					    help="Name of the hybrid ViT timm model you'd like to convert.",
					)
					parser.add_argument(
					    "--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model directory."
					)
					parser.add_argument(
					    "--push_to_hub", action="store_true", help="Whether to upload the model to the HuggingFace hub."
					)

					__A								=       parser.parse_args()
					convert_vit_checkpoint(args.vit_name, args.pytorch_dump_folder_path, args.push_to_hub)








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        __lowerCAmelCase					:

			"""simple docstring"""







			def __init__( self     ,		lowerCamelCase__     ,		lowerCamelCase__=13     ,		lowerCamelCase__=7     ,		lowerCamelCase__=False     ,		lowerCamelCase__=True     ,		lowerCamelCase__=False     ,		lowerCamelCase__=False     ,		lowerCamelCase__=19     ,		lowerCamelCase__=32     ,		lowerCamelCase__=5     ,		lowerCamelCase__=4     ,		lowerCamelCase__=37     ,		lowerCamelCase__="gelu"     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=0.1     ,		lowerCamelCase__=512     ,		lowerCamelCase__=16     ,		lowerCamelCase__=2     ,		lowerCamelCase__=0.02     ,		lowerCamelCase__=3     ,		lowerCamelCase__=4     ,		lowerCamelCase__=None     ,		)       -> Any:



							'''simple docstring'''
							__lowerCamelCase									=       parent
							__lowerCamelCase									=       batch_size
							__lowerCamelCase									=       seq_length
							__lowerCamelCase									=       is_training
							__lowerCamelCase									=       use_input_mask
							__lowerCamelCase									=       use_token_type_ids
							__lowerCamelCase									=       use_labels
							__lowerCamelCase									=       vocab_size
							__lowerCamelCase									=       hidden_size
							__lowerCamelCase									=       num_hidden_layers
							__lowerCamelCase									=       num_attention_heads
							__lowerCamelCase									=       intermediate_size
							__lowerCamelCase									=       hidden_act
							__lowerCamelCase									=       hidden_dropout_prob
							__lowerCamelCase									=       attention_probs_dropout_prob
							__lowerCamelCase									=       max_position_embeddings
							__lowerCamelCase									=       type_vocab_size
							__lowerCamelCase									=       type_sequence_label_size
							__lowerCamelCase									=       initializer_range
							__lowerCamelCase									=       num_labels
							__lowerCamelCase									=       num_choices
							__lowerCamelCase									=       scope


			def  lowercase_       ( self				)       -> str:



							'''simple docstring'''
							__lowerCamelCase									=       ids_tensor([self.batch_size, self.seq_length]     ,		self.vocab_size				)

							__lowerCamelCase									=       None
							if self.use_input_mask:
											__lowerCamelCase									=       random_attention_mask([self.batch_size, self.seq_length]				)

							__lowerCamelCase									=       None
							__lowerCamelCase									=       None
							__lowerCamelCase									=       None
							if self.use_labels:
											__lowerCamelCase									=       ids_tensor([self.batch_size]     ,		self.type_sequence_label_size				)
											__lowerCamelCase									=       ids_tensor([self.batch_size, self.seq_length]     ,		self.num_labels				)
											__lowerCamelCase									=       ids_tensor([self.batch_size]     ,		self.num_choices				)

							__lowerCamelCase									=       self.get_config()

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


			def  lowercase_       ( self				)       -> Tuple:



							'''simple docstring'''
							__lowerCamelCase									=       EsmConfig(
							    vocab_size=33     ,		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=lowerCamelCase__     ,		esmfold_config={'trunk': {'num_blocks': 2}, 'fp16_esm': False}     ,		)
							return config


			def  lowercase_       ( self     ,		lowerCamelCase__     ,		lowerCamelCase__     ,		lowerCamelCase__     ,		lowerCamelCase__     ,		lowerCamelCase__     ,		lowerCamelCase__				)       -> Optional[Any]:



							'''simple docstring'''
							__lowerCamelCase									=       EsmForProteinFolding(config=lowerCamelCase__				).float()
							model.to(lowerCamelCase__				)
							model.eval()
							__lowerCamelCase									=       model(lowerCamelCase__     ,		attention_mask=lowerCamelCase__				)
							__lowerCamelCase									=       model(lowerCamelCase__				)
							__lowerCamelCase									=       model(lowerCamelCase__				)

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






			def  lowercase_       ( self				)       -> int:



							'''simple docstring'''
							__lowerCamelCase									=       self.prepare_config_and_inputs()
							(
							    (
							    __lowerCamelCase
							)			,		(
							    __lowerCamelCase
							)			,		(
							    __lowerCamelCase
							)			,		(
							    __lowerCamelCase
							)			,		(
							    __lowerCamelCase
							)			,		(
							    __lowerCamelCase
							)			,		
							)									=       config_and_inputs
							__lowerCamelCase									=       {'input_ids': input_ids, 'attention_mask': input_mask}
							return config, inputs_dict







@require_torch
class        __lowerCAmelCase					(			__magic_name__     ,							__magic_name__     ,							unittest.TestCase					):

			"""simple docstring"""







			snake_case_  						=			False

			snake_case_  						=			(EsmForProteinFolding,) if is_torch_available() else ()
			snake_case_  						=			()
			snake_case_  						=			{} if is_torch_available() else {}
			snake_case_  						=			False


			def  lowercase_       ( self				)       -> Tuple:



							'''simple docstring'''
							__lowerCamelCase									=       EsmFoldModelTester(self				)
							__lowerCamelCase									=       ConfigTester(self     ,		config_class=lowerCamelCase__     ,		hidden_size=37				)


			def  lowercase_       ( self				)       -> Any:



							'''simple docstring'''
							self.config_tester.run_common_tests()


			def  lowercase_       ( self				)       -> str:



							'''simple docstring'''
							__lowerCamelCase									=       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*lowerCamelCase__				)


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



							'''simple docstring'''
							pass


			@unittest.skip
			def  lowercase_       ( self				)       -> Tuple:



							'''simple docstring'''
							pass


			@unittest.skip('Esm does not support embedding resizing'				)
			def  lowercase_       ( self				)       -> Any:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold does not support head pruning.'				)
			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold does not support head pruning.'				)
			def  lowercase_       ( self				)       -> int:



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold does not support head pruning.'				)
			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold does not output hidden states in the normal way.'				)
			def  lowercase_       ( self				)       -> List[str]:



							'''simple docstring'''
							pass


			@unittest.skip('ESMfold does not output hidden states in the normal way.'				)
			def  lowercase_       ( self				)       -> Optional[int]:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold does not support input chunking.'				)
			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold doesn\'t support torchscript compilation.'				)
			def  lowercase_       ( self				)       -> Union[str, Any]:



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold doesn\'t support torchscript compilation.'				)
			def  lowercase_       ( self				)       -> str:



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold doesn\'t support torchscript compilation.'				)
			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							pass


			@unittest.skip('ESMFold doesn\'t support data parallel.'				)
			def  lowercase_       ( self				)       -> str:



							'''simple docstring'''
							pass






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



							'''simple docstring'''
							pass







@require_torch
class        __lowerCAmelCase					(			__magic_name__					):

			"""simple docstring"""







			@slow
			def  lowercase_       ( self				)       -> str:



							'''simple docstring'''
							__lowerCamelCase									=       EsmForProteinFolding.from_pretrained('facebook/esmfold_v1'				).float()
							model.eval()
							__lowerCamelCase									=       torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]				)
							__lowerCamelCase									=       model(lowerCamelCase__				)['positions']
							__lowerCamelCase									=       torch.tensor([2.58_28, 0.79_93, -10.93_34]     ,		dtype=torch.floataa				)
							self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]     ,		lowerCamelCase__     ,		atol=1e-4				)				)


