




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 ViTImageProcessor




class 		UpperCamelCase__	(unittest.TestCase     ):

    '''simple docstring'''



    def __init__(    self     ,  UpperCamelCase__     ,  UpperCamelCase__=13     ,  UpperCamelCase__=3     ,  UpperCamelCase__=224     ,  UpperCamelCase__=30     ,  UpperCamelCase__=400     ,  UpperCamelCase__=True     ,  UpperCamelCase__=None     ,  UpperCamelCase__=True     ,  UpperCamelCase__=[0.5, 0.5, 0.5]     ,  UpperCamelCase__=[0.5, 0.5, 0.5]     ,  )     ->      str:
           lowerCamelCase   :      int			 =					size if size is not None else {"height": 18, "width": 18}
           lowerCamelCase   :      int			 =					parent
           lowerCamelCase   :      str			 =					batch_size
           lowerCamelCase   :      List[Any]			 =					num_channels
           lowerCamelCase   :      Any			 =					image_size
           lowerCamelCase   :      Optional[int]			 =					min_resolution
           lowerCamelCase   :      Dict			 =					max_resolution
           lowerCamelCase   :      Tuple			 =					do_resize
           lowerCamelCase   :      Tuple			 =					size
           lowerCamelCase   :      Tuple			 =					do_normalize
           lowerCamelCase   :      Any			 =					image_mean
           lowerCamelCase   :      int			 =					image_std







    def     _lowercase     (    self     )     ->      List[Any]:
           return {
               "image_mean": self.image_mean,
               "image_std": self.image_std,
               "do_normalize": self.do_normalize,
               "do_resize": self.do_resize,
               "size": self.size,
           }




@require_torch
@require_vision
class 		UpperCamelCase__	(lowerCAmelCase__    ,				unittest.TestCase     ):

    '''simple docstring'''



    lowerCamelCase_      :	Dict	     =      ViTImageProcessor if is_vision_available() else None







    def     _lowercase     (    self     )     ->      List[Any]:
           lowerCamelCase   :      List[Any]			 =					EfficientFormerImageProcessorTester(self     )







    @property
    def     _lowercase     (    self     )     ->      Tuple:
           return self.image_proc_tester.prepare_image_processor_dict()







    def     _lowercase     (    self     )     ->      Optional[int]:
           lowerCamelCase   :      Dict			 =					self.image_processing_class(**self.image_processor_dict     )
           self.assertTrue(hasattr(UpperCamelCase__     ,  "image_mean"     )     )
           self.assertTrue(hasattr(UpperCamelCase__     ,  "image_std"     )     )
           self.assertTrue(hasattr(UpperCamelCase__     ,  "do_normalize"     )     )
           self.assertTrue(hasattr(UpperCamelCase__     ,  "do_resize"     )     )
           self.assertTrue(hasattr(UpperCamelCase__     ,  "size"     )     )







    def     _lowercase     (    self     )     ->      List[Any]:
           pass







    def     _lowercase     (    self     )     ->      List[str]:
           # Initialize image_processor
           lowerCamelCase   :      int			 =					self.image_processing_class(**self.image_processor_dict     )
           # create random PIL images
           lowerCamelCase   :      Tuple			 =					prepare_image_inputs(self.image_proc_tester     ,  equal_resolution=UpperCamelCase__     )
           for image in image_inputs:
                  self.assertIsInstance(UpperCamelCase__     ,  Image.Image     )

           # Test not batched input
           lowerCamelCase   :      Dict			 =					image_processor(image_inputs[0]     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )

           # Test batched
           lowerCamelCase   :      Union[str, Any]			 =					image_processor(UpperCamelCase__     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )







    def     _lowercase     (    self     )     ->      str:
           # Initialize image_processor
           lowerCamelCase   :      Dict			 =					self.image_processing_class(**self.image_processor_dict     )
           # create random numpy tensors
           lowerCamelCase   :      Optional[int]			 =					prepare_image_inputs(self.image_proc_tester     ,  equal_resolution=UpperCamelCase__     ,  numpify=UpperCamelCase__     )
           for image in image_inputs:
                  self.assertIsInstance(UpperCamelCase__     ,  np.ndarray     )

           # Test not batched input
           lowerCamelCase   :      List[Any]			 =					image_processor(image_inputs[0]     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )

           # Test batched
           lowerCamelCase   :      Tuple			 =					image_processor(UpperCamelCase__     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )







    def     _lowercase     (    self     )     ->      int:
           # Initialize image_processor
           lowerCamelCase   :      Tuple			 =					self.image_processing_class(**self.image_processor_dict     )
           # create random PyTorch tensors
           lowerCamelCase   :      int			 =					prepare_image_inputs(self.image_proc_tester     ,  equal_resolution=UpperCamelCase__     ,  torchify=UpperCamelCase__     )
           for image in image_inputs:
                  self.assertIsInstance(UpperCamelCase__     ,  torch.Tensor     )

           # Test not batched input
           lowerCamelCase   :      Union[str, Any]			 =					image_processor(image_inputs[0]     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )

           # Test batched
           lowerCamelCase   :      Tuple			 =					image_processor(UpperCamelCase__     ,  return_tensors="pt"     ).pixel_values
           self.assertEqual(
               encoded_images.shape     ,  (
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size["height"],
                   self.image_proc_tester.size["width"],
               )     ,  )












def      A      (      _SCREAMING_SNAKE_CASE    )	-> list:
       if n_term == "":
              return []
       lowerCamelCase   :      list			 =					[]
       for temp in range(int(_SCREAMING_SNAKE_CASE    )    ):
              series.append(f'''1/{temp + 1}''' if series else "1"    )
       return series


if __name__ == "__main__":
       SCREAMING_SNAKE_CASE__       :      Dict  =   input('Enter the last number (nth term) of the Harmonic Series')
       print('Formula of Harmonic Series => 1+1/2+1/3 ..... 1/n')
       print(harmonic_series(nth_term))






