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






class      snake_case__    (	unittest.TestCase ):







		"""simple docstring"""

		def __init__(	self							:       Dict   ,     UpperCamelCase__							:       List[Any]   ,     UpperCamelCase__							:       List[Any]=7   ,     UpperCamelCase__							:       int=3   ,     UpperCamelCase__							:       Dict=18   ,     UpperCamelCase__							:       Dict=30   ,     UpperCamelCase__							:       str=400   ,     UpperCamelCase__							:       Optional[Any]=True   ,     UpperCamelCase__							:       Union[str, Any]=None   ,     UpperCamelCase__							:       Optional[int]=True   ,     UpperCamelCase__							:       int=[0.5, 0.5, 0.5]   ,     UpperCamelCase__							:       Any=[0.5, 0.5, 0.5]   ,     )		->       str:






				"""simple docstring"""







				snake_case   :    Tuple			       =		size if size is not None else {'''height''': 18, '''width''': 18}
				snake_case   :    str			       =		parent
				snake_case   :    Union[str, Any]			       =		batch_size
				snake_case   :    List[str]			       =		num_channels
				snake_case   :    List[str]			       =		image_size
				snake_case   :    int			       =		min_resolution
				snake_case   :    Union[str, Any]			       =		max_resolution
				snake_case   :    Tuple			       =		do_resize
				snake_case   :    List[Any]			       =		size
				snake_case   :    List[Any]			       =		do_normalize
				snake_case   :    Tuple			       =		image_mean
				snake_case   :    List[str]			       =		image_std



		def 	lowerCAmelCase							(	self							:       int	)		->       Optional[int]:






				"""simple docstring"""







				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      snake_case__    (	__SCREAMING_SNAKE_CASE  , unittest.TestCase ):







		"""simple docstring"""

		lowerCamelCase							=		ViTImageProcessor if is_vision_available() else None



		def 	lowerCAmelCase							(	self							:       str	)		->       List[Any]:






				"""simple docstring"""







				snake_case   :    int			       =		ViTImageProcessingTester(self	)



		@property
		def 	lowerCAmelCase							(	self							:       List[Any]	)		->       List[str]:






				"""simple docstring"""







				return self.image_processor_tester.prepare_image_processor_dict()



		def 	lowerCAmelCase							(	self							:       Union[str, Any]	)		->       Dict:






				"""simple docstring"""







				snake_case   :    List[Any]			       =		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 	lowerCAmelCase							(	self							:       str	)		->       int:






				"""simple docstring"""







				snake_case   :    Union[str, Any]			       =		self.image_processing_class.from_dict(self.image_processor_dict	)
				self.assertEqual(image_processor.size   ,     {'''height''': 18, '''width''': 18}	)

				snake_case   :    Optional[int]			       =		self.image_processing_class.from_dict(self.image_processor_dict   ,     size=42	)
				self.assertEqual(image_processor.size   ,     {'''height''': 42, '''width''': 42}	)



		def 	lowerCAmelCase							(	self							:       Tuple	)		->       Any:






				"""simple docstring"""







				pass



		def 	lowerCAmelCase							(	self							:       List[Any]	)		->       Optional[int]:






				"""simple docstring"""







				snake_case   :    Any			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random PIL images
				snake_case   :    List[str]			       =		prepare_image_inputs(self.image_processor_tester   ,     equal_resolution=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     Image.Image	)

				# Test not batched input
				snake_case   :    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.size['''height'''],
				        self.image_processor_tester.size['''width'''],
				    )   ,     )

				# Test batched
				snake_case   :    str			       =		image_processing(UpperCamelCase__   ,     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 	lowerCAmelCase							(	self							:       str	)		->       Any:






				"""simple docstring"""







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

				# Test not batched input
				snake_case   :    List[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.size['''height'''],
				        self.image_processor_tester.size['''width'''],
				    )   ,     )

				# Test batched
				snake_case   :    Optional[int]			       =		image_processing(UpperCamelCase__   ,     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 	lowerCAmelCase							(	self							:       Tuple	)		->       str:






				"""simple docstring"""







				snake_case   :    Tuple			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random PyTorch tensors
				snake_case   :    Dict			       =		prepare_image_inputs(self.image_processor_tester   ,     equal_resolution=UpperCamelCase__   ,     torchify=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     torch.Tensor	)

				# Test not batched input
				snake_case   :    List[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.size['''height'''],
				        self.image_processor_tester.size['''width'''],
				    )   ,     )

				# Test batched
				snake_case   :    str			       =		image_processing(UpperCamelCase__   ,     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'''],
				    )   ,     )









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


_UpperCAmelCase				       = logging.get_logger(__name__)

_UpperCAmelCase				       = {
    'MCG-NJU/videomae-base': 'https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json',
}



class 							_UpperCamelCase    (		lowerCAmelCase_   ):
       _UpperCamelCase :    List[Any]   			=      '''videomae'''

       def __init__(						self:       Optional[Any]    ,      _SCREAMING_SNAKE_CASE:       List[str]=224    ,      _SCREAMING_SNAKE_CASE:       Dict=16    ,      _SCREAMING_SNAKE_CASE:       List[Any]=3    ,      _SCREAMING_SNAKE_CASE:       Tuple=16    ,      _SCREAMING_SNAKE_CASE:       Tuple=2    ,      _SCREAMING_SNAKE_CASE:       Optional[Any]=768    ,      _SCREAMING_SNAKE_CASE:       str=12    ,      _SCREAMING_SNAKE_CASE:       List[Any]=12    ,      _SCREAMING_SNAKE_CASE:       Dict=3072    ,      _SCREAMING_SNAKE_CASE:       Tuple="gelu"    ,      _SCREAMING_SNAKE_CASE:       List[Any]=0.0    ,      _SCREAMING_SNAKE_CASE:       List[Any]=0.0    ,      _SCREAMING_SNAKE_CASE:       Tuple=0.02    ,      _SCREAMING_SNAKE_CASE:       Optional[int]=1e-12    ,      _SCREAMING_SNAKE_CASE:       Dict=True    ,      _SCREAMING_SNAKE_CASE:       Dict=True    ,      _SCREAMING_SNAKE_CASE:       List[str]=6    ,      _SCREAMING_SNAKE_CASE:       Dict=384    ,      _SCREAMING_SNAKE_CASE:       Any=4    ,      _SCREAMING_SNAKE_CASE:       Dict=1536    ,      _SCREAMING_SNAKE_CASE:       Optional[int]=True    ,      **_SCREAMING_SNAKE_CASE:       str    ,      )				->       Dict:




              """simple docstring"""


              super().__init__(**_SCREAMING_SNAKE_CASE						)

              UpperCamelCase_      				=     image_size
              UpperCamelCase_      				=     patch_size
              UpperCamelCase_      				=     num_channels
              UpperCamelCase_      				=     num_frames
              UpperCamelCase_      				=     tubelet_size

              UpperCamelCase_      				=     hidden_size
              UpperCamelCase_      				=     num_hidden_layers
              UpperCamelCase_      				=     num_attention_heads
              UpperCamelCase_      				=     intermediate_size
              UpperCamelCase_      				=     hidden_act
              UpperCamelCase_      				=     hidden_dropout_prob
              UpperCamelCase_      				=     attention_probs_dropout_prob
              UpperCamelCase_      				=     initializer_range
              UpperCamelCase_      				=     layer_norm_eps
              UpperCamelCase_      				=     qkv_bias
              UpperCamelCase_      				=     use_mean_pooling

              UpperCamelCase_      				=     decoder_num_attention_heads
              UpperCamelCase_      				=     decoder_hidden_size
              UpperCamelCase_      				=     decoder_num_hidden_layers
              UpperCamelCase_      				=     decoder_intermediate_size
              UpperCamelCase_      				=     norm_pix_loss

