



'''simple docstring'''




import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch
						from torch import nn

						from transformers import (
						    MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
						    VideoMAEForPreTraining,
						    VideoMAEForVideoClassification,
						    VideoMAEModel,
						)
						from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
						from transformers import VideoMAEImageProcessor






class 		_UpperCamelCase						:


			'''simple docstring'''

			def __init__(							self  :				List[Any]							,  lowerCAmelCase__  :				Optional[int]							,  lowerCAmelCase__  :				Union[str, Any]=1_3							,  lowerCAmelCase__  :				int=1_0							,  lowerCAmelCase__  :				Tuple=3							,  lowerCAmelCase__  :				List[Any]=2							,  lowerCAmelCase__  :				Optional[int]=2							,  lowerCAmelCase__  :				Tuple=2							,  lowerCAmelCase__  :				Union[str, Any]=True							,  lowerCAmelCase__  :				Union[str, Any]=True							,  lowerCAmelCase__  :				Optional[int]=3_2							,  lowerCAmelCase__  :				List[str]=5							,  lowerCAmelCase__  :				Any=4							,  lowerCAmelCase__  :				Tuple=3_7							,  lowerCAmelCase__  :				int="gelu"							,  lowerCAmelCase__  :				Tuple=0.1							,  lowerCAmelCase__  :				str=0.1							,  lowerCAmelCase__  :				Dict=1_0							,  lowerCAmelCase__  :				Union[str, Any]=0.02							,  lowerCAmelCase__  :				Tuple=0.9							,  lowerCAmelCase__  :				Union[str, Any]=None							,  ):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	parent
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	batch_size
					__SCREAMING_SNAKE_CASE :	Tuple					 =	image_size
					__SCREAMING_SNAKE_CASE :	Tuple					 =	num_channels
					__SCREAMING_SNAKE_CASE :	Any					 =	patch_size
					__SCREAMING_SNAKE_CASE :	Tuple					 =	tubelet_size
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	num_frames
					__SCREAMING_SNAKE_CASE :	Tuple					 =	is_training
					__SCREAMING_SNAKE_CASE :	Tuple					 =	use_labels
					__SCREAMING_SNAKE_CASE :	str					 =	hidden_size
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	num_hidden_layers
					__SCREAMING_SNAKE_CASE :	Tuple					 =	num_attention_heads
					__SCREAMING_SNAKE_CASE :	str					 =	intermediate_size
					__SCREAMING_SNAKE_CASE :	int					 =	hidden_act
					__SCREAMING_SNAKE_CASE :	Tuple					 =	hidden_dropout_prob
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	attention_probs_dropout_prob
					__SCREAMING_SNAKE_CASE :	str					 =	type_sequence_label_size
					__SCREAMING_SNAKE_CASE :	Any					 =	initializer_range
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	mask_ratio
					__SCREAMING_SNAKE_CASE :	Tuple					 =	scope

					# in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
					__SCREAMING_SNAKE_CASE :	List[str]					 =	(image_size // patch_size) ** 2
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	(num_frames // tubelet_size) * self.num_patches_per_frame

					# use this variable to define bool_masked_pos
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	int(mask_ratio * self.seq_length		)

			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	int					 =	floats_tensor(
					    [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size]		)

					__SCREAMING_SNAKE_CASE :	Tuple					 =	None
					if self.use_labels:
							__SCREAMING_SNAKE_CASE :	int					 =	ids_tensor([self.batch_size]							,  self.type_sequence_label_size		)

					__SCREAMING_SNAKE_CASE :	Any					 =	self.get_config()

					return config, pixel_values, labels

			def UpperCamelCase__      (							self  :				List[Any]		):





					"""simple docstring"""






					return VideoMAEConfig(
					    image_size=self.image_size							,  patch_size=self.patch_size							,  num_channels=self.num_channels							,  num_frames=self.num_frames							,  tubelet_size=self.tubelet_size							,  hidden_size=self.hidden_size							,  num_hidden_layers=self.num_hidden_layers							,  num_attention_heads=self.num_attention_heads							,  intermediate_size=self.intermediate_size							,  hidden_act=self.hidden_act							,  hidden_dropout_prob=self.hidden_dropout_prob							,  attention_probs_dropout_prob=self.attention_probs_dropout_prob							,  is_decoder=lowerCAmelCase__							,  initializer_range=self.initializer_range							,  )

			def UpperCamelCase__      (							self  :				List[str]							,  lowerCAmelCase__  :				int							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	int					 =	VideoMAEModel(config=lowerCAmelCase__		)
					model.to(lowerCAmelCase__		)
					model.eval()
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.last_hidden_state.shape							,  (self.batch_size, self.seq_length, self.hidden_size)		)

			def UpperCamelCase__      (							self  :				Union[str, Any]							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	VideoMAEForPreTraining(lowerCAmelCase__		)
					model.to(lowerCAmelCase__		)
					model.eval()
					# important: each video needs to have the same number of masked patches
					# hence we define a single mask, which we then repeat for each example in the batch
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	torch.ones((self.num_masks,)		)
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	torch.cat([mask, torch.zeros(self.seq_length - mask.size(0		)		)]		)
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	mask.expand(self.batch_size							,  -1		).bool()

					__SCREAMING_SNAKE_CASE :	str					 =	model(lowerCAmelCase__							,  lowerCAmelCase__		)
					# model only returns predictions for masked patches
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	mask.sum().item()
					__SCREAMING_SNAKE_CASE :	Any					 =	3 * self.tubelet_size * self.patch_size**2
					self.parent.assertEqual(result.logits.shape							,  (self.batch_size, num_masked_patches, decoder_num_labels)		)



			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Tuple					 =	self.prepare_config_and_inputs()
					__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	Dict					 =	config_and_inputs
					__SCREAMING_SNAKE_CASE :	Dict					 =	{"""pixel_values""": pixel_values}
					return config, inputs_dict






@require_torch
class 		_UpperCamelCase						(							lowerCamelCase__					,      lowerCamelCase__					,      unittest.TestCase					):


			'''simple docstring'''

			_A   :	Dict    					=	(
			    (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
			)
			_A   :	Any    					=	(
			    {'''feature-extraction''': VideoMAEModel, '''video-classification''': VideoMAEForVideoClassification}
			    if is_torch_available()
			    else {}
			)

			_A   :	str    					=	False
			_A   :	List[str]    					=	False
			_A   :	str    					=	False
			_A   :	Optional[int]    					=	False

			def UpperCamelCase__      (							self  :				Tuple		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Dict					 =	VideoMAEModelTester(self		)
					__SCREAMING_SNAKE_CASE :	Dict					 =	ConfigTester(self							,  config_class=lowerCAmelCase__							,  has_text_modality=lowerCAmelCase__							,  hidden_size=3_7		)

			def UpperCamelCase__      (							self  :				int							,  lowerCAmelCase__  :				Tuple							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				str=False		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	copy.deepcopy(lowerCAmelCase__		)

					if model_class == VideoMAEForPreTraining:
							# important: each video needs to have the same number of masked patches
							# hence we define a single mask, which we then repeat for each example in the batch
							__SCREAMING_SNAKE_CASE :	List[str]					 =	torch.ones((self.model_tester.num_masks,)		)
							__SCREAMING_SNAKE_CASE :	str					 =	torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0		)		)]		)
							__SCREAMING_SNAKE_CASE :	Any					 =	mask.expand(self.model_tester.batch_size							,  -1		).bool()
							__SCREAMING_SNAKE_CASE :	Tuple					 =	bool_masked_pos.to(lowerCAmelCase__		)

					if return_labels:
							if model_class in [
							    *get_values(lowerCAmelCase__		),
							]:
									__SCREAMING_SNAKE_CASE :	str					 =	torch.zeros(
									    self.model_tester.batch_size							,  dtype=torch.long							,  device=lowerCAmelCase__		)

					return inputs_dict

			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					self.config_tester.run_common_tests()

			@unittest.skip(reason="""VideoMAE does not use inputs_embeds"""		)
			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					pass

			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	List[str]					 =	self.model_tester.prepare_config_and_inputs_for_common()

					for model_class in self.all_model_classes:
							__SCREAMING_SNAKE_CASE :	Tuple					 =	model_class(lowerCAmelCase__		)
							self.assertIsInstance(model.get_input_embeddings()							,  (nn.Module)		)
							__SCREAMING_SNAKE_CASE :	int					 =	model.get_output_embeddings()
							self.assertTrue(x is None or isinstance(lowerCAmelCase__							,  nn.Linear		)		)

			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	int					 =	self.model_tester.prepare_config_and_inputs_for_common()

					for model_class in self.all_model_classes:
							__SCREAMING_SNAKE_CASE :	List[str]					 =	model_class(lowerCAmelCase__		)
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	inspect.signature(model.forward		)
							# signature.parameters is an OrderedDict => so arg_names order is deterministic
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	[*signature.parameters.keys()]

							__SCREAMING_SNAKE_CASE :	List[str]					 =	["""pixel_values"""]
							self.assertListEqual(arg_names[:1]							,  lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Optional[int]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_pretraining(*lowerCAmelCase__		)

			@slow
			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	VideoMAEModel.from_pretrained(lowerCAmelCase__		)
							self.assertIsNotNone(lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				str		):





					"""simple docstring"""






					if not self.has_attentions:
							pass

					else:
							__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	self.model_tester.prepare_config_and_inputs_for_common()
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	True

							for model_class in self.all_model_classes:
									__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.model_tester.seq_length - self.model_tester.num_masks
									__SCREAMING_SNAKE_CASE :	Any					 =	(
									    num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
									)

									__SCREAMING_SNAKE_CASE :	List[str]					 =	True
									__SCREAMING_SNAKE_CASE :	List[str]					 =	False
									__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	True
									__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	model_class(lowerCAmelCase__		)
									model.to(lowerCAmelCase__		)
									model.eval()
									with torch.no_grad():
											__SCREAMING_SNAKE_CASE :	int					 =	model(**self._prepare_for_class(lowerCAmelCase__							,  lowerCAmelCase__		)		)
									__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	outputs.attentions
									self.assertEqual(len(lowerCAmelCase__		)							,  self.model_tester.num_hidden_layers		)

									# check that output_attentions also work using config
									del inputs_dict["output_attentions"]
									__SCREAMING_SNAKE_CASE :	int					 =	True
									__SCREAMING_SNAKE_CASE :	Optional[int]					 =	model_class(lowerCAmelCase__		)
									model.to(lowerCAmelCase__		)
									model.eval()
									with torch.no_grad():
											__SCREAMING_SNAKE_CASE :	List[str]					 =	model(**self._prepare_for_class(lowerCAmelCase__							,  lowerCAmelCase__		)		)
									__SCREAMING_SNAKE_CASE :	Optional[int]					 =	outputs.attentions
									self.assertEqual(len(lowerCAmelCase__		)							,  self.model_tester.num_hidden_layers		)

									self.assertListEqual(
									    list(attentions[0].shape[-3:]		)							,  [self.model_tester.num_attention_heads, seq_len, seq_len]							,  )
									__SCREAMING_SNAKE_CASE :	Any					 =	len(lowerCAmelCase__		)

									# Check attention is always last and order is fine
									__SCREAMING_SNAKE_CASE :	Dict					 =	True
									__SCREAMING_SNAKE_CASE :	int					 =	True
									__SCREAMING_SNAKE_CASE :	Dict					 =	model_class(lowerCAmelCase__		)
									model.to(lowerCAmelCase__		)
									model.eval()
									with torch.no_grad():
											__SCREAMING_SNAKE_CASE :	List[Any]					 =	model(**self._prepare_for_class(lowerCAmelCase__							,  lowerCAmelCase__		)		)

									self.assertEqual(out_len + 1							,  len(lowerCAmelCase__		)		)

									__SCREAMING_SNAKE_CASE :	List[Any]					 =	outputs.attentions

									self.assertEqual(len(lowerCAmelCase__		)							,  self.model_tester.num_hidden_layers		)
									self.assertListEqual(
									    list(self_attentions[0].shape[-3:]		)							,  [self.model_tester.num_attention_heads, seq_len, seq_len]							,  )

			def UpperCamelCase__      (							self  :				Union[str, Any]		):





					"""simple docstring"""






					def check_hidden_states_output(lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Union[str, Any]		):
							__SCREAMING_SNAKE_CASE :	Dict					 =	model_class(lowerCAmelCase__		)
							model.to(lowerCAmelCase__		)
							model.eval()

							with torch.no_grad():
									__SCREAMING_SNAKE_CASE :	Tuple					 =	model(**self._prepare_for_class(lowerCAmelCase__							,  lowerCAmelCase__		)		)

							__SCREAMING_SNAKE_CASE :	Any					 =	outputs.hidden_states
							__SCREAMING_SNAKE_CASE :	Optional[int]					 =	self.model_tester.num_hidden_layers + 1
							self.assertEqual(len(lowerCAmelCase__		)							,  lowerCAmelCase__		)

							__SCREAMING_SNAKE_CASE :	List[str]					 =	self.model_tester.seq_length - self.model_tester.num_masks
							__SCREAMING_SNAKE_CASE :	Optional[int]					 =	num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

							self.assertListEqual(
							    list(hidden_states[0].shape[-2:]		)							,  [seq_length, self.model_tester.hidden_size]							,  )

					__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	Tuple					 =	self.model_tester.prepare_config_and_inputs_for_common()

					for model_class in self.all_model_classes:
							__SCREAMING_SNAKE_CASE :	int					 =	True
							check_hidden_states_output(lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__		)

							# check that output_hidden_states also work using config
							del inputs_dict["output_hidden_states"]
							__SCREAMING_SNAKE_CASE :	str					 =	True

							check_hidden_states_output(lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__		)



			@unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""		)
			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					pass


def        lowerCAmelCase_     (			):
		__SCREAMING_SNAKE_CASE :	List[Any]					 =	hf_hub_download(
		    repo_id="""hf-internal-testing/spaghetti-video""" ,   filename="""eating_spaghetti.npy""" ,   repo_type="""dataset"""      )
		__SCREAMING_SNAKE_CASE :	Optional[int]					 =	np.load(_lowerCamelCase      )
		return list(_lowerCamelCase      )






@require_torch
@require_vision
class 		_UpperCamelCase						(							unittest.TestCase					):


			'''simple docstring'''

			@cached_property
			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					return (
					    VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5]							,  image_std=[0.5, 0.5, 0.5]		)
					    if is_vision_available()
					    else None
					)

			@slow
			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	int					 =	VideoMAEForVideoClassification.from_pretrained("""MCG-NJU/videomae-base-finetuned-kinetics"""		).to(
					    lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.default_image_processor
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	prepare_video()
					__SCREAMING_SNAKE_CASE :	Any					 =	image_processor(lowerCAmelCase__							,  return_tensors="""pt"""		).to(lowerCAmelCase__		)

					# forward pass
					with torch.no_grad():
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	model(**lowerCAmelCase__		)

					# verify the logits
					__SCREAMING_SNAKE_CASE :	List[str]					 =	torch.Size((1, 4_0_0)		)
					self.assertEqual(outputs.logits.shape							,  lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	List[Any]					 =	torch.tensor([0.36_69, -0.06_88, -0.24_21]		).to(lowerCAmelCase__		)

					self.assertTrue(torch.allclose(outputs.logits[0, :3]							,  lowerCAmelCase__							,  atol=1E-4		)		)



			@slow
			def UpperCamelCase__      (							self  :				Optional[int]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""		).to(lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	Any					 =	self.default_image_processor
					__SCREAMING_SNAKE_CASE :	Any					 =	prepare_video()
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	image_processor(lowerCAmelCase__							,  return_tensors="""pt"""		).to(lowerCAmelCase__		)

					# add boolean mask, indicating which patches to mask
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	hf_hub_download(repo_id="""hf-internal-testing/bool-masked-pos"""							,  filename="""bool_masked_pos.pt"""		)
					__SCREAMING_SNAKE_CASE :	int					 =	torch.load(lowerCAmelCase__		)

					# forward pass
					with torch.no_grad():
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	model(**lowerCAmelCase__		)

					# verify the logits
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	torch.Size([1, 1_4_0_8, 1_5_3_6]		)
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	torch.tensor(
					    [[0.79_94, 0.96_12, 0.85_08], [0.74_01, 0.89_58, 0.83_02], [0.58_62, 0.74_68, 0.73_25]]							,  device=lowerCAmelCase__		)
					self.assertEqual(outputs.logits.shape							,  lowerCAmelCase__		)
					self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]							,  lowerCAmelCase__							,  atol=1E-4		)		)

					# verify the loss (`config.norm_pix_loss` = `True`)
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	torch.tensor([0.51_42]							,  device=lowerCAmelCase__		)
					self.assertTrue(torch.allclose(outputs.loss							,  lowerCAmelCase__							,  atol=1E-4		)		)

					# verify the loss (`config.norm_pix_loss` = `False`)
					__SCREAMING_SNAKE_CASE :	Dict					 =	VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""							,  norm_pix_loss=lowerCAmelCase__		).to(
					    lowerCAmelCase__		)

					with torch.no_grad():
							__SCREAMING_SNAKE_CASE :	Tuple					 =	model(**lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	Any					 =	torch.tensor(torch.tensor([0.64_69]		)							,  device=lowerCAmelCase__		)
					self.assertTrue(torch.allclose(outputs.loss							,  lowerCAmelCase__							,  atol=1E-4		)		)




'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

from packaging import version

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


UpperCamelCase__ :			Any												=				logging.get_logger(__name__)

UpperCamelCase__ :			Dict												=				{
    '''microsoft/beit-base-patch16-224-pt22k''': (
        '''https://huggingface.co/microsoft/beit-base-patch16-224-pt22k/resolve/main/config.json'''
    ),
    # See all BEiT models at https://huggingface.co/models?filter=beit
}






class 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Optional[int]    					=	'''beit'''

			def __init__(							self  :				Tuple							,  lowerCAmelCase__  :				List[Any]=8_1_9_2							,  lowerCAmelCase__  :				List[Any]=7_6_8							,  lowerCAmelCase__  :				List[Any]=1_2							,  lowerCAmelCase__  :				Union[str, Any]=1_2							,  lowerCAmelCase__  :				Dict=3_0_7_2							,  lowerCAmelCase__  :				List[Any]="gelu"							,  lowerCAmelCase__  :				List[Any]=0.0							,  lowerCAmelCase__  :				int=0.0							,  lowerCAmelCase__  :				Tuple=0.02							,  lowerCAmelCase__  :				Any=1E-12							,  lowerCAmelCase__  :				Dict=2_2_4							,  lowerCAmelCase__  :				List[str]=1_6							,  lowerCAmelCase__  :				int=3							,  lowerCAmelCase__  :				Union[str, Any]=False							,  lowerCAmelCase__  :				Union[str, Any]=False							,  lowerCAmelCase__  :				Any=False							,  lowerCAmelCase__  :				Union[str, Any]=False							,  lowerCAmelCase__  :				Optional[int]=0.1							,  lowerCAmelCase__  :				Dict=0.1							,  lowerCAmelCase__  :				Tuple=True							,  lowerCAmelCase__  :				str=[3, 5, 7, 1_1]							,  lowerCAmelCase__  :				str=[1, 2, 3, 6]							,  lowerCAmelCase__  :				Dict=True							,  lowerCAmelCase__  :				Dict=0.4							,  lowerCAmelCase__  :				int=2_5_6							,  lowerCAmelCase__  :				Any=1							,  lowerCAmelCase__  :				str=False							,  lowerCAmelCase__  :				Union[str, Any]=2_5_5							,  **lowerCAmelCase__  :				Optional[int]							,  ):





					"""simple docstring"""






					super().__init__(**lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	int					 =	vocab_size
					__SCREAMING_SNAKE_CASE :	int					 =	hidden_size
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	num_hidden_layers
					__SCREAMING_SNAKE_CASE :	List[str]					 =	num_attention_heads
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	intermediate_size
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	hidden_act
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	hidden_dropout_prob
					__SCREAMING_SNAKE_CASE :	Any					 =	attention_probs_dropout_prob
					__SCREAMING_SNAKE_CASE :	Dict					 =	initializer_range
					__SCREAMING_SNAKE_CASE :	Any					 =	layer_norm_eps

					__SCREAMING_SNAKE_CASE :	Dict					 =	image_size
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	patch_size
					__SCREAMING_SNAKE_CASE :	int					 =	num_channels
					__SCREAMING_SNAKE_CASE :	Tuple					 =	use_mask_token
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	use_absolute_position_embeddings
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	use_relative_position_bias
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	use_shared_relative_position_bias
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	layer_scale_init_value
					__SCREAMING_SNAKE_CASE :	Any					 =	drop_path_rate
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	use_mean_pooling
					# decode head attributes (semantic segmentation)
					__SCREAMING_SNAKE_CASE :	Any					 =	out_indices
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	pool_scales
					# auxiliary head attributes (semantic segmentation)
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	use_auxiliary_head
					__SCREAMING_SNAKE_CASE :	str					 =	auxiliary_loss_weight
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	auxiliary_channels
					__SCREAMING_SNAKE_CASE :	str					 =	auxiliary_num_convs
					__SCREAMING_SNAKE_CASE :	int					 =	auxiliary_concat_input
					__SCREAMING_SNAKE_CASE :	Dict					 =	semantic_loss_ignore_index






class 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			_A   :	List[str]    					=	version.parse('''1.11'''					)

			@property
			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					return OrderedDict(
					    [
					        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
					    ]		)



			@property
			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					return 1E-4