






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

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=None							,		_lowerCamelCase=True							,		_lowerCamelCase=None							,		_lowerCamelCase=True							,		_lowerCamelCase=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3]							,		_lowerCamelCase=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1]							,		_lowerCamelCase=True							,		):
       lowercase							   =	parent
       lowercase							   =	batch_size
       lowercase							   =	num_channels
       lowercase							   =	image_size
       lowercase							   =	min_resolution
       lowercase							   =	max_resolution
       lowercase							   =	do_resize
       lowercase							   =	size if size is not None else {'height': 1_8, 'width': 1_8}
       lowercase							   =	do_center_crop
       lowercase							   =	crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}
       lowercase							   =	do_normalize
       lowercase							   =	image_mean
       lowercase							   =	image_std
       lowercase							   =	do_convert_rgb







     def       UpperCamelCase_				(      self	):
       return {
           "do_resize": self.do_resize,
           "size": self.size,
           "do_center_crop": self.do_center_crop,
           "crop_size": self.crop_size,
           "do_normalize": self.do_normalize,
           "image_mean": self.image_mean,
           "image_std": self.image_std,
           "do_convert_rgb": self.do_convert_rgb,
       }


@require_torch
@require_vision
class 	a					(       lowerCAmelCase_,    unittest.TestCase     ):
     UpperCAmelCase_			:					Any     					=OwlViTImageProcessor if is_vision_available() else None







     def       UpperCamelCase_				(      self	):
       lowercase							   =	OwlViTImageProcessingTester(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(_snake_case							,		'do_resize'	)	)
       self.assertTrue(hasattr(_snake_case							,		'size'	)	)
       self.assertTrue(hasattr(_snake_case							,		'do_center_crop'	)	)
       self.assertTrue(hasattr(_snake_case							,		'center_crop'	)	)
       self.assertTrue(hasattr(_snake_case							,		'do_normalize'	)	)
       self.assertTrue(hasattr(_snake_case							,		'image_mean'	)	)
       self.assertTrue(hasattr(_snake_case							,		'image_std'	)	)
       self.assertTrue(hasattr(_snake_case							,		'do_convert_rgb'	)	)







     def       UpperCamelCase_				(      self	):
       lowercase							   =	self.image_processing_class.from_dict(self.image_processor_dict	)
       self.assertEqual(image_processor.size							,		{'height': 1_8, 'width': 1_8}	)
       self.assertEqual(image_processor.crop_size							,		{'height': 1_8, 'width': 1_8}	)

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







     def       UpperCamelCase_				(      self	):
       # Initialize image_processing
       lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
       # create random PIL images
       lowercase							   =	prepare_image_inputs(self.image_processor_tester							,		equal_resolution=_snake_case	)

       for image in image_inputs:
         self.assertIsInstance(_snake_case							,		Image.Image	)

       # Test not batched input
       lowercase							   =	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
       lowercase							   =	image_processing(_snake_case							,		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       UpperCamelCase_				(      self	):
       # Initialize image_processing
       lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
       # create random numpy tensors
       lowercase							   =	prepare_image_inputs(self.image_processor_tester							,		equal_resolution=_snake_case							,		numpify=_snake_case	)
       for image in image_inputs:
         self.assertIsInstance(_snake_case							,		np.ndarray	)

       # Test not batched input
       lowercase							   =	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
       lowercase							   =	image_processing(_snake_case							,		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       UpperCamelCase_				(      self	):
       # Initialize image_processing
       lowercase							   =	self.image_processing_class(**self.image_processor_dict	)
       # create random PyTorch tensors
       lowercase							   =	prepare_image_inputs(self.image_processor_tester							,		equal_resolution=_snake_case							,		torchify=_snake_case	)
       for image in image_inputs:
         self.assertIsInstance(_snake_case							,		torch.Tensor	)

       # Test not batched input
       lowercase							   =	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
       lowercase							   =	image_processing(_snake_case							,		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'],
           )							,		)










"""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() = }''')


