



"""simple docstring"""





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


_UpperCamelCase     :		int											=					logging.get_logger(__name__)

_UpperCamelCase     :		Union[str, Any]											=					{
    "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   UpperCAmelCase_			(					_a):
      lowerCamelCase__	:					Any										=						"vivit"


      def __init__(     self	,    a=2_2_4	,    a=3_2	,    a=[2, 1_6, 1_6]	,    a=3	,    a=7_6_8	,    a=1_2	,    a=1_2	,    a=3_0_7_2	,    a="gelu_fast"	,    a=0.0	,    a=0.0	,    a=0.02	,    a=1e-06	,    a=True	,    **a	,    ) ->      List[Any]:
             lowercase__    :	int     					=			hidden_size
             lowercase__    :	Optional[Any]     					=			num_hidden_layers
             lowercase__    :	int     					=			num_attention_heads
             lowercase__    :	List[Any]     					=			intermediate_size
             lowercase__    :	List[Any]     					=			hidden_act
             lowercase__    :	int     					=			hidden_dropout_prob
             lowercase__    :	Tuple     					=			attention_probs_dropout_prob
             lowercase__    :	int     					=			initializer_range
             lowercase__    :	Optional[int]     					=			layer_norm_eps

             lowercase__    :	Any     					=			image_size
             lowercase__    :	List[Any]     					=			num_frames
             lowercase__    :	Optional[int]     					=			tubelet_size
             lowercase__    :	int     					=			num_channels
             lowercase__    :	Optional[int]     					=			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   UpperCAmelCase_			(					unittest.TestCase):


      @slow
      def 	_UpperCAmelCase (     self							) ->      str:
             lowercase__    :	Optional[Any]     					=			AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'							)
             lowercase__    :	Union[str, Any]     					=			AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'							)
             model.to(a							)

             from datasets import load_dataset

             lowercase__    :	str     					=			load_dataset('nielsr/rvlcdip-demo'							)

             lowercase__    :	Tuple     					=			dataset['train'][0]['image'].convert('RGB'							)

             lowercase__    :	int     					=			image_processor(a	,    return_tensors='pt'							).to(a							)

             # forward pass
             with torch.no_grad():
                    lowercase__    :	List[str]     					=			model(**a							)
                    lowercase__    :	List[Any]     					=			outputs.logits

             lowercase__    :	Union[str, Any]     					=			torch.Size((1, 1_6)							)
             self.assertEqual(logits.shape	,    a							)

             lowercase__    :	Tuple     					=			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							)							)

