




'''simple docstring'''

import unittest

import numpy as np

from transformers.testing_utils import is_flaky, 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 DonutImageProcessor



class 		SCREAMING_SNAKE_CASE__  (			unittest.TestCase	):





			def __init__(      self						:    Any      ,		a_						:    List[str]      ,		a_						:    Dict=7      ,		a_						:    List[str]=3      ,		a_						:    Union[str, Any]=18      ,		a_						:    str=30      ,		a_						:    Tuple=400      ,		a_						:    List[Any]=True      ,		a_						:    Tuple=None      ,		a_						:    Dict=True      ,		a_						:    Union[str, Any]=False      ,		a_						:    str=True      ,		a_						:    int=True      ,		a_						:    Optional[int]=[0.5, 0.5, 0.5]      ,		a_						:    List[str]=[0.5, 0.5, 0.5]      ,		):



						"""simple docstring"""




						__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 if size is not None else {'''height''': 18, '''width''': 20}
						__snake_case			=		do_thumbnail
						__snake_case			=		do_align_axis
						__snake_case			=		do_pad
						__snake_case			=		do_normalize
						__snake_case			=		image_mean
						__snake_case			=		image_std






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



						"""simple docstring"""




						return {
						    "do_resize": self.do_resize,
						    "size": self.size,
						    "do_thumbnail": self.do_thumbnail,
						    "do_align_long_axis": self.do_align_axis,
						    "do_pad": self.do_pad,
						    "do_normalize": self.do_normalize,
						    "image_mean": self.image_mean,
						    "image_std": self.image_std,
						}







@require_torch
@require_vision
class 		SCREAMING_SNAKE_CASE__  (			SCREAMING_SNAKE_CASE__				,     unittest.TestCase	):
			__SCREAMING_SNAKE_CASE    =			DonutImageProcessor if is_vision_available() else None





			def 							A (      self						:    Optional[int]							):



						"""simple docstring"""




						__snake_case			=		DonutImageProcessingTester(self							)





			@property
			def 							A (      self						:    Union[str, Any]							):



						"""simple docstring"""




						return self.image_processor_tester.prepare_image_processor_dict()





			def 							A (      self						:    List[str]							):



						"""simple docstring"""




						__snake_case			=		self.image_processing_class(**self.image_processor_dict							)
						self.assertTrue(hasattr(A_      ,		"do_resize"							)							)
						self.assertTrue(hasattr(A_      ,		"size"							)							)
						self.assertTrue(hasattr(A_      ,		"do_thumbnail"							)							)
						self.assertTrue(hasattr(A_      ,		"do_align_long_axis"							)							)
						self.assertTrue(hasattr(A_      ,		"do_pad"							)							)
						self.assertTrue(hasattr(A_      ,		"do_normalize"							)							)
						self.assertTrue(hasattr(A_      ,		"image_mean"							)							)
						self.assertTrue(hasattr(A_      ,		"image_std"							)							)





			def 							A (      self						:    List[str]							):



						"""simple docstring"""




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

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

						# Previous config had dimensions in (width, height) order
						__snake_case			=		self.image_processing_class.from_dict(self.image_processor_dict      ,		size=(42, 84)							)
						self.assertEqual(image_processor.size      ,		{"height": 84, "width": 42}							)





			def 							A (      self						:    List[str]							):



						"""simple docstring"""




						pass





			@is_flaky()
			def 							A (      self						:    int							):



						"""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=A_							)
						for image in image_inputs:
									self.assertIsInstance(A_      ,		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(A_      ,		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"],
						    )      ,		)





			@is_flaky()
			def 							A (      self						:    Union[str, Any]							):



						"""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=A_      ,		numpify=A_							)
						for image in image_inputs:
									self.assertIsInstance(A_      ,		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(A_      ,		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"],
						    )      ,		)






			@is_flaky()
			def 							A (      self						:    Optional[int]							):



						"""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=A_      ,		torchify=A_							)
						for image in image_inputs:
									self.assertIsInstance(A_      ,		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(A_      ,		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 __future__ import annotations

import typing
from collections import Counter




def 			_lowerCAmelCase		(		_UpperCamelCase    ):






  """simple docstring"""



  _lowercase:      typing.Counter[int]   			=  Counter()
  for base in range(1			,					max_perimeter + 1    ):
    for perpendicular in range(_UpperCamelCase			,					max_perimeter + 1    ):
      _lowercase:      str   			=  (base * base + perpendicular * perpendicular) ** 0.5
      if hypotenuse == int(_UpperCamelCase    ):
        _lowercase:      str   			=  int(base + perpendicular + hypotenuse    )
        if perimeter > max_perimeter:
          continue
        triplets[perimeter] += 1
  return triplets




def 			_lowerCAmelCase		(		_UpperCamelCase = 1_000    ):






  """simple docstring"""



  _lowercase:      int   			=  pythagorean_triple(_UpperCamelCase    )
  return triplets.most_common(1    )[0][0]


if __name__ == "__main__":
  print(f"""Perimeter {solution()} has maximum solutions""")
