






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 		SCREAMING_SNAKE_CASE__   (     unittest.TestCase    ):



		def __init__(    self:    Any				,   a:    int				,   a:    int=7				,   a:    Dict=3				,   a:    Optional[int]=10				,   a:    int=18				,   a:    Union[str, Any]=30				,   a:    List[Any]=4_00				,   a:    Any=True				,   a:    Tuple=None				,   a:    List[str]=True				,   a:    int=[0.5, 0.5, 0.5]				,   a:    List[str]=[0.5, 0.5, 0.5]				,   a:    Union[str, Any]=None				,   )  ->int:






								'''simple docstring'''


								a_				     =   size if size is not None else {"shortest_edge": 18}
								a_				     =   crop_size if crop_size is not None else {"height": 18, "width": 18}

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




		def _lowerCAmelCase     (    self:    Union[str, Any])  ->Optional[Any]:






								'''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,
								    "crop_size": self.crop_size,
								}





@require_torch
@require_vision
class 		SCREAMING_SNAKE_CASE__   (     lowercase_		,		unittest.TestCase    ):
		_UpperCAmelCase         =VideoMAEImageProcessor if is_vision_available() else None



		def _lowerCAmelCase     (    self:    Union[str, Any])  ->Optional[Any]:






								'''simple docstring'''


								a_				     =   VideoMAEImageProcessingTester(self)



		@property
		def _lowerCAmelCase     (    self:    Tuple)  ->str:






								'''simple docstring'''


								return self.image_processor_tester.prepare_image_processor_dict()



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






								'''simple docstring'''


								a_				     =   self.image_processing_class(**self.image_processor_dict)
								self.assertTrue(hasattr(a				,   "image_mean"))
								self.assertTrue(hasattr(a				,   "image_std"))
								self.assertTrue(hasattr(a				,   "do_normalize"))
								self.assertTrue(hasattr(a				,   "do_resize"))
								self.assertTrue(hasattr(a				,   "do_center_crop"))
								self.assertTrue(hasattr(a				,   "size"))



		def _lowerCAmelCase     (    self:    Optional[Any])  ->str:






								'''simple docstring'''


								a_				     =   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})

								a_				     =   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:    Optional[int])  ->Union[str, Any]:






								'''simple docstring'''


								pass



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






								'''simple docstring'''


								a_				     =   self.image_processing_class(**self.image_processor_dict)
								# create random PIL videos
								a_				     =   prepare_video_inputs(self.image_processor_tester				,   equal_resolution=a)
								for video in video_inputs:
														self.assertIsInstance(a				,   a)
														self.assertIsInstance(video[0]				,   Image.Image)

								# Test not batched input
								a_				     =   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
								a_				     =   image_processing(a				,   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:    Any)  ->List[Any]:






								'''simple docstring'''


								a_				     =   self.image_processing_class(**self.image_processor_dict)
								# create random numpy tensors
								a_				     =   prepare_video_inputs(self.image_processor_tester				,   equal_resolution=a				,   numpify=a)
								for video in video_inputs:
														self.assertIsInstance(a				,   a)
														self.assertIsInstance(video[0]				,   np.ndarray)

								# Test not batched input
								a_				     =   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
								a_				     =   image_processing(a				,   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:    Union[str, Any])  ->int:






								'''simple docstring'''


								a_				     =   self.image_processing_class(**self.image_processor_dict)
								# create random PyTorch tensors
								a_				     =   prepare_video_inputs(self.image_processor_tester				,   equal_resolution=a				,   torchify=a)
								for video in video_inputs:
														self.assertIsInstance(a				,   a)
														self.assertIsInstance(video[0]				,   torch.Tensor)

								# Test not batched input
								a_				     =   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
								a_				     =   image_processing(a				,   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 collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


a_      = logging.get_logger(__name__)

a_      = {
    'google/mobilebert-uncased': 'https://huggingface.co/google/mobilebert-uncased/resolve/main/config.json'
}





class 		SCREAMING_SNAKE_CASE__   (     lowercase_    ):
		_UpperCAmelCase         =MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
		_UpperCAmelCase         ='''mobilebert'''



		def __init__(    self:    Union[str, Any]				,   a:    str=3_05_22				,   a:    List[str]=5_12				,   a:    List[str]=24				,   a:    Dict=4				,   a:    List[str]=5_12				,   a:    Optional[int]="relu"				,   a:    Dict=0.0				,   a:    Union[str, Any]=0.1				,   a:    int=5_12				,   a:    Optional[Any]=2				,   a:    List[Any]=0.02				,   a:    Optional[Any]=1e-12				,   a:    List[Any]=0				,   a:    Optional[int]=1_28				,   a:    Union[str, Any]=True				,   a:    Dict=True				,   a:    List[Any]=1_28				,   a:    Any=False				,   a:    Any=True				,   a:    Dict=4				,   a:    List[Any]="no_norm"				,   a:    Any=True				,   a:    Tuple=None				,   **a:    Any				,   )  ->Any:






								'''simple docstring'''


								super().__init__(pad_token_id=a				,   **a)

								a_				     =   vocab_size
								a_				     =   hidden_size
								a_				     =   num_hidden_layers
								a_				     =   num_attention_heads
								a_				     =   hidden_act
								a_				     =   intermediate_size
								a_				     =   hidden_dropout_prob
								a_				     =   attention_probs_dropout_prob
								a_				     =   max_position_embeddings
								a_				     =   type_vocab_size
								a_				     =   initializer_range
								a_				     =   layer_norm_eps
								a_				     =   embedding_size
								a_				     =   trigram_input
								a_				     =   use_bottleneck
								a_				     =   intra_bottleneck_size
								a_				     =   use_bottleneck_attention
								a_				     =   key_query_shared_bottleneck
								a_				     =   num_feedforward_networks
								a_				     =   normalization_type
								a_				     =   classifier_activation

								if self.use_bottleneck:
														a_				     =   intra_bottleneck_size
								else:
														a_				     =   hidden_size

								a_				     =   classifier_dropout





class 		SCREAMING_SNAKE_CASE__   (     lowercase_    ):



		@property
		def _lowerCAmelCase     (    self:    Optional[int])  ->Mapping[str, Mapping[int, str]]:






								'''simple docstring'''


								if self.task == "multiple-choice":
														a_				     =   {0: "batch", 1: "choice", 2: "sequence"}
								else:
														a_				     =   {0: "batch", 1: "sequence"}
								return OrderedDict(
								    [
								        ("input_ids", dynamic_axis),
								        ("attention_mask", dynamic_axis),
								        ("token_type_ids", dynamic_axis),
								    ])



