





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 ConvNextImageProcessor







class 						_lowerCAmelCase(						unittest.TestCase):

  """simple docstring"""







  def __init__( self  ,    UpperCAmelCase  ,    UpperCAmelCase=7  ,    UpperCAmelCase=3  ,    UpperCAmelCase=18  ,    UpperCAmelCase=30  ,    UpperCAmelCase=4_00  ,    UpperCAmelCase=True  ,    UpperCAmelCase=None  ,    UpperCAmelCase=0.875  ,    UpperCAmelCase=True  ,    UpperCAmelCase=[0.5, 0.5, 0.5]  ,    UpperCAmelCase=[0.5, 0.5, 0.5]  ,    )-> str:
     __A				 =       size if size is not None else {'''shortest_edge''': 20}
     __A				 =       parent
     __A				 =       batch_size
     __A				 =       num_channels
     __A				 =       image_size
     __A				 =       min_resolution
     __A				 =       max_resolution
     __A				 =       do_resize
     __A				 =       size
     __A				 =       crop_pct
     __A				 =       do_normalize
     __A				 =       image_mean
     __A				 =       image_std





  def 		SCREAMING_SNAKE_CASE__	( self     )-> int:
     return {
         "image_mean": self.image_mean,
         "image_std": self.image_std,
         "do_normalize": self.do_normalize,
         "do_resize": self.do_resize,
         "size": self.size,
         "crop_pct": self.crop_pct,
     }







@require_torch
@require_vision
class 						_lowerCAmelCase(						_a		,   unittest.TestCase):

  """simple docstring"""







  lowerCamelCase__      					=   ConvNextImageProcessor if is_vision_available() else None

  def 		SCREAMING_SNAKE_CASE__	( self     )-> Any:
     __A				 =       ConvNextImageProcessingTester(self     )

  @property
  def 		SCREAMING_SNAKE_CASE__	( self     )-> int:
     return self.image_processor_tester.prepare_image_processor_dict()

  def 		SCREAMING_SNAKE_CASE__	( self     )-> Dict:
     __A				 =       self.image_processing_class(**self.image_processor_dict     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''do_resize'''     )     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''size'''     )     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''crop_pct'''     )     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''do_normalize'''     )     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''image_mean'''     )     )
     self.assertTrue(hasattr(UpperCAmelCase  ,    '''image_std'''     )     )

  def 		SCREAMING_SNAKE_CASE__	( self     )-> Optional[int]:
     __A				 =       self.image_processing_class.from_dict(self.image_processor_dict     )
     self.assertEqual(image_processor.size  ,    {'''shortest_edge''': 20}     )

     __A				 =       self.image_processing_class.from_dict(self.image_processor_dict  ,    size=42     )
     self.assertEqual(image_processor.size  ,    {'''shortest_edge''': 42}     )

  def 		SCREAMING_SNAKE_CASE__	( self     )-> List[str]:
     pass

  def 		SCREAMING_SNAKE_CASE__	( self     )-> Tuple:
     # Initialize image_processing
     __A				 =       self.image_processing_class(**self.image_processor_dict     )
     # create random PIL images
     __A				 =       prepare_image_inputs(self.image_processor_tester  ,    equal_resolution=UpperCAmelCase     )
     for image in image_inputs:
        self.assertIsInstance(UpperCAmelCase  ,    Image.Image     )

     # Test not batched input
     __A				 =       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['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )

     # Test batched
     __A				 =       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.size['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )

  def 		SCREAMING_SNAKE_CASE__	( self     )-> Dict:
     # Initialize image_processing
     __A				 =       self.image_processing_class(**self.image_processor_dict     )
     # create random numpy tensors
     __A				 =       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
     __A				 =       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['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )

     # Test batched
     __A				 =       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.size['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )





  def 		SCREAMING_SNAKE_CASE__	( self     )-> Optional[Any]:
     # Initialize image_processing
     __A				 =       self.image_processing_class(**self.image_processor_dict     )
     # create random PyTorch tensors
     __A				 =       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
     __A				 =       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['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )

     # Test batched
     __A				 =       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.size['''shortest_edge'''],
             self.image_processor_tester.size['''shortest_edge'''],
         )  ,    )








from __future__ import annotations

import sys
def 				__UpperCamelCase  (		snake_case    ,	snake_case     )  ->						tuple[int, int]:


   '''simple docstring'''







   if abs(snake_case     ) == 1:
      return a, 0
   elif abs(snake_case     ) == 1:
      return 0, b

   __A ,						__A				 =       a, b
   __A ,						__A				 =       1, 0
   __A ,						__A				 =       0, 1

   while remainder != 0:
      __A				 =       old_remainder // remainder
      __A ,						__A				 =       remainder, old_remainder - quotient * remainder
      __A ,						__A				 =       coeff_a, old_coeff_a - quotient * coeff_a
      __A ,						__A				 =       coeff_b, old_coeff_b - quotient * coeff_b

   # sign correction for negative numbers
   if a < 0:
      __A				 =       -old_coeff_a
   if b < 0:
      __A				 =       -old_coeff_b

   return old_coeff_a, old_coeff_b
def 				__UpperCamelCase  (		)  ->						Tuple:


   '''simple docstring'''







   if len(sys.argv     ) < 3:
      print('''2 integer arguments required'''     )
      return 1
   __A				 =       int(sys.argv[1]     )
   __A				 =       int(sys.argv[2]     )
   print(extended_euclidean_algorithm(snake_case    ,	snake_case     )     )
   return 0


if __name__ == "__main__":
    raise SystemExit(main())

