





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      lowerCamelCase(						unittest.TestCase	):
     '''simple docstring'''


     def __init__(    self				,     snake_case_				,     snake_case_=13				,     snake_case_=3				,     snake_case_=224				,     snake_case_=30				,     snake_case_=400				,     snake_case_=True				,     snake_case_=None				,     snake_case_=True				,     snake_case_=[0.5, 0.5, 0.5]				,     snake_case_=[0.5, 0.5, 0.5]				,     ):
         _A     =							size if size is not None else {'height': 18, 'width': 18}
         _A     =							parent
         _A     =							batch_size
         _A     =							num_channels
         _A     =							image_size
         _A     =							min_resolution
         _A     =							max_resolution
         _A     =							do_resize
         _A     =							size
         _A     =							do_normalize
         _A     =							image_mean
         _A     =							image_std




     def        lowerCAmelCase__		(    self							):
         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      lowerCamelCase(						__snake_case			, unittest.TestCase	):
     '''simple docstring'''


     __magic_name__   =			ViTImageProcessor if is_vision_available() else None




     def        lowerCAmelCase__		(    self							):
         _A     =							EfficientFormerImageProcessorTester(self							)




     @property
     def        lowerCAmelCase__		(    self							):
         return self.image_proc_tester.prepare_image_processor_dict()




     def        lowerCAmelCase__		(    self							):
         _A     =							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'							)							)




     def        lowerCAmelCase__		(    self							):
         pass




     def        lowerCAmelCase__		(    self							):
         # Initialize image_processor
         _A     =							self.image_processing_class(**self.image_processor_dict							)
         # create random PIL images
         _A     =							prepare_image_inputs(self.image_proc_tester				,     equal_resolution=snake_case_							)
         for image in image_inputs:
             self.assertIsInstance(snake_case_				,     Image.Image							)

         # Test not batched input
         _A     =							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
         _A     =							image_processor(snake_case_				,     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        lowerCAmelCase__		(    self							):
         # Initialize image_processor
         _A     =							self.image_processing_class(**self.image_processor_dict							)
         # create random numpy tensors
         _A     =							prepare_image_inputs(self.image_proc_tester				,     equal_resolution=snake_case_				,     numpify=snake_case_							)
         for image in image_inputs:
             self.assertIsInstance(snake_case_				,     np.ndarray							)

         # Test not batched input
         _A     =							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
         _A     =							image_processor(snake_case_				,     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        lowerCAmelCase__		(    self							):
         # Initialize image_processor
         _A     =							self.image_processing_class(**self.image_processor_dict							)
         # create random PyTorch tensors
         _A     =							prepare_image_inputs(self.image_proc_tester				,     equal_resolution=snake_case_				,     torchify=snake_case_							)
         for image in image_inputs:
             self.assertIsInstance(snake_case_				,     torch.Tensor							)

         # Test not batched input
         _A     =							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
         _A     =							image_processor(snake_case_				,     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'],
             )				,     )










'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__a  			=						{
    "configuration_bigbird_pegasus": [
        "BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BigBirdPegasusConfig",
        "BigBirdPegasusOnnxConfig",
    ],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __a  			=						[
           "BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST",
           "BigBirdPegasusForCausalLM",
           "BigBirdPegasusForConditionalGeneration",
           "BigBirdPegasusForQuestionAnswering",
           "BigBirdPegasusForSequenceClassification",
           "BigBirdPegasusModel",
           "BigBirdPegasusPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_bigbird_pegasus import (
           BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
           BigBirdPegasusConfig,
           BigBirdPegasusOnnxConfig,
       )

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_bigbird_pegasus import (
                  BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
                  BigBirdPegasusForCausalLM,
                  BigBirdPegasusForConditionalGeneration,
                  BigBirdPegasusForQuestionAnswering,
                  BigBirdPegasusForSequenceClassification,
                  BigBirdPegasusModel,
                  BigBirdPegasusPreTrainedModel,
              )


else:
       import sys

       __a  			=						_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
