



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


__lowerCamelCase     :							Dict  							=				logging.get_logger(__name__)

__lowerCamelCase     :							Dict  							=				{
    "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  __magic_name__   (							A__						):
		lowercase      :       Optional[int]          ='''vivit'''






		def __init__(						self      :     Union[str, Any]				,		UpperCamelCase__      :     Optional[int]=2_24				,		UpperCamelCase__      :     Tuple=32				,		UpperCamelCase__      :     Optional[int]=[2, 16, 16]				,		UpperCamelCase__      :     Dict=3				,		UpperCamelCase__      :     Union[str, Any]=7_68				,		UpperCamelCase__      :     Optional[Any]=12				,		UpperCamelCase__      :     int=12				,		UpperCamelCase__      :     List[Any]=30_72				,		UpperCamelCase__      :     List[Any]="gelu_fast"				,		UpperCamelCase__      :     Optional[Any]=0.0				,		UpperCamelCase__      :     List[Any]=0.0				,		UpperCamelCase__      :     Optional[Any]=0.02				,		UpperCamelCase__      :     Optional[int]=1e-0_6				,		UpperCamelCase__      :     int=True				,		**UpperCamelCase__      :     Union[str, Any]				,		)				->					Any:
								'''simple docstring'''







								UpperCAmelCase         =     hidden_size
								UpperCAmelCase         =     num_hidden_layers
								UpperCAmelCase         =     num_attention_heads
								UpperCAmelCase         =     intermediate_size
								UpperCAmelCase         =     hidden_act
								UpperCAmelCase         =     hidden_dropout_prob
								UpperCAmelCase         =     attention_probs_dropout_prob
								UpperCAmelCase         =     initializer_range
								UpperCAmelCase         =     layer_norm_eps

								UpperCAmelCase         =     image_size
								UpperCAmelCase         =     num_frames
								UpperCAmelCase         =     tubelet_size
								UpperCAmelCase         =     num_channels
								UpperCAmelCase         =     qkv_bias

								super().__init__(**UpperCamelCase__      )








import tempfile
import unittest

from transformers import AutoModelForSeqaSeqLM, AutoTokenizer
from transformers.testing_utils import (
    is_torch_available,
    require_optimum,
    require_torch,
    slow,
)


if is_torch_available():
		import torch





@require_torch
@require_optimum
@slow
class  __magic_name__   (							unittest.TestCase						):






		def SCREAMING_SNAKE_CASE_			(						self      :     Tuple      )				->					Optional[int]:
								'''simple docstring'''







								UpperCAmelCase         =     "hf-internal-testing/tiny-random-t5"
								UpperCAmelCase         =     AutoTokenizer.from_pretrained(UpperCamelCase__      )
								UpperCAmelCase         =     AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__      )

								UpperCAmelCase         =     tokenizer("This is me"				,		return_tensors="pt"      )

								UpperCAmelCase         =     model.to_bettertransformer()

								self.assertTrue(any("BetterTransformer" in mod.__class__.__name__ for _, mod in model.named_modules()      )      )

								UpperCAmelCase         =     model.generate(**UpperCamelCase__      )

								UpperCAmelCase         =     model.reverse_bettertransformer()

								self.assertFalse(any("BetterTransformer" in mod.__class__.__name__ for _, mod in model.named_modules()      )      )

								with tempfile.TemporaryDirectory() as tmpdirname:
														model.save_pretrained(UpperCamelCase__      )

														UpperCAmelCase         =     AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__      )

														self.assertFalse(
														    any("BetterTransformer" in mod.__class__.__name__ for _, mod in model_reloaded.named_modules()      )      )

														UpperCAmelCase         =     model_reloaded.generate(**UpperCamelCase__      )
														self.assertTrue(torch.allclose(UpperCamelCase__				,		UpperCamelCase__      )      )







		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]      )				->					Optional[int]:
								'''simple docstring'''







								UpperCAmelCase         =     "hf-internal-testing/tiny-random-t5"
								UpperCAmelCase         =     AutoModelForSeqaSeqLM.from_pretrained(UpperCamelCase__      )

								UpperCAmelCase         =     model.to_bettertransformer()

								with tempfile.TemporaryDirectory() as tmpdirname:
														with self.assertRaises(UpperCamelCase__      ):
																				model.save_pretrained(UpperCamelCase__      )

														UpperCAmelCase         =     model.reverse_bettertransformer()
														model.save_pretrained(UpperCamelCase__      )



