






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


if is_torch_available():
 import torch

if is_vision_available():
 from PIL import Image

 from transformers import OwlViTImageProcessor


class 				_UpperCAmelCase  (						unittest.TestCase	):




    def __init__(	self     :				str     ,   a     :				Optional[Any]     ,   a     :				List[Any]=7     ,   a     :				str=3     ,   a     :				Union[str, Any]=1_8     ,   a     :				str=3_0     ,   a     :				Tuple=4_0_0     ,   a     :				str=True     ,   a     :				int=None     ,   a     :				Tuple=True     ,   a     :				int=None     ,   a     :				int=True     ,   a     :				str=[0.4814_5466, 0.457_8275, 0.4082_1073]     ,   a     :				List[str]=[0.2686_2954, 0.2613_0258, 0.2757_7711]     ,   a     :				int=True     ,   ):






       '''simple docstring'''






       lowercase_		:			str							=   parent
       lowercase_		:			Optional[Any]							=   batch_size
       lowercase_		:			Union[str, Any]							=   num_channels
       lowercase_		:			Optional[int]							=   image_size
       lowercase_		:			Dict							=   min_resolution
       lowercase_		:			List[Any]							=   max_resolution
       lowercase_		:			List[str]							=   do_resize
       lowercase_		:			Dict							=   size if size is not None else {"height": 1_8, "width": 1_8}
       lowercase_		:			List[Any]							=   do_center_crop
       lowercase_		:			List[Any]							=   crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}
       lowercase_		:			Union[str, Any]							=   do_normalize
       lowercase_		:			int							=   image_mean
       lowercase_		:			Dict							=   image_std
       lowercase_		:			List[Any]							=   do_convert_rgb





    def  lowerCAmelCase__ (	self     :				str	):






       '''simple docstring'''






       return {
           "do_resize": self.do_resize,
           "size": self.size,
           "do_center_crop": self.do_center_crop,
           "crop_size": self.crop_size,
           "do_normalize": self.do_normalize,
           "image_mean": self.image_mean,
           "image_std": self.image_std,
           "do_convert_rgb": self.do_convert_rgb,
       }


