





from __future__ import annotations

import sys


def 					__SCREAMING_SNAKE_CASE  (							__lowercase:		int     ,							__lowercase:		int):



  '''simple docstring'''






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

  __lowerCAmelCase			=				a, b
  __lowerCAmelCase			=				1, 0
  __lowerCAmelCase			=				0, 1

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

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

  return old_coeff_a, old_coeff_b


def 					__SCREAMING_SNAKE_CASE  (							):



  '''simple docstring'''






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


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







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 ViltImageProcessor

class   __snake_case				(			unittest.TestCase   ):






    '''simple docstring'''





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

      """simple docstring"""





      __lowerCAmelCase			=				size if size is not None else {'''shortest_edge''': 30}
      __lowerCAmelCase			=				parent
      __lowerCAmelCase			=				batch_size
      __lowerCAmelCase			=				num_channels
      __lowerCAmelCase			=				image_size
      __lowerCAmelCase			=				min_resolution
      __lowerCAmelCase			=				max_resolution
      __lowerCAmelCase			=				do_resize
      __lowerCAmelCase			=				size
      __lowerCAmelCase			=				size_divisor
      __lowerCAmelCase			=				do_normalize
      __lowerCAmelCase			=				image_mean
      __lowerCAmelCase			=				image_std





    def 	A		(   self						:		int							):

      """simple docstring"""





      return {
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_normalize": self.do_normalize,
          "do_resize": self.do_resize,
          "size": self.size,
          "size_divisor": self.size_divisor,
      }





    def 	A		(   self						:		Dict			,						snake_case						:		List[Any]			,						snake_case						:		Any=False							):

      """simple docstring"""





      if not batched:
        __lowerCAmelCase			=				self.size['''shortest_edge''']
        __lowerCAmelCase			=				image_inputs[0]
        if isinstance(snake_case			,						Image.Image							):
          __lowerCAmelCase	,						__lowerCAmelCase			=				image.size
        else:
          __lowerCAmelCase	,						__lowerCAmelCase			=				image.shape[1], image.shape[2]
        __lowerCAmelCase			=				size / min(snake_case			,						snake_case							)
        if h < w:
          __lowerCAmelCase	,						__lowerCAmelCase			=				size, scale * w
        else:
          __lowerCAmelCase	,						__lowerCAmelCase			=				scale * h, size

        __lowerCAmelCase			=				int((1_333 / 800) * size							)
        if max(snake_case			,						snake_case							) > max_size:
          __lowerCAmelCase			=				max_size / max(snake_case			,						snake_case							)
          __lowerCAmelCase			=				newh * scale
          __lowerCAmelCase			=				neww * scale

        __lowerCAmelCase	,						__lowerCAmelCase			=				int(newh + 0.5							), int(neww + 0.5							)
        __lowerCAmelCase	,						__lowerCAmelCase			=				(
            newh // self.size_divisor * self.size_divisor,
            neww // self.size_divisor * self.size_divisor,
        )

      else:
        __lowerCAmelCase			=				[]
        for image in image_inputs:
          __lowerCAmelCase	,						__lowerCAmelCase			=				self.get_expected_values([image]							)
          expected_values.append((expected_height, expected_width)							)
        __lowerCAmelCase			=				max(snake_case			,						key=lambda snake_case							: item[0]							)[0]
        __lowerCAmelCase			=				max(snake_case			,						key=lambda snake_case							: item[1]							)[1]

      return expected_height, expected_width


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






    '''simple docstring'''
    _lowerCAmelCase     =	ViltImageProcessor if is_vision_available() else None





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

      """simple docstring"""





      __lowerCAmelCase			=				ViltImageProcessingTester(self							)





    @property
    def 	A		(   self						:		Any							):

      """simple docstring"""





      return self.image_processor_tester.prepare_image_processor_dict()





    def 	A		(   self						:		List[Any]							):

      """simple docstring"""





      __lowerCAmelCase			=				self.image_processing_class(**self.image_processor_dict							)
      self.assertTrue(hasattr(snake_case			,						'''image_mean'''							)							)
      self.assertTrue(hasattr(snake_case			,						'''image_std'''							)							)
      self.assertTrue(hasattr(snake_case			,						'''do_normalize'''							)							)
      self.assertTrue(hasattr(snake_case			,						'''do_resize'''							)							)
      self.assertTrue(hasattr(snake_case			,						'''size'''							)							)
      self.assertTrue(hasattr(snake_case			,						'''size_divisor'''							)							)





    def 	A		(   self						:		Optional[Any]							):

      """simple docstring"""





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

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





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

      """simple docstring"""





      pass





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

      """simple docstring"""





      __lowerCAmelCase			=				self.image_processing_class(**self.image_processor_dict							)
      # create random PIL images
      __lowerCAmelCase			=				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
      __lowerCAmelCase			=				image_processing(image_inputs[0]			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(1, self.image_processor_tester.num_channels, expected_height, expected_width)			,						)

      # Test batched
      __lowerCAmelCase			=				image_processing(snake_case			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case			,						batched=snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )			,						)





    def 	A		(   self						:		Tuple							):

      """simple docstring"""





      __lowerCAmelCase			=				self.image_processing_class(**self.image_processor_dict							)
      # create random numpy tensors
      __lowerCAmelCase			=				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
      __lowerCAmelCase			=				image_processing(image_inputs[0]			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(1, self.image_processor_tester.num_channels, expected_height, expected_width)			,						)

      # Test batched
      __lowerCAmelCase			=				image_processing(snake_case			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case			,						batched=snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )			,						)





    def 	A		(   self						:		List[str]							):

      """simple docstring"""





      __lowerCAmelCase			=				self.image_processing_class(**self.image_processor_dict							)
      # create random PyTorch tensors
      __lowerCAmelCase			=				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
      __lowerCAmelCase			=				image_processing(image_inputs[0]			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(1, self.image_processor_tester.num_channels, expected_height, expected_width)			,						)

      # Test batched
      __lowerCAmelCase			=				image_processing(snake_case			,						return_tensors='''pt'''							).pixel_values

      __lowerCAmelCase	,						__lowerCAmelCase			=				self.image_processor_tester.get_expected_values(snake_case			,						batched=snake_case							)
      self.assertEqual(
          encoded_images.shape			,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )			,						)
