






"""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


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import SwinaSRImageProcessor
    from transformers.image_transforms import get_image_size

class 	a					(       unittest.TestCase     ):







    def __init__(      self							,		_lowerCamelCase							,		_lowerCamelCase=7							,		_lowerCamelCase=3							,		_lowerCamelCase=1_8							,		_lowerCamelCase=3_0							,		_lowerCamelCase=4_0_0							,		_lowerCamelCase=True							,		_lowerCamelCase=1 / 2_5_5							,		_lowerCamelCase=True							,		_lowerCamelCase=8							,		):
      lowercase							   =	parent
      lowercase							   =	batch_size
      lowercase							   =	num_channels
      lowercase							   =	image_size
      lowercase							   =	min_resolution
      lowercase							   =	max_resolution
      lowercase							   =	do_rescale
      lowercase							   =	rescale_factor
      lowercase							   =	do_pad
      lowercase							   =	pad_size







    def       UpperCamelCase_				(      self	):
      return {
          "do_rescale": self.do_rescale,
          "rescale_factor": self.rescale_factor,
          "do_pad": self.do_pad,
          "pad_size": self.pad_size,
      }







    def       UpperCamelCase_				(      self							,		_lowerCamelCase=False							,		_lowerCamelCase=False							,		_lowerCamelCase=False	):
      assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

      if equal_resolution:
        lowercase							   =	[]
        for i in range(self.batch_size	):
          image_inputs.append(
              np.random.randint(
                  2_5_5							,		size=(self.num_channels, self.max_resolution, self.max_resolution)							,		dtype=np.uinta	)	)
      else:
        lowercase							   =	[]
        for i in range(self.batch_size	):
          lowercase   ,					lowercase							   =	np.random.choice(np.arange(self.min_resolution							,		self.max_resolution	)							,		2	)
          image_inputs.append(np.random.randint(2_5_5							,		size=(self.num_channels, width, height)							,		dtype=np.uinta	)	)

      if not numpify and not torchify:
        # PIL expects the channel dimension as last dimension
        lowercase							   =	[Image.fromarray(np.moveaxis(_lowerCamelCase							,		0							,		-1	)	) for x in image_inputs]

      if torchify:
        lowercase							   =	[torch.from_numpy(_lowerCamelCase	) for x in image_inputs]

      return image_inputs


@require_torch
@require_vision
class 	a					(       a_,    unittest.TestCase     ):
    UpperCAmelCase_			:					Dict     					=SwinaSRImageProcessor if is_vision_available() else None







    def       UpperCamelCase_				(      self	):
      lowercase							   =	SwinaSRImageProcessingTester(self	)







    @property
    def       UpperCamelCase_				(      self	):
      return self.image_processor_tester.prepare_image_processor_dict()







    def       UpperCamelCase_				(      self	):
      lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
      self.assertTrue(hasattr(_lowerCamelCase							,		'do_rescale'	)	)
      self.assertTrue(hasattr(_lowerCamelCase							,		'rescale_factor'	)	)
      self.assertTrue(hasattr(_lowerCamelCase							,		'do_pad'	)	)
      self.assertTrue(hasattr(_lowerCamelCase							,		'pad_size'	)	)







    def       UpperCamelCase_				(      self	):
      pass







    def       UpperCamelCase_				(      self							,		_lowerCamelCase	):
      lowercase   ,					lowercase							   =	get_image_size(_lowerCamelCase	)
      lowercase							   =	self.image_processor_tester.pad_size

      lowercase							   =	(old_height // size + 1) * size - old_height
      lowercase							   =	(old_width // size + 1) * size - old_width
      return old_height + pad_height, old_width + pad_width







    def       UpperCamelCase_				(      self	):
      # Initialize image_processor
      lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
      # create random PIL images
      lowercase							   =	self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase	)
      for image in image_inputs:
        self.assertIsInstance(_lowerCamelCase							,		Image.Image	)

      # Test not batched input
      lowercase							   =	image_processor(image_inputs[0]							,		return_tensors='pt'	).pixel_values
      lowercase   ,					lowercase							   =	self.calculate_expected_size(np.array(image_inputs[0]	)	)
      self.assertEqual(
          encoded_images.shape							,		(
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )							,		)







    def       UpperCamelCase_				(      self	):
      # Initialize image_processor
      lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
      # create random numpy tensors
      lowercase							   =	self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase							,		numpify=_lowerCamelCase	)
      for image in image_inputs:
        self.assertIsInstance(_lowerCamelCase							,		np.ndarray	)

      # Test not batched input
      lowercase							   =	image_processor(image_inputs[0]							,		return_tensors='pt'	).pixel_values
      lowercase   ,					lowercase							   =	self.calculate_expected_size(image_inputs[0]	)
      self.assertEqual(
          encoded_images.shape							,		(
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )							,		)







    def       UpperCamelCase_				(      self	):
      # Initialize image_processor
      lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
      # create random PyTorch tensors
      lowercase							   =	self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase							,		torchify=_lowerCamelCase	)
      for image in image_inputs:
        self.assertIsInstance(_lowerCamelCase							,		torch.Tensor	)

      # Test not batched input
      lowercase							   =	image_processor(image_inputs[0]							,		return_tensors='pt'	).pixel_values
      lowercase   ,					lowercase							   =	self.calculate_expected_size(image_inputs[0]	)
      self.assertEqual(
          encoded_images.shape							,		(
              1,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )							,		)










"""simple docstring"""



def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  for a in range(3_00   ):
    for b in range(a + 1		, 4_00   ):
      for c in range(b + 1		, 5_00   ):
        if (a + b + c) == 10_00 and (a**2) + (b**2) == (c**2):
          return a * b * c

  return -1
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  for a in range(3_00   ):
    for b in range(4_00   ):
      lowercase							   =	10_00 - a - b
      if a < b < c and (a**2) + (b**2) == (c**2):
        return a * b * c

  return -1
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  import timeit

  print(
      timeit.timeit('solution()'		, setup='from __main__ import solution'		, number=10_00   )   )
  print(
      timeit.timeit(
          'solution_fast()'		, setup='from __main__ import solution_fast'		, number=10_00   )   )


if __name__ == "__main__":
    print(F'''{solution() = }''')


