
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   :					int				,A   :					Dict				,A   :					int=13				,A   :					Dict=7				,A   :					Dict=False				,A   :					List[str]=True				,A   :					Optional[int]=False				,A   :					Dict=False				,A   :					Union[str, Any]=19				,A   :					str=32				,A   :					int=5				,A   :					Any=4				,A   :					List[str]=37				,A   :					Union[str, Any]="gelu"				,A   :					int=0.1				,A   :					int=0.1				,A   :					Tuple=5_12				,A   :					List[str]=16				,A   :					Optional[int]=2				,A   :					Optional[int]=0.02				,A   :					str=3				,A   :					Optional[int]=4				,A   :					Any=None				,):
					__A       =					parent
					__A       =					batch_size
					__A       =					seq_length
					__A       =					is_training
					__A       =					use_input_mask
					__A       =					use_token_type_ids
					__A       =					use_labels
					__A       =					vocab_size
					__A       =					hidden_size
					__A       =					num_hidden_layers
					__A       =					num_attention_heads
					__A       =					intermediate_size
					__A       =					hidden_act
					__A       =					hidden_dropout_prob
					__A       =					attention_probs_dropout_prob
					__A       =					max_position_embeddings
					__A       =					type_vocab_size
					__A       =					type_sequence_label_size
					__A       =					initializer_range
					__A       =					num_labels
					__A       =					num_choices
					__A       =					scope






	def 							UpperCamelCase_    (			self   :					int					):
					__A       =					ids_tensor([self.batch_size, self.seq_length]				,self.vocab_size					)

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

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

					__A       =					self.get_config()

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






	def 							UpperCamelCase_    (			self   :					List[Any]					):
					__A       =					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=A				,esmfold_config={"trunk": {"num_blocks": 2}, "fp16_esm": False}				,)
					return config






	def 							UpperCamelCase_    (			self   :					Optional[Any]				,A   :					List[Any]				,A   :					List[Any]				,A   :					Optional[int]				,A   :					Tuple				,A   :					List[Any]				,A   :					List[Any]					):
					__A       =					EsmForProteinFolding(config=A					).float()
					model.to(A					)
					model.eval()
					__A       =					model(A				,attention_mask=A					)
					__A       =					model(A					)
					__A       =					model(A					)

					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 							UpperCamelCase_    (			self   :					Optional[int]					):
					__A       =					self.prepare_config_and_inputs()
					(
					    (
					    __A
					)     ,				(
					    __A
					)     ,				(
					    __A
					)     ,				(
					    __A
					)     ,				(
					    __A
					)     ,				(
					    __A
					)     ,				
					)       =					config_and_inputs
					__A       =					{"input_ids": input_ids, "attention_mask": input_mask}
					return config, inputs_dict





@require_torch
class 				UpperCAmelCase (    __SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE     ,     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 							UpperCamelCase_    (			self   :					Any					):
					__A       =					EsmFoldModelTester(self					)
					__A       =					ConfigTester(self				,config_class=A				,hidden_size=37					)






	def 							UpperCamelCase_    (			self   :					str					):
					self.config_tester.run_common_tests()






	def 							UpperCamelCase_    (			self   :					Optional[int]					):
					__A       =					self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*A					)






	@unittest.skip("Does not support attention outputs"					)
	def 							UpperCamelCase_    (			self   :					Dict					):
					pass






	@unittest.skip
	def 							UpperCamelCase_    (			self   :					Any					):
					pass






	@unittest.skip("Esm does not support embedding resizing"					)
	def 							UpperCamelCase_    (			self   :					Any					):
					pass






	@unittest.skip("Esm does not support embedding resizing"					)
	def 							UpperCamelCase_    (			self   :					Optional[int]					):
					pass






	@unittest.skip("ESMFold does not support passing input embeds!"					)
	def 							UpperCamelCase_    (			self   :					Optional[int]					):
					pass






	@unittest.skip("ESMFold does not support head pruning."					)
	def 							UpperCamelCase_    (			self   :					List[str]					):
					pass






	@unittest.skip("ESMFold does not support head pruning."					)
	def 							UpperCamelCase_    (			self   :					List[Any]					):
					pass






	@unittest.skip("ESMFold does not support head pruning."					)
	def 							UpperCamelCase_    (			self   :					int					):
					pass






	@unittest.skip("ESMFold does not support head pruning."					)
	def 							UpperCamelCase_    (			self   :					List[Any]					):
					pass






	@unittest.skip("ESMFold does not support head pruning."					)
	def 							UpperCamelCase_    (			self   :					List[Any]					):
					pass






	@unittest.skip("ESMFold does not output hidden states in the normal way."					)
	def 							UpperCamelCase_    (			self   :					Optional[Any]					):
					pass






	@unittest.skip("ESMfold does not output hidden states in the normal way."					)
	def 							UpperCamelCase_    (			self   :					Dict					):
					pass






	@unittest.skip("ESMFold only has one output format."					)
	def 							UpperCamelCase_    (			self   :					int					):
					pass






	@unittest.skip("This test doesn't work for ESMFold and doesn't test core functionality"					)
	def 							UpperCamelCase_    (			self   :					List[str]					):
					pass






	@unittest.skip("ESMFold does not support input chunking."					)
	def 							UpperCamelCase_    (			self   :					List[Any]					):
					pass






	@unittest.skip("ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."					)
	def 							UpperCamelCase_    (			self   :					List[str]					):
					pass






	@unittest.skip("ESMFold doesn't support torchscript compilation."					)
	def 							UpperCamelCase_    (			self   :					int					):
					pass






	@unittest.skip("ESMFold doesn't support torchscript compilation."					)
	def 							UpperCamelCase_    (			self   :					int					):
					pass






	@unittest.skip("ESMFold doesn't support torchscript compilation."					)
	def 							UpperCamelCase_    (			self   :					int					):
					pass






	@unittest.skip("ESMFold doesn't support data parallel."					)
	def 							UpperCamelCase_    (			self   :					Optional[int]					):
					pass







	@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."					)
	def 							UpperCamelCase_    (			self   :					Tuple					):
					pass





