




"""simple docstring"""

import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import ViTImageProcessor
class      A__   (   unittest.TestCase  ):




	def __init__( self	:						List[Any]   ,     lowercase	:						Union[str, Any]   ,     lowercase	:						Union[str, Any]=7   ,     lowercase	:						Tuple=3   ,     lowercase	:						Optional[int]=18   ,     lowercase	:						Optional[Any]=30   ,     lowercase	:						Dict=400   ,     lowercase	:						Any=True   ,     lowercase	:						Optional[int]=None   ,     lowercase	:						List[Any]=True   ,     lowercase	:						Optional[int]=[0.5, 0.5, 0.5]   ,     lowercase	:						Dict=[0.5, 0.5, 0.5]   ,     )       ->			Dict:
						__snake_case        =						size if size is not None else {"""height""": 18, """width""": 18}
						__snake_case        =						parent
						__snake_case        =						batch_size
						__snake_case        =						num_channels
						__snake_case        =						image_size
						__snake_case        =						min_resolution
						__snake_case        =						max_resolution
						__snake_case        =						do_resize
						__snake_case        =						size
						__snake_case        =						do_normalize
						__snake_case        =						image_mean
						__snake_case        =						image_std




	def 				a_		( self	:						str						)       ->			Union[str, Any]:
						return {
						    "image_mean": self.image_mean,
						    "image_std": self.image_std,
						    "do_normalize": self.do_normalize,
						    "do_resize": self.do_resize,
						    "size": self.size,
						}

@require_torch
@require_vision
class      A__   (   lowercase_  ,						unittest.TestCase  ):
	A_				:					Dict      =   ViTImageProcessor if is_vision_available() else None




	def 				a_		( self	:						List[Any]						)       ->			str:
						__snake_case        =						ViTImageProcessingTester(self						)




	@property
	def 				a_		( self	:						Dict						)       ->			str:
						return self.image_processor_tester.prepare_image_processor_dict()




	def 				a_		( self	:						Optional[Any]						)       ->			Any:
						__snake_case        =						self.image_processing_class(**self.image_processor_dict						)
						self.assertTrue(hasattr(lowercase   ,     """image_mean"""						)						)
						self.assertTrue(hasattr(lowercase   ,     """image_std"""						)						)
						self.assertTrue(hasattr(lowercase   ,     """do_normalize"""						)						)
						self.assertTrue(hasattr(lowercase   ,     """do_resize"""						)						)
						self.assertTrue(hasattr(lowercase   ,     """size"""						)						)




	def 				a_		( self	:						Dict						)       ->			int:
						__snake_case        =						self.image_processing_class.from_dict(self.image_processor_dict						)
						self.assertEqual(image_processor.size   ,     {"""height""": 18, """width""": 18}						)

						__snake_case        =						self.image_processing_class.from_dict(self.image_processor_dict   ,     size=42						)
						self.assertEqual(image_processor.size   ,     {"""height""": 42, """width""": 42}						)




	def 				a_		( self	:						Optional[int]						)       ->			str:
						pass




	def 				a_		( self	:						Optional[Any]						)       ->			List[str]:
						# Initialize image_processing
						__snake_case        =						self.image_processing_class(**self.image_processor_dict						)
						# create random PIL images
						__snake_case        =						prepare_image_inputs(self.image_processor_tester   ,     equal_resolution=lowercase						)
						for image in image_inputs:
											self.assertIsInstance(lowercase   ,     Image.Image						)

						# Test not batched input
						__snake_case        =						image_processing(image_inputs[0]   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )

						# Test batched
						__snake_case        =						image_processing(lowercase   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )




	def 				a_		( self	:						Optional[Any]						)       ->			List[Any]:
						# Initialize image_processing
						__snake_case        =						self.image_processing_class(**self.image_processor_dict						)
						# create random numpy tensors
						__snake_case        =						prepare_image_inputs(self.image_processor_tester   ,     equal_resolution=lowercase   ,     numpify=lowercase						)
						for image in image_inputs:
											self.assertIsInstance(lowercase   ,     np.ndarray						)

						# Test not batched input
						__snake_case        =						image_processing(image_inputs[0]   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )

						# Test batched
						__snake_case        =						image_processing(lowercase   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )




	def 				a_		( self	:						Any						)       ->			Optional[Any]:
						# Initialize image_processing
						__snake_case        =						self.image_processing_class(**self.image_processor_dict						)
						# create random PyTorch tensors
						__snake_case        =						prepare_image_inputs(self.image_processor_tester   ,     equal_resolution=lowercase   ,     torchify=lowercase						)
						for image in image_inputs:
											self.assertIsInstance(lowercase   ,     torch.Tensor						)

						# Test not batched input
						__snake_case        =						image_processing(image_inputs[0]   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )

						# Test batched
						__snake_case        =						image_processing(lowercase   ,     return_tensors="""pt"""						).pixel_values
						self.assertEqual(
						    encoded_images.shape   ,     (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.size["""height"""],
						        self.image_processor_tester.size["""width"""],
						    )   ,     )








"""simple docstring"""

from .chunk_utils import chunk_layer
from .data_transforms import make_atomaa_masks
from .feats import atomaa_to_atomaa, frames_and_literature_positions_to_atomaa_pos, torsion_angles_to_frames
from .loss import compute_predicted_aligned_error, compute_tm
from .protein import Protein as OFProtein
from .protein import to_pdb
from .rigid_utils import Rigid, Rotation
from .tensor_utils import dict_multimap, flatten_final_dims, permute_final_dims


