



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_video_inputs


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import VideoMAEImageProcessor



class        lowerCAmelCase_	(						unittest.TestCase							):
       def __init__(    self,    SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_=7,    SCREAMING_SNAKE_CASE_=3,    SCREAMING_SNAKE_CASE_=10,    SCREAMING_SNAKE_CASE_=18,    SCREAMING_SNAKE_CASE_=30,    SCREAMING_SNAKE_CASE_=400,    SCREAMING_SNAKE_CASE_=True,    SCREAMING_SNAKE_CASE_=None,    SCREAMING_SNAKE_CASE_=True,    SCREAMING_SNAKE_CASE_=[0.5, 0.5, 0.5],    SCREAMING_SNAKE_CASE_=[0.5, 0.5, 0.5],    SCREAMING_SNAKE_CASE_=None,    )  ->	str:
          UpperCamelCase					:						Optional[int]					=			size if size is not None else {'shortest_edge': 18}
          UpperCamelCase					:						Union[str, Any]					=			crop_size if crop_size is not None else {'height': 18, 'width': 18}

          UpperCamelCase					:						List[Any]					=			parent
          UpperCamelCase					:						int					=			batch_size
          UpperCamelCase					:						List[Any]					=			num_channels
          UpperCamelCase					:						Optional[Any]					=			num_frames
          UpperCamelCase					:						Union[str, Any]					=			image_size
          UpperCamelCase					:						Dict					=			min_resolution
          UpperCamelCase					:						List[str]					=			max_resolution
          UpperCamelCase					:						Dict					=			do_resize
          UpperCamelCase					:						int					=			size
          UpperCamelCase					:						str					=			do_normalize
          UpperCamelCase					:						Optional[int]					=			image_mean
          UpperCamelCase					:						Any					=			image_std
          UpperCamelCase					:						Tuple					=			crop_size






       def       snake_case_ (    self )  ->	Dict:
          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_size": self.crop_size,
          }