@require_torch
class 				UpperCAmelCase (    __SCREAMING_SNAKE_CASE    ):




	'''simple docstring'''





	@slow
	def 							UpperCamelCase_    (			self   :					str					):
					__A       =					EsmForProteinFolding.from_pretrained("facebook/esmfold_v1"					).float()
					model.eval()
					__A       =					torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]					)
					__A       =					model(A					)["positions"]
					__A       =					torch.tensor([2.58_28, 0.79_93, -10.93_34]				,dtype=torch.floataa					)
					self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]				,A				,atol=1E-4					)					)

"""simple docstring"""



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


_UpperCamelCase								=		logging.get_logger(__name__)

_UpperCamelCase								=		{
    "vinvino02/glpn-kitti": "https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json",
    # See all GLPN models at https://huggingface.co/models?filter=glpn
}
class 						__UpperCAmelCase    (__A     ):







			'''simple docstring'''
			_UpperCamelCase  :						Dict					     =				'glpn'





			def __init__(			self   ,      snake_case_=3   ,      snake_case_=4   ,      snake_case_=[2, 2, 2, 2]   ,      snake_case_=[8, 4, 2, 1]   ,      snake_case_=[32, 64, 160, 256]   ,      snake_case_=[7, 3, 3, 3]   ,      snake_case_=[4, 2, 2, 2]   ,      snake_case_=[1, 2, 5, 8]   ,      snake_case_=[4, 4, 4, 4]   ,      snake_case_="gelu"   ,      snake_case_=0.0   ,      snake_case_=0.0   ,      snake_case_=0.02   ,      snake_case_=0.1   ,      snake_case_=1E-6   ,      snake_case_=64   ,      snake_case_=10   ,      snake_case_=-1   ,      **snake_case_   ,      ):







										'''simple docstring'''


										super().__init__(**snake_case_							)

										A__       :     str								=			num_channels
										A__       :     List[Any]								=			num_encoder_blocks
										A__       :     List[str]								=			depths
										A__       :     int								=			sr_ratios
										A__       :     Optional[Any]								=			hidden_sizes
										A__       :     int								=			patch_sizes
										A__       :     str								=			strides
										A__       :     int								=			mlp_ratios
										A__       :     Optional[int]								=			num_attention_heads
										A__       :     Optional[Any]								=			hidden_act
										A__       :     Optional[Any]								=			hidden_dropout_prob
										A__       :     Optional[Any]								=			attention_probs_dropout_prob
										A__       :     List[str]								=			initializer_range
										A__       :     Dict								=			drop_path_rate
										A__       :     Any								=			layer_norm_eps
										A__       :     Any								=			decoder_hidden_size
										A__       :     Optional[Any]								=			max_depth
										A__       :     List[Any]								=			head_in_index





