
"""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_video_inputs


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import VideoMAEImageProcessor







class 		lowerCamelCase__					(					unittest.TestCase				):





			'''simple docstring'''



			def __init__(							self     ,     __UpperCAmelCase     ,     __UpperCAmelCase=7     ,     __UpperCAmelCase=3     ,     __UpperCAmelCase=10     ,     __UpperCAmelCase=18     ,     __UpperCAmelCase=30     ,     __UpperCAmelCase=4_00     ,     __UpperCAmelCase=True     ,     __UpperCAmelCase=None     ,     __UpperCAmelCase=True     ,     __UpperCAmelCase=[0.5, 0.5, 0.5]     ,     __UpperCAmelCase=[0.5, 0.5, 0.5]     ,     __UpperCAmelCase=None     ,     ) ->     str:
				_lowerCAmelCase								=size if size is not None else {"""shortest_edge""": 18}
				_lowerCAmelCase								=crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

				_lowerCAmelCase								=parent
				_lowerCAmelCase								=batch_size
				_lowerCAmelCase								=num_channels
				_lowerCAmelCase								=num_frames
				_lowerCAmelCase								=image_size
				_lowerCAmelCase								=min_resolution
				_lowerCAmelCase								=max_resolution
				_lowerCAmelCase								=do_resize
				_lowerCAmelCase								=size
				_lowerCAmelCase								=do_normalize
				_lowerCAmelCase								=image_mean
				_lowerCAmelCase								=image_std
				_lowerCAmelCase								=crop_size



			def 					_lowerCAmelCase		(							self  ) ->     Union[str, 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,
				    "crop_size": self.crop_size,
				}







@require_torch
@require_vision
class 		lowerCamelCase__					(					__magic_name__ ,	unittest.TestCase				):





			'''simple docstring'''
			lowerCamelCase  					=		VideoMAEImageProcessor if is_vision_available() else None



			def 					_lowerCAmelCase		(							self  ) ->     List[Any]:
				_lowerCAmelCase								=VideoMAEImageProcessingTester(self  )



			@property
			def 					_lowerCAmelCase		(							self  ) ->     List[Any]:
				return self.image_processor_tester.prepare_image_processor_dict()



			def 					_lowerCAmelCase		(							self  ) ->     List[str]:
				_lowerCAmelCase								=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     ,     """do_center_crop"""  )  )
				self.assertTrue(hasattr(__UpperCAmelCase     ,     """size"""  )  )



			def 					_lowerCAmelCase		(							self  ) ->     Any:
				_lowerCAmelCase								=self.image_processing_class.from_dict(self.image_processor_dict  )
				self.assertEqual(image_processor.size     ,     {"""shortest_edge""": 18}  )
				self.assertEqual(image_processor.crop_size     ,     {"""height""": 18, """width""": 18}  )

				_lowerCAmelCase								=self.image_processing_class.from_dict(self.image_processor_dict     ,     size=42     ,     crop_size=84  )
				self.assertEqual(image_processor.size     ,     {"""shortest_edge""": 42}  )
				self.assertEqual(image_processor.crop_size     ,     {"""height""": 84, """width""": 84}  )



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



			def 					_lowerCAmelCase		(							self  ) ->     Union[str, Any]:
				# Initialize image_processing
				_lowerCAmelCase								=self.image_processing_class(**self.image_processor_dict  )
				# create random PIL videos
				_lowerCAmelCase								=prepare_video_inputs(self.image_processor_tester     ,     equal_resolution=__UpperCAmelCase  )
				for video in video_inputs:
					self.assertIsInstance(__UpperCAmelCase     ,     __UpperCAmelCase  )
					self.assertIsInstance(video[0]     ,     Image.Image  )

				# Test not batched input
				_lowerCAmelCase								=image_processing(video_inputs[0]     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        1,
				        self.image_processor_tester.num_frames,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.crop_size["""height"""],
				        self.image_processor_tester.crop_size["""width"""],
				    )     ,     )

				# Test batched
				_lowerCAmelCase								=image_processing(__UpperCAmelCase     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_frames,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.crop_size["""height"""],
				        self.image_processor_tester.crop_size["""width"""],
				    )     ,     )



			def 					_lowerCAmelCase		(							self  ) ->     str:
				# Initialize image_processing
				_lowerCAmelCase								=self.image_processing_class(**self.image_processor_dict  )
				# create random numpy tensors
				_lowerCAmelCase								=prepare_video_inputs(self.image_processor_tester     ,     equal_resolution=__UpperCAmelCase     ,     numpify=__UpperCAmelCase  )
				for video in video_inputs:
					self.assertIsInstance(__UpperCAmelCase     ,     __UpperCAmelCase  )
					self.assertIsInstance(video[0]     ,     np.ndarray  )

				# Test not batched input
				_lowerCAmelCase								=image_processing(video_inputs[0]     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        1,
				        self.image_processor_tester.num_frames,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.crop_size["""height"""],
				        self.image_processor_tester.crop_size["""width"""],
				    )     ,     )

				# Test batched
				_lowerCAmelCase								=image_processing(__UpperCAmelCase     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_frames,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.crop_size["""height"""],
				        self.image_processor_tester.crop_size["""width"""],
				    )     ,     )



			def 					_lowerCAmelCase		(							self  ) ->     Dict:
				# Initialize image_processing
				_lowerCAmelCase								=self.image_processing_class(**self.image_processor_dict  )
				# create random PyTorch tensors
				_lowerCAmelCase								=prepare_video_inputs(self.image_processor_tester     ,     equal_resolution=__UpperCAmelCase     ,     torchify=__UpperCAmelCase  )
				for video in video_inputs:
					self.assertIsInstance(__UpperCAmelCase     ,     __UpperCAmelCase  )
					self.assertIsInstance(video[0]     ,     torch.Tensor  )

				# Test not batched input
				_lowerCAmelCase								=image_processing(video_inputs[0]     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        1,
				        self.image_processor_tester.num_frames,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.crop_size["""height"""],
				        self.image_processor_tester.crop_size["""width"""],
				    )     ,     )

				# Test batched
				_lowerCAmelCase								=image_processing(__UpperCAmelCase     ,     return_tensors="""pt"""  ).pixel_values
				self.assertEqual(
				    encoded_videos.shape     ,     (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_frames,
				        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


lowerCAmelCase_		:			str				   =					logging.get_logger(__name__)

lowerCAmelCase_		:			Optional[int]				   =					{
    '''google/reformer-crime-and-punishment''': (
        '''https://huggingface.co/google/reformer-crime-and-punishment/resolve/main/config.json'''
    ),
    '''google/reformer-enwik8''': '''https://huggingface.co/google/reformer-enwik8/resolve/main/config.json''',
}





class      UpperCamelCase_       (				a_     ):
  _A				:    int =		'reformer'
  _A				:    Any =		['past_buckets_states']
  _A				:    Optional[Any] =		{}



  def __init__(					self       ,						snake_case__=64       ,						snake_case__=["local", "lsh", "local", "lsh", "local", "lsh"]       ,						snake_case__=1.0       ,						snake_case__=True       ,						snake_case__=[64, 64]       ,						snake_case__=[64, 1_92]       ,						snake_case__=0       ,						snake_case__=2       ,						snake_case__=5_12       ,						snake_case__=None       ,						snake_case__="relu"       ,						snake_case__=0.05       ,						snake_case__=2_56       ,						snake_case__=0.02       ,						snake_case__=False       ,						snake_case__=1e-12       ,						snake_case__=1       ,						snake_case__=0       ,						snake_case__=0.05       ,						snake_case__=64       ,						snake_case__=64       ,						snake_case__=0.0       ,						snake_case__=1       ,						snake_case__=0       ,						snake_case__=40_96       ,						snake_case__=12       ,						snake_case__=None       ,						snake_case__=1       ,						snake_case__=0       ,						snake_case__=3_20       ,						snake_case__=False       ,						snake_case__=True       ,						snake_case__=None       ,						**snake_case__       ,						)	->	List[Any]:



         """simple docstring"""





         UpperCAmelCase					=	hash_seed
         UpperCAmelCase					=	vocab_size
         UpperCAmelCase					=	attention_head_size
         UpperCAmelCase					=	hidden_size
         UpperCAmelCase					=	num_attention_heads
         UpperCAmelCase					=	num_hashes
         UpperCAmelCase					=	len(snake_case__ )
         UpperCAmelCase					=	tuple(snake_case__ ) if isinstance(snake_case__       ,						snake_case__ ) else num_buckets
         UpperCAmelCase					=	lsh_attn_chunk_length
         UpperCAmelCase					=	local_attn_chunk_length
         UpperCAmelCase					=	lsh_num_chunks_after
         UpperCAmelCase					=	lsh_num_chunks_before
         UpperCAmelCase					=	local_num_chunks_after
         UpperCAmelCase					=	local_num_chunks_before
         UpperCAmelCase					=	hidden_act
         UpperCAmelCase					=	feed_forward_size
         UpperCAmelCase					=	hidden_dropout_prob
         UpperCAmelCase					=	lsh_attention_probs_dropout_prob
         UpperCAmelCase					=	local_attention_probs_dropout_prob
         UpperCAmelCase					=	max_position_embeddings
         UpperCAmelCase					=	initializer_range
         UpperCAmelCase					=	layer_norm_eps
         UpperCAmelCase					=	axial_pos_embds
         UpperCAmelCase					=	tuple(snake_case__ )
         UpperCAmelCase					=	tuple(snake_case__ )
         UpperCAmelCase					=	axial_norm_std
         UpperCAmelCase					=	chunk_size_lm_head
         UpperCAmelCase					=	attn_layers
         UpperCAmelCase					=	use_cache
         UpperCAmelCase					=	classifier_dropout
         super().__init__(
             pad_token_id=snake_case__       ,						eos_token_id=snake_case__       ,						is_decoder=snake_case__       ,						tie_word_embeddings=snake_case__       ,						**snake_case__       ,						)