@require_torch
@require_vision
class        lowerCAmelCase_	(						a__ ,					unittest.TestCase							):
       UpperCAmelCase__       :      List[str]       =						VideoMAEImageProcessor if is_vision_available() else None
       def       snake_case_ (    self )  ->	Dict:
          UpperCamelCase					:						Any					=			VideoMAEImageProcessingTester(self )
       @property
       def       snake_case_ (    self )  ->	List[str]:
          return self.image_processor_tester.prepare_image_processor_dict()
       def       snake_case_ (    self )  ->	Union[str, Any]:
          UpperCamelCase					:						Optional[Any]					=			self.image_processing_class(**self.image_processor_dict )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'image_mean' ) )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'image_std' ) )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'do_normalize' ) )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'do_resize' ) )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'do_center_crop' ) )
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,    'size' ) )
       def       snake_case_ (    self )  ->	int:
          UpperCamelCase					:						Tuple					=			self.image_processing_class.from_dict(self.image_processor_dict )
          self.assertEqual(image_processor.size,    {'shortest_edge': 18} )
          self.assertEqual(image_processor.crop_size,    {'height': 18, 'width': 18} )

          UpperCamelCase					:						Any					=			self.image_processing_class.from_dict(self.image_processor_dict,    size=42,    crop_size=84 )
          self.assertEqual(image_processor.size,    {'shortest_edge': 42} )
          self.assertEqual(image_processor.crop_size,    {'height': 84, 'width': 84} )
       def       snake_case_ (    self )  ->	Union[str, Any]:
          pass
       def       snake_case_ (    self )  ->	Union[str, Any]:
          # Initialize image_processing
          UpperCamelCase					:						List[Any]					=			self.image_processing_class(**self.image_processor_dict )
          # create random PIL videos
          UpperCamelCase					:						Dict					=			prepare_video_inputs(self.image_processor_tester,    equal_resolution=SCREAMING_SNAKE_CASE_ )
          for video in video_inputs:
             self.assertIsInstance(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_ )
             self.assertIsInstance(video[0],    Image.Image )

          # Test not batched input
          UpperCamelCase					:						str					=			image_processing(video_inputs[0],    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  1,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )

          # Test batched
          UpperCamelCase					:						str					=			image_processing(SCREAMING_SNAKE_CASE_,    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  self.image_processor_tester.batch_size,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )
       def       snake_case_ (    self )  ->	Dict:
          # Initialize image_processing
          UpperCamelCase					:						Union[str, Any]					=			self.image_processing_class(**self.image_processor_dict )
          # create random numpy tensors
          UpperCamelCase					:						Optional[Any]					=			prepare_video_inputs(self.image_processor_tester,    equal_resolution=SCREAMING_SNAKE_CASE_,    numpify=SCREAMING_SNAKE_CASE_ )
          for video in video_inputs:
             self.assertIsInstance(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_ )
             self.assertIsInstance(video[0],    np.ndarray )

          # Test not batched input
          UpperCamelCase					:						int					=			image_processing(video_inputs[0],    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  1,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )

          # Test batched
          UpperCamelCase					:						Optional[Any]					=			image_processing(SCREAMING_SNAKE_CASE_,    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  self.image_processor_tester.batch_size,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )






       def       snake_case_ (    self )  ->	Optional[Any]:
          # Initialize image_processing
          UpperCamelCase					:						List[Any]					=			self.image_processing_class(**self.image_processor_dict )
          # create random PyTorch tensors
          UpperCamelCase					:						Optional[int]					=			prepare_video_inputs(self.image_processor_tester,    equal_resolution=SCREAMING_SNAKE_CASE_,    torchify=SCREAMING_SNAKE_CASE_ )
          for video in video_inputs:
             self.assertIsInstance(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_ )
             self.assertIsInstance(video[0],    torch.Tensor )

          # Test not batched input
          UpperCamelCase					:						List[Any]					=			image_processing(video_inputs[0],    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  1,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )

          # Test batched
          UpperCamelCase					:						Optional[Any]					=			image_processing(SCREAMING_SNAKE_CASE_,    return_tensors='pt' ).pixel_values
          self.assertEqual(
              encoded_videos.shape,    (
                  self.image_processor_tester.batch_size,
                  self.image_processor_tester.num_frames,
                  self.image_processor_tester.num_channels,
                  self.image_processor_tester.crop_size['height'],
                  self.image_processor_tester.crop_size['width'],
              ),    )








from __future__ import annotations

import sys
def 	UpperCamelCase			(     snake_case__ :					int ,  snake_case__ :					int			)			->  tuple[int, int]:
   # base cases
   if abs(snake_case__			) == 1:
      return a, 0
   elif abs(snake_case__			) == 1:
      return 0, b

   UpperCamelCase			,  UpperCamelCase					:						Dict					=			a, b
   UpperCamelCase			,  UpperCamelCase					:						int					=			1, 0
   UpperCamelCase			,  UpperCamelCase					:						Union[str, Any]					=			0, 1

   while remainder != 0:
      UpperCamelCase					:						str					=			old_remainder // remainder
      UpperCamelCase			,  UpperCamelCase					:						Union[str, Any]					=			remainder, old_remainder - quotient * remainder
      UpperCamelCase			,  UpperCamelCase					:						List[Any]					=			coeff_a, old_coeff_a - quotient * coeff_a
      UpperCamelCase			,  UpperCamelCase					:						Optional[Any]					=			coeff_b, old_coeff_b - quotient * coeff_b

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

   return old_coeff_a, old_coeff_b
def 	UpperCamelCase			(     )			->  Tuple:
   if len(sys.argv			) < 3:
      print('2 integer arguments required'			)
      return 1
   UpperCamelCase					:						Union[str, Any]					=			int(sys.argv[1]			)
   UpperCamelCase					:						Optional[int]					=			int(sys.argv[2]			)
   print(extended_euclidean_algorithm(snake_case__ ,  snake_case__			)			)
   return 0


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



