"""simple docstring"""





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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''google/vivit-b-16x2-kinetics400''': (
        '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json'''
    ),
    # See all Vivit models at https://huggingface.co/models?filter=vivit
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"vivit"





				def __init__(      self							:							str      ,    _A							:							Union[str, Any]=2_2_4      ,    _A							:							int=3_2      ,    _A							:							Tuple=[2, 1_6, 1_6]      ,    _A							:							Union[str, Any]=3      ,    _A							:							str=7_6_8      ,    _A							:							int=1_2      ,    _A							:							Optional[Any]=1_2      ,    _A							:							int=3_0_7_2      ,    _A							:							int="gelu_fast"      ,    _A							:							List[str]=0.0      ,    _A							:							Union[str, Any]=0.0      ,    _A							:							Tuple=0.02      ,    _A							:							Optional[Any]=1e-06      ,    _A							:							Optional[int]=True      ,    **_A							:							List[Any]      ,    ):



											"""simple docstring"""







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

											_SCREAMING_SNAKE_CASE		:						Any			  =    image_size
											_SCREAMING_SNAKE_CASE		:						int			  =    num_frames
											_SCREAMING_SNAKE_CASE		:						Dict			  =    tubelet_size
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    num_channels
											_SCREAMING_SNAKE_CASE		:						Any			  =    qkv_bias

											super().__init__(**_A)



"""simple docstring"""





import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
			import torch

			from transformers import AutoModelForImageClassification

if is_vision_available():
			from transformers import AutoImageProcessor




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







				"""simple docstring"""






				@slow
				def 		_lowerCAmelCase		(      self							:							str):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Any			  =    AutoImageProcessor.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip""")
											_SCREAMING_SNAKE_CASE		:						str			  =    AutoModelForImageClassification.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip""")
											model.to(_A)

											from datasets import load_dataset

											_SCREAMING_SNAKE_CASE		:						Any			  =    load_dataset("""nielsr/rvlcdip-demo""")

											_SCREAMING_SNAKE_CASE		:						Any			  =    dataset["""train"""][0]["""image"""].convert("""RGB""")

											_SCREAMING_SNAKE_CASE		:						str			  =    image_processor(_A      ,    return_tensors="""pt""").to(_A)

											# forward pass
											with torch.no_grad():
																		_SCREAMING_SNAKE_CASE		:						Any			  =    model(**_A)
																		_SCREAMING_SNAKE_CASE		:						List[Any]			  =    outputs.logits

											_SCREAMING_SNAKE_CASE		:						List[str]			  =    torch.Size((1, 1_6))
											self.assertEqual(logits.shape      ,    _A)

											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    torch.tensor(
											    [-0.4_158, -0.4_092, -0.4_347]      ,    device=_A      ,    dtype=torch.float      ,    )
											self.assertTrue(torch.allclose(logits[0, :3]      ,    _A      ,    atol=1e-4))