@require_torch
@require_vision
class 				_UpperCAmelCase  (						__lowerCAmelCase ,    unittest.TestCase	):
    __lowerCamelCase:      Tuple										=			OwlViTImageProcessor if is_vision_available() else None




    def  lowerCAmelCase__ (	self     :				Dict	):






       '''simple docstring'''






       lowercase_		:			Optional[int]							=   OwlViTImageProcessingTester(self	)




    @property
    def  lowerCAmelCase__ (	self     :				Optional[int]	):






       '''simple docstring'''






       return self.image_processor_tester.prepare_image_processor_dict()




    def  lowerCAmelCase__ (	self     :				Any	):






       '''simple docstring'''






       lowercase_		:			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_center_crop"	)	)
       self.assertTrue(hasattr(_lowerCamelCase     ,   "center_crop"	)	)
       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  lowerCAmelCase__ (	self     :				List[str]	):






       '''simple docstring'''






       lowercase_		:			Optional[int]							=   self.image_processing_class.from_dict(self.image_processor_dict	)
       self.assertEqual(image_processor.size     ,   {"height": 1_8, "width": 1_8}	)
       self.assertEqual(image_processor.crop_size     ,   {"height": 1_8, "width": 1_8}	)

       lowercase_		:			Dict							=   self.image_processing_class.from_dict(self.image_processor_dict     ,   size=4_2     ,   crop_size=8_4	)
       self.assertEqual(image_processor.size     ,   {"height": 4_2, "width": 4_2}	)
       self.assertEqual(image_processor.crop_size     ,   {"height": 8_4, "width": 8_4}	)




    def  lowerCAmelCase__ (	self     :				str	):






       '''simple docstring'''






       lowercase_		:			Optional[Any]							=   self.image_processing_class(**self.image_processor_dict	)
       # create random PIL images
       lowercase_		:			Optional[Any]							=   prepare_image_inputs(self.image_processor_tester     ,   equal_resolution=_lowerCamelCase	)

       for image in image_inputs:
          self.assertIsInstance(_lowerCamelCase     ,   Image.Image	)

       # Test not batched input
       lowercase_		:			Optional[int]							=   image_processing(image_inputs[0]     ,   return_tensors="pt"	).pixel_values
       self.assertEqual(
           encoded_images.shape     ,   (
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )

       # Test batched
       lowercase_		:			Union[str, Any]							=   image_processing(_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.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )




    def  lowerCAmelCase__ (	self     :				str	):






       '''simple docstring'''






       lowercase_		:			Dict							=   self.image_processing_class(**self.image_processor_dict	)
       # create random numpy tensors
       lowercase_		:			Optional[int]							=   prepare_image_inputs(self.image_processor_tester     ,   equal_resolution=_lowerCamelCase     ,   numpify=_lowerCamelCase	)
       for image in image_inputs:
          self.assertIsInstance(_lowerCamelCase     ,   np.ndarray	)

       # Test not batched input
       lowercase_		:			str							=   image_processing(image_inputs[0]     ,   return_tensors="pt"	).pixel_values
       self.assertEqual(
           encoded_images.shape     ,   (
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )

       # Test batched
       lowercase_		:			List[Any]							=   image_processing(_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.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )





    def  lowerCAmelCase__ (	self     :				Optional[Any]	):






       '''simple docstring'''






       lowercase_		:			List[str]							=   self.image_processing_class(**self.image_processor_dict	)
       # create random PyTorch tensors
       lowercase_		:			int							=   prepare_image_inputs(self.image_processor_tester     ,   equal_resolution=_lowerCamelCase     ,   torchify=_lowerCamelCase	)
       for image in image_inputs:
          self.assertIsInstance(_lowerCamelCase     ,   torch.Tensor	)

       # Test not batched input
       lowercase_		:			Union[str, Any]							=   image_processing(image_inputs[0]     ,   return_tensors="pt"	).pixel_values
       self.assertEqual(
           encoded_images.shape     ,   (
               1,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )

       # Test batched
       lowercase_		:			Optional[int]							=   image_processing(_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.crop_size["height"],
               self.image_processor_tester.crop_size["width"],
           )     ,   )





"""simple docstring"""


from ...configuration_utils import PretrainedConfig
from ...utils import logging


a							=logging.get_logger(__name__)

a							={
    'microsoft/mpnet-base': 'https://huggingface.co/microsoft/mpnet-base/resolve/main/config.json',
}






class    __UpperCAmelCase						(	__lowerCAmelCase	):
				A__      :   Optional[int]  							=       '''mpnet'''

				def __init__(      self	, _lowerCamelCase=30527	, _lowerCamelCase=768	, _lowerCamelCase=12	, _lowerCamelCase=12	, _lowerCamelCase=3072	, _lowerCamelCase="gelu"	, _lowerCamelCase=0.1	, _lowerCamelCase=0.1	, _lowerCamelCase=512	, _lowerCamelCase=0.0_2	, _lowerCamelCase=1E-12	, _lowerCamelCase=32	, _lowerCamelCase=1	, _lowerCamelCase=0	, _lowerCamelCase=2	, **_lowerCamelCase	, ):
										super().__init__(pad_token_id=_lowerCamelCase	, bos_token_id=_lowerCamelCase	, eos_token_id=_lowerCamelCase	, **_lowerCamelCase      )

										lowerCamelCase__					=vocab_size
										lowerCamelCase__					=hidden_size
										lowerCamelCase__					=num_hidden_layers
										lowerCamelCase__					=num_attention_heads
										lowerCamelCase__					=hidden_act
										lowerCamelCase__					=intermediate_size
										lowerCamelCase__					=hidden_dropout_prob
										lowerCamelCase__					=attention_probs_dropout_prob
										lowerCamelCase__					=max_position_embeddings
										lowerCamelCase__					=initializer_range
										lowerCamelCase__					=layer_norm_eps
										lowerCamelCase__					=relative_attention_num_buckets


