
'''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


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import BlipImageProcessor







class 	__lowerCAmelCase    (  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__=False						,	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						,	):
          _UpperCAmelCase					:  int         =    size if size is not None else {"""height""": 2_0, """width""": 2_0}
          _UpperCAmelCase					:  Any         =    parent
          _UpperCAmelCase					:  int         =    batch_size
          _UpperCAmelCase					:  str         =    num_channels
          _UpperCAmelCase					:  str         =    image_size
          _UpperCAmelCase					:  Union[str, Any]         =    min_resolution
          _UpperCAmelCase					:  Any         =    max_resolution
          _UpperCAmelCase					:  List[str]         =    do_resize
          _UpperCAmelCase					:  Optional[int]         =    size
          _UpperCAmelCase					:  List[Any]         =    do_normalize
          _UpperCAmelCase					:  Optional[int]         =    image_mean
          _UpperCAmelCase					:  List[Any]         =    image_std
          _UpperCAmelCase					:  Optional[int]         =    do_pad
          _UpperCAmelCase					:  Union[str, Any]         =    do_convert_rgb



     def     snake_case_ (self	):
          return {
              "do_resize": self.do_resize,
              "size": self.size,
              "do_normalize": self.do_normalize,
              "image_mean": self.image_mean,
              "image_std": self.image_std,
              "do_convert_rgb": self.do_convert_rgb,
              "do_pad": self.do_pad,
          }



     def     snake_case_ (self						,	lowerCAmelCase__=False						,	lowerCAmelCase__=False						,	lowerCAmelCase__=False	):
          assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

          if equal_resolution:
               _UpperCAmelCase					:  Tuple         =    []
               for i in range(self.batch_size	):
                    image_inputs.append(
                        np.random.randint(
                            2_5_5						,	size=(self.num_channels, self.max_resolution, self.max_resolution)						,	dtype=np.uinta	)	)
          else:
               _UpperCAmelCase					:  str         =    []
               for i in range(self.batch_size	):
                    _UpperCAmelCase  ,     _UpperCAmelCase					:  str         =    np.random.choice(np.arange(self.min_resolution						,	self.max_resolution	)						,	2	)
                    image_inputs.append(np.random.randint(2_5_5						,	size=(self.num_channels, width, height)						,	dtype=np.uinta	)	)

          if not numpify and not torchify:
               # PIL expects the channel dimension as last dimension
               _UpperCAmelCase					:  str         =    [Image.fromarray(np.moveaxis(lowerCAmelCase__						,	0						,	-1	)	) for x in image_inputs]

          if torchify:
               _UpperCAmelCase					:  Optional[int]         =    [torch.from_numpy(lowerCAmelCase__	) for x in image_inputs]

          return image_inputs







@require_torch
@require_vision
class 	__lowerCAmelCase    (  __a       ,					unittest.TestCase				):
     snake_case   :    Optional[Any]							      =      BlipImageProcessor if is_vision_available() else None



     def     snake_case_ (self	):
          _UpperCAmelCase					:  List[str]         =    BlipImageProcessingTester(self	)



     @property
     def     snake_case_ (self	):
          return self.image_processor_tester.prepare_image_processor_dict()



     def     snake_case_ (self	):
          _UpperCAmelCase					:  int         =    self.image_processing_class(**self.image_processor_dict	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_resize"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""size"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_normalize"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""image_mean"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""image_std"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_convert_rgb"""	)	)



     def     snake_case_ (self	):
          pass



     def     snake_case_ (self	):
          # Initialize image_processor
          _UpperCAmelCase					:  Any         =    self.image_processing_class(**self.image_processor_dict	)
          # create random PIL images
          _UpperCAmelCase					:  int         =    self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase__	)
          for image in image_inputs:
               self.assertIsInstance(lowerCAmelCase__						,	Image.Image	)

          # Test not batched input
          _UpperCAmelCase					:  Any         =    image_processor(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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)

          # Test batched
          _UpperCAmelCase					:  Optional[int]         =    image_processor(lowerCAmelCase__						,	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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)



     def     snake_case_ (self	):
          # Initialize image_processor
          _UpperCAmelCase					:  Dict         =    self.image_processing_class(**self.image_processor_dict	)
          # create random numpy tensors
          _UpperCAmelCase					:  Optional[int]         =    self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase__						,	numpify=lowerCAmelCase__	)
          for image in image_inputs:
               self.assertIsInstance(lowerCAmelCase__						,	np.ndarray	)

          # Test not batched input
          _UpperCAmelCase					:  Optional[Any]         =    image_processor(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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)

          # Test batched
          _UpperCAmelCase					:  Any         =    image_processor(lowerCAmelCase__						,	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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)



     def     snake_case_ (self	):
          # Initialize image_processor
          _UpperCAmelCase					:  Optional[Any]         =    self.image_processing_class(**self.image_processor_dict	)
          # create random PyTorch tensors
          _UpperCAmelCase					:  Optional[Any]         =    self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase__						,	torchify=lowerCAmelCase__	)
          for image in image_inputs:
               self.assertIsInstance(lowerCAmelCase__						,	torch.Tensor	)

          # Test not batched input
          _UpperCAmelCase					:  List[str]         =    image_processor(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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)

          # Test batched
          _UpperCAmelCase					:  List[str]         =    image_processor(lowerCAmelCase__						,	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["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)







@require_torch
@require_vision
class 	__lowerCAmelCase    (  __a       ,					unittest.TestCase				):
     snake_case   :    List[Any]							      =      BlipImageProcessor if is_vision_available() else None



     def     snake_case_ (self	):
          _UpperCAmelCase					:  Optional[int]         =    BlipImageProcessingTester(self						,	num_channels=4	)
          _UpperCAmelCase					:  Tuple         =    3



     @property
     def     snake_case_ (self	):
          return self.image_processor_tester.prepare_image_processor_dict()



     def     snake_case_ (self	):
          _UpperCAmelCase					:  Optional[Any]         =    self.image_processing_class(**self.image_processor_dict	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_resize"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""size"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_normalize"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""image_mean"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""image_std"""	)	)
          self.assertTrue(hasattr(lowerCAmelCase__						,	"""do_convert_rgb"""	)	)



     def     snake_case_ (self	):
          pass



     def     snake_case_ (self	):
          # Initialize image_processor
          _UpperCAmelCase					:  Tuple         =    self.image_processing_class(**self.image_processor_dict	)
          # create random PIL images
          _UpperCAmelCase					:  List[str]         =    self.image_processor_tester.prepare_inputs(equal_resolution=lowerCAmelCase__	)
          for image in image_inputs:
               self.assertIsInstance(lowerCAmelCase__						,	Image.Image	)

          # Test not batched input
          _UpperCAmelCase					:  Optional[int]         =    image_processor(image_inputs[0]						,	return_tensors="""pt"""	).pixel_values
          self.assertEqual(
              encoded_images.shape						,	(
                  1,
                  self.expected_encoded_image_num_channels,
                  self.image_processor_tester.size["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)

          # Test batched
          _UpperCAmelCase					:  List[str]         =    image_processor(lowerCAmelCase__						,	return_tensors="""pt"""	).pixel_values
          self.assertEqual(
              encoded_images.shape						,	(
                  self.image_processor_tester.batch_size,
                  self.expected_encoded_image_num_channels,
                  self.image_processor_tester.size["""height"""],
                  self.image_processor_tester.size["""width"""],
              )						,	)




'''simple docstring'''

from itertools import permutations







def __A  (    ):
     _UpperCAmelCase					:  Union[str, Any]         =    list(map("""""".join ,       permutations("""0123456789"""       )       )       )
     return result[99_9999]


if __name__ == "__main__":
   print(solution())


