




'''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 MobileNetVaImageProcessor





class __magic_name__(						unittest.TestCase      ):






						def __init__(   self						:						int					,   __UpperCamelCase						:						List[Any]					,   __UpperCamelCase						:						int=7					,   __UpperCamelCase						:						Optional[Any]=3					,   __UpperCamelCase						:						Dict=1_8					,   __UpperCamelCase						:						Tuple=3_0					,   __UpperCamelCase						:						List[Any]=4_0_0					,   __UpperCamelCase						:						List[str]=True					,   __UpperCamelCase						:						Any=None					,   __UpperCamelCase						:						int=True					,   __UpperCamelCase						:						Optional[int]=None					,   ):



									'''simple docstring'''






									snake_case__          =						size if size is not None else {"""shortest_edge""": 2_0}
									snake_case__          =						crop_size if crop_size is not None else {"""height""": 1_8, """width""": 1_8}
									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_center_crop
									snake_case__          =						crop_size







						def       __lowerCAmelCase(   self						:						Dict       ):



									'''simple docstring'''






									return {
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "do_center_crop": self.do_center_crop,
									    "crop_size": self.crop_size,
									}







@require_torch
@require_vision
class __magic_name__(						__lowerCAmelCase    ,		unittest.TestCase      ):
						UpperCAmelCase_		:					Optional[Any]    =  MobileNetVaImageProcessor if is_vision_available() else None






						def       __lowerCAmelCase(   self						:						Dict       ):



									'''simple docstring'''






									snake_case__          =						MobileNetVaImageProcessingTester(self       )






						@property
						def       __lowerCAmelCase(   self						:						int       ):



									'''simple docstring'''






									return self.image_processor_tester.prepare_image_processor_dict()






						def       __lowerCAmelCase(   self						:						Optional[int]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									self.assertTrue(hasattr(__UpperCamelCase					,   """do_resize"""       )       )
									self.assertTrue(hasattr(__UpperCamelCase					,   """size"""       )       )
									self.assertTrue(hasattr(__UpperCamelCase					,   """do_center_crop"""       )       )
									self.assertTrue(hasattr(__UpperCamelCase					,   """center_crop"""       )       )






						def       __lowerCAmelCase(   self						:						Optional[int]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class.from_dict(self.image_processor_dict       )
									self.assertEqual(image_processor.size					,   {"""shortest_edge""": 2_0}       )
									self.assertEqual(image_processor.crop_size					,   {"""height""": 1_8, """width""": 1_8}       )

									snake_case__          =						self.image_processing_class.from_dict(self.image_processor_dict					,   size=4_2					,   crop_size=8_4       )
									self.assertEqual(image_processor.size					,   {"""shortest_edge""": 4_2}       )
									self.assertEqual(image_processor.crop_size					,   {"""height""": 8_4, """width""": 8_4}       )






						def       __lowerCAmelCase(   self						:						Optional[int]       ):



									'''simple docstring'''






									pass






						def       __lowerCAmelCase(   self						:						Union[str, Any]       ):



									'''simple docstring'''






									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=__UpperCamelCase       )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )

									# Test batched
									snake_case__          =						image_processing(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )






						def       __lowerCAmelCase(   self						:						int       ):



									'''simple docstring'''






									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=__UpperCamelCase					,   numpify=__UpperCamelCase       )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )

									# Test batched
									snake_case__          =						image_processing(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )







						def       __lowerCAmelCase(   self						:						Tuple       ):



									'''simple docstring'''






									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=__UpperCamelCase					,   torchify=__UpperCamelCase       )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )

									# Test batched
									snake_case__          =						image_processing(__UpperCamelCase					,   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.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )					,   )



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




