



"""simple docstring"""
import copy
import os
from typing import Union

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


__a      =				logging.get_logger(__name__)

__a      =				{
    "BAAI/AltCLIP": "https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json",
    # See all AltCLIP models at https://huggingface.co/models?filter=altclip
}
class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					_A		:			Dict						=     """altclip_text_model"""






					def __init__(       self:							Tuple						,     snake_case:							List[Any]=250_002						,     snake_case:							Dict=1_024						,     snake_case:							Tuple=24						,     snake_case:							int=16						,     snake_case:							Any=4_096						,     snake_case:							Optional[int]="gelu"						,     snake_case:							List[Any]=0.1						,     snake_case:							Union[str, Any]=0.1						,     snake_case:							List[str]=514						,     snake_case:							List[Any]=1						,     snake_case:							Any=0.0_2						,     snake_case:							Optional[int]=0.0_2						,     snake_case:							Union[str, Any]=1E-05						,     snake_case:							List[Any]=1						,     snake_case:							Tuple=0						,     snake_case:							int=2						,     snake_case:							Dict="absolute"						,     snake_case:							Optional[int]=True						,     snake_case:							Tuple=768						,     **snake_case:							Union[str, Any]						,     )   ->	Union[str, Any]:
											super().__init__(pad_token_id=snake_case						,     bos_token_id=snake_case						,     eos_token_id=snake_case						,     **snake_case						)

											snake_case_ :Dict						=			vocab_size
											snake_case_ :str						=			hidden_size
											snake_case_ :List[Any]						=			num_hidden_layers
											snake_case_ :List[Any]						=			num_attention_heads
											snake_case_ :Union[str, Any]						=			hidden_act
											snake_case_ :Tuple						=			intermediate_size
											snake_case_ :List[str]						=			hidden_dropout_prob
											snake_case_ :int						=			attention_probs_dropout_prob
											snake_case_ :int						=			max_position_embeddings
											snake_case_ :Optional[int]						=			type_vocab_size
											snake_case_ :Union[str, Any]						=			initializer_range
											snake_case_ :str						=			initializer_factor
											snake_case_ :List[str]						=			layer_norm_eps
											snake_case_ :Tuple						=			position_embedding_type
											snake_case_ :str						=			use_cache
											snake_case_ :List[str]						=			project_dim

class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					_A		:			Optional[Any]						=     """altclip_vision_model"""






					def __init__(       self:							Dict						,     snake_case:							Dict=768						,     snake_case:							List[Any]=3_072						,     snake_case:							int=512						,     snake_case:							List[Any]=12						,     snake_case:							List[str]=12						,     snake_case:							Optional[int]=3						,     snake_case:							int=224						,     snake_case:							Optional[Any]=32						,     snake_case:							Optional[int]="quick_gelu"						,     snake_case:							Tuple=1E-5						,     snake_case:							Tuple=0.0						,     snake_case:							List[str]=0.0_2						,     snake_case:							Union[str, Any]=1.0						,     **snake_case:							str						,     )   ->	Optional[Any]:
											super().__init__(**snake_case						)

											snake_case_ :int						=			hidden_size
											snake_case_ :Optional[int]						=			intermediate_size
											snake_case_ :List[str]						=			projection_dim
											snake_case_ :Any						=			num_hidden_layers
											snake_case_ :Optional[Any]						=			num_attention_heads
											snake_case_ :Union[str, Any]						=			num_channels
											snake_case_ :int						=			patch_size
											snake_case_ :List[Any]						=			image_size
											snake_case_ :int						=			initializer_range
											snake_case_ :Optional[Any]						=			initializer_factor
											snake_case_ :str						=			attention_dropout
											snake_case_ :List[Any]						=			layer_norm_eps
											snake_case_ :List[str]						=			hidden_act






					@classmethod
					def    lowerCAmelCase_				(       cls:							List[str]						,     snake_case:							Union[str, os.PathLike]						,     **snake_case:							List[Any]						)   ->	"PretrainedConfig":
											cls._set_token_in_kwargs(snake_case						)

											snake_case_,       snake_case_ :List[str]						=			cls.get_config_dict(snake_case						,     **snake_case						)

											# get the vision config dict if we are loading from AltCLIPConfig
											if config_dict.get("""model_type"""						) == "altclip":
																	snake_case_ :Optional[Any]						=			config_dict["""vision_config"""]

											if "model_type" in config_dict and hasattr(cls						,     """model_type"""						) and config_dict["model_type"] != cls.model_type:
																	logger.warning(
																	    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
																	    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""						)

											return cls.from_dict(snake_case						,     **snake_case						)

class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					_A		:			str						=     """altclip"""
					_A		:			Any						=     True






					def __init__(       self:							int						,     snake_case:							Any=None						,     snake_case:							Optional[Any]=None						,     snake_case:							str=768						,     snake_case:							int=2.6_5_9_2						,     **snake_case:							Union[str, Any]						)   ->	str:
											# If `_config_dict` exist, we use them for the backward compatibility.
											# We pop out these 2 attributes before calling `super().__init__` to avoid them being saved (which causes a lot
											# of confusion!).
											snake_case_ :str						=			kwargs.pop("""text_config_dict"""						,     snake_case						)
											snake_case_ :List[str]						=			kwargs.pop("""vision_config_dict"""						,     snake_case						)

											super().__init__(**snake_case						)

											# Instead of simply assigning `[text|vision]_config_dict` to `[text|vision]_config`, we use the values in
											# `[text|vision]_config_dict` to update the values in `[text|vision]_config`. The values should be same in most
											# cases, but we don't want to break anything regarding `_config_dict` that existed before commit `8827e1b2`.
											if text_config_dict is not None:
																	if text_config is None:
																							snake_case_ :Tuple						=			{}

																	# This is the complete result when using `text_config_dict`.
																	snake_case_ :str						=			AltCLIPTextConfig(**snake_case						).to_dict()

																	# Give a warning if the values exist in both `_text_config_dict` and `text_config` but being different.
																	for key, value in _text_config_dict.items():
																							if key in text_config and value != text_config[key] and key not in ["transformers_version"]:
																													# If specified in `text_config_dict`
																													if key in text_config_dict:
																																			snake_case_ :List[str]						=			(
																																			    f"""`{key}` is found in both `text_config_dict` and `text_config` but with different values. """
																																			    f"""The value `text_config_dict[\"{key}\"]` will be used instead."""
																																			)
																													# If inferred from default argument values (just to be super careful)
																													else:
																																			snake_case_ :str						=			(
																																			    f"""`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The """
																																			    f"""value `text_config[\"{key}\"]` will be overriden."""
																																			)
																													logger.warning(snake_case						)

            # Update all values in `text_config` with the ones in `_text_config_dict`.
																	text_config.update(_text_config_dict						)

											if vision_config_dict is not None:
																	if vision_config is None:
																							snake_case_ :Tuple						=			{}

																	# This is the complete result when using `vision_config_dict`.
																	snake_case_ :Dict						=			AltCLIPVisionConfig(**snake_case						).to_dict()
																	# convert keys to string instead of integer
																	if "id2label" in _vision_config_dict:
																							snake_case_ :Union[str, Any]						=			{
																							    str(snake_case						): value for key, value in _vision_config_dict["""id2label"""].items()
																							}

																	# Give a warning if the values exist in both `_vision_config_dict` and `vision_config` but being different.
																	for key, value in _vision_config_dict.items():
																							if key in vision_config and value != vision_config[key] and key not in ["transformers_version"]:
																													# If specified in `vision_config_dict`
																													if key in vision_config_dict:
																																			snake_case_ :Dict						=			(
																																			    f"""`{key}` is found in both `vision_config_dict` and `vision_config` but with different """
																																			    f"""values. The value `vision_config_dict[\"{key}\"]` will be used instead."""
																																			)
																													# If inferred from default argument values (just to be super careful)
																													else:
																																			snake_case_ :Dict						=			(
																																			    f"""`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. """
																																			    f"""The value `vision_config[\"{key}\"]` will be overriden."""
																																			)
																													logger.warning(snake_case						)

            # Update all values in `vision_config` with the ones in `_vision_config_dict`.
																	vision_config.update(_vision_config_dict						)

											if text_config is None:
																	snake_case_ :Optional[Any]						=			{}
																	logger.info("""`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values."""						)

											if vision_config is None:
																	snake_case_ :List[str]						=			{}
																	logger.info("""`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values."""						)

											snake_case_ :Tuple						=			AltCLIPTextConfig(**snake_case						)
											snake_case_ :str						=			AltCLIPVisionConfig(**snake_case						)

											snake_case_ :int						=			projection_dim
											snake_case_ :Union[str, Any]						=			logit_scale_init_value
											snake_case_ :Dict						=			1.0






					@classmethod
					def    lowerCAmelCase_				(       cls:							str						,     snake_case:							AltCLIPTextConfig						,     snake_case:							AltCLIPVisionConfig						,     **snake_case:							int						)   ->	Union[str, Any]:
											return cls(text_config=text_config.to_dict()						,     vision_config=vision_config.to_dict()						,     **snake_case						)






					def    lowerCAmelCase_				(       self:							int						)   ->	Tuple:
											snake_case_ :str						=			copy.deepcopy(self.__dict__						)
											snake_case_ :Any						=			self.text_config.to_dict()
											snake_case_ :Optional[int]						=			self.vision_config.to_dict()
											snake_case_ :List[Any]						=			self.__class__.model_type
											return output






import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import TimesformerConfig
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,
					    TimesformerForVideoClassification,
					    TimesformerModel,
					)
					from transformers.models.timesformer.modeling_timesformer import TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from transformers import VideoMAEImageProcessor







class     __lowerCAmelCase :

			"""simple docstring"""







			def __init__(      self			,						lowerCamelCase__			,						lowerCamelCase__=13			,						lowerCamelCase__=10			,						lowerCamelCase__=3			,						lowerCamelCase__=2			,						lowerCamelCase__=2			,						lowerCamelCase__=True			,						lowerCamelCase__=True			,						lowerCamelCase__=32			,						lowerCamelCase__=5			,						lowerCamelCase__=4			,						lowerCamelCase__=37			,						lowerCamelCase__="gelu"			,						lowerCamelCase__=0.1			,						lowerCamelCase__=0.1			,						lowerCamelCase__=10			,						lowerCamelCase__=0.02			,						lowerCamelCase__="divided_space_time"			,						lowerCamelCase__=None			,						)    ->      Any:



							'''simple docstring'''
							__lowerCamelCase		       =    parent
							__lowerCamelCase		       =    batch_size
							__lowerCamelCase		       =    image_size
							__lowerCamelCase		       =    num_channels
							__lowerCamelCase		       =    patch_size
							__lowerCamelCase		       =    num_frames
							__lowerCamelCase		       =    is_training
							__lowerCamelCase		       =    use_labels
							__lowerCamelCase		       =    hidden_size
							__lowerCamelCase		       =    num_hidden_layers
							__lowerCamelCase		       =    num_attention_heads
							__lowerCamelCase		       =    intermediate_size
							__lowerCamelCase		       =    hidden_act
							__lowerCamelCase		       =    hidden_dropout_prob
							__lowerCamelCase		       =    attention_probs_dropout_prob
							__lowerCamelCase		       =    attention_type
							__lowerCamelCase		       =    initializer_range
							__lowerCamelCase		       =    scope
							__lowerCamelCase		       =    num_labels

							# in TimeSformer, the number of spatial tokens equals num_frames * num_patches per frame + 1 CLS token
							__lowerCamelCase		       =    (image_size // patch_size) ** 2
							__lowerCamelCase		       =    (num_frames) * self.num_patches_per_frame + 1


			def       lowercase_    (      self							)    ->      Optional[int]:



							'''simple docstring'''
							__lowerCamelCase		       =    floats_tensor(
							    [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size]							)

							__lowerCamelCase		       =    None
							if self.use_labels:
											__lowerCamelCase		       =    ids_tensor([self.batch_size]			,						self.num_labels							)

							__lowerCamelCase		       =    self.get_config()

							return config, pixel_values, labels


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



							'''simple docstring'''
							__lowerCamelCase		       =    TimesformerConfig(
							    image_size=self.image_size			,						patch_size=self.patch_size			,						num_channels=self.num_channels			,						num_frames=self.num_frames			,						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			,						initializer_range=self.initializer_range			,						attention_type=self.attention_type			,						)
							__lowerCamelCase		       =    self.num_labels
							return config


			def       lowercase_    (      self			,						lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							)    ->      Tuple:



							'''simple docstring'''
							__lowerCamelCase		       =    TimesformerModel(config=lowerCamelCase__							)
							model.to(lowerCamelCase__							)
							model.eval()
							__lowerCamelCase		       =    model(lowerCamelCase__							)
							self.parent.assertEqual(result.last_hidden_state.shape			,						(self.batch_size, self.seq_length, self.hidden_size)							)


			def       lowercase_    (      self			,						lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							)    ->      Union[str, Any]:



							'''simple docstring'''
							__lowerCamelCase		       =    TimesformerForVideoClassification(lowerCamelCase__							)
							model.to(lowerCamelCase__							)
							model.eval()

							__lowerCamelCase		       =    model(lowerCamelCase__							)

							# verify the logits shape
							__lowerCamelCase		       =    torch.Size((self.batch_size, self.num_labels)							)
							self.parent.assertEqual(result.logits.shape			,						lowerCamelCase__							)






			def       lowercase_    (      self							)    ->      Tuple:



							'''simple docstring'''
							__lowerCamelCase		       =    self.prepare_config_and_inputs()
							__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    config_and_inputs
							__lowerCamelCase		       =    {'pixel_values': pixel_values}
							return config, inputs_dict







@require_torch
class     __lowerCAmelCase (       __magic_name__			,				__magic_name__			,				unittest.TestCase ):

			"""simple docstring"""







			snake_case_   		=       (TimesformerModel, TimesformerForVideoClassification) if is_torch_available() else ()
			snake_case_   		=       (
			    {'''feature-extraction''': TimesformerModel, '''video-classification''': TimesformerForVideoClassification}
			    if is_torch_available()
			    else {}
			)

			snake_case_   		=       False
			snake_case_   		=       False
			snake_case_   		=       False
			snake_case_   		=       False


			def       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							__lowerCamelCase		       =    TimesformerModelTester(self							)
							__lowerCamelCase		       =    ConfigTester(
							    self			,						config_class=lowerCamelCase__			,						has_text_modality=lowerCamelCase__			,						hidden_size=37							)


			def       lowercase_    (      self			,						lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__=False							)    ->      int:



							'''simple docstring'''
							__lowerCamelCase		       =    copy.deepcopy(lowerCamelCase__							)

							if return_labels:
											if model_class in get_values(lowerCamelCase__							):
															__lowerCamelCase		       =    torch.zeros(
															    self.model_tester.batch_size			,						dtype=torch.long			,						device=lowerCamelCase__							)

							return inputs_dict


			def       lowercase_    (      self							)    ->      Optional[int]:



							'''simple docstring'''
							self.config_tester.run_common_tests()


			@unittest.skip(reason='TimeSformer does not use inputs_embeds'							)
			def       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							__lowerCamelCase       ,						__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs_for_common()

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


			def       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							__lowerCamelCase       ,						__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											__lowerCamelCase		       =    model_class(lowerCamelCase__							)
											__lowerCamelCase		       =    inspect.signature(model.forward							)
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											__lowerCamelCase		       =    [*signature.parameters.keys()]

											__lowerCamelCase		       =    ['pixel_values']
											self.assertListEqual(arg_names[:1]			,						lowerCamelCase__							)


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



							'''simple docstring'''
							__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*lowerCamelCase__							)


			def       lowercase_    (      self							)    ->      str:



							'''simple docstring'''
							__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_video_classification(*lowerCamelCase__							)


			@slow
			def       lowercase_    (      self							)    ->      Dict:



							'''simple docstring'''
							for model_name in TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											__lowerCamelCase		       =    TimesformerModel.from_pretrained(lowerCamelCase__							)
											self.assertIsNotNone(lowerCamelCase__							)


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



							'''simple docstring'''
							if not self.has_attentions:
											pass

							else:
											__lowerCamelCase       ,						__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs_for_common()
											__lowerCamelCase		       =    True

											for model_class in self.all_model_classes:
															__lowerCamelCase		       =    self.model_tester.seq_length
															__lowerCamelCase		       =    self.model_tester.num_frames

															__lowerCamelCase		       =    True
															__lowerCamelCase		       =    False
															__lowerCamelCase		       =    True
															__lowerCamelCase		       =    model_class(lowerCamelCase__							)
															model.to(lowerCamelCase__							)
															model.eval()
															with torch.no_grad():
																			__lowerCamelCase		       =    model(**self._prepare_for_class(lowerCamelCase__			,						lowerCamelCase__							)							)
															__lowerCamelCase		       =    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"]
															__lowerCamelCase		       =    True
															__lowerCamelCase		       =    model_class(lowerCamelCase__							)
															model.to(lowerCamelCase__							)
															model.eval()
															with torch.no_grad():
																			__lowerCamelCase		       =    model(**self._prepare_for_class(lowerCamelCase__			,						lowerCamelCase__							)							)
															__lowerCamelCase		       =    outputs.attentions
															self.assertEqual(len(lowerCamelCase__							)			,						self.model_tester.num_hidden_layers							)

															# attentions has shape (batch_size x num_frames) x num_heads x (num_patches per frame + 1) x (num_patches per frame + 1)
															self.assertListEqual(
															    list(attentions[0].shape[-3:]							)			,						[self.model_tester.num_attention_heads, seq_len // num_frames + 1, seq_len // num_frames + 1]			,						)
															__lowerCamelCase		       =    len(lowerCamelCase__							)

															# Check attention is always last and order is fine
															__lowerCamelCase		       =    True
															__lowerCamelCase		       =    True
															__lowerCamelCase		       =    model_class(lowerCamelCase__							)
															model.to(lowerCamelCase__							)
															model.eval()
															with torch.no_grad():
																			__lowerCamelCase		       =    model(**self._prepare_for_class(lowerCamelCase__			,						lowerCamelCase__							)							)

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

															__lowerCamelCase		       =    outputs.attentions

															self.assertEqual(len(lowerCamelCase__							)			,						self.model_tester.num_hidden_layers							)

															# attentions has shape (batch_size x num_frames) x num_heads x (num_patches per frame + 1) x (num_patches per frame + 1)
															self.assertListEqual(
															    list(self_attentions[0].shape[-3:]							)			,						[self.model_tester.num_attention_heads, seq_len // num_frames + 1, seq_len // num_frames + 1]			,						)






			def       lowercase_    (      self							)    ->      Tuple:



							'''simple docstring'''
							def check_hidden_states_output(lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							):
											__lowerCamelCase		       =    model_class(lowerCamelCase__							)
											model.to(lowerCamelCase__							)
											model.eval()

											with torch.no_grad():
															__lowerCamelCase		       =    model(**self._prepare_for_class(lowerCamelCase__			,						lowerCamelCase__							)							)

											__lowerCamelCase		       =    outputs.hidden_states
											__lowerCamelCase		       =    self.model_tester.num_hidden_layers + 1
											self.assertEqual(len(lowerCamelCase__							)			,						lowerCamelCase__							)

											__lowerCamelCase		       =    self.model_tester.seq_length

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

							__lowerCamelCase       ,						__lowerCamelCase		       =    self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
											__lowerCamelCase		       =    True
											check_hidden_states_output(lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							)

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											__lowerCamelCase		       =    True

											check_hidden_states_output(lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							)







def 			lowerCamelCase_		(       )     ->       Any:





				"""simple docstring"""


				__lowerCamelCase		       =    hf_hub_download(
				    repo_id='hf-internal-testing/spaghetti-video' ,     filename='eating_spaghetti.npy' ,     repo_type='dataset'      )
				__lowerCamelCase		       =    np.load(UpperCamelCase__      )
				return list(UpperCamelCase__      )







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

			"""simple docstring"""







			@cached_property
			def       lowercase_    (      self							)    ->      List[Any]:



							'''simple docstring'''
							# logits were tested with a different mean and std, so we use the same here
							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       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							__lowerCamelCase		       =    TimesformerForVideoClassification.from_pretrained('facebook/timesformer-base-finetuned-k400'							).to(
							    lowerCamelCase__							)

							__lowerCamelCase		       =    self.default_image_processor
							__lowerCamelCase		       =    prepare_video()
							__lowerCamelCase		       =    image_processor(video[:8]			,						return_tensors='pt'							).to(lowerCamelCase__							)

							# forward pass
							with torch.no_grad():
											__lowerCamelCase		       =    model(**lowerCamelCase__							)

							# verify the logits
							__lowerCamelCase		       =    torch.Size((1, 400)							)
							self.assertEqual(outputs.logits.shape			,						lowerCamelCase__							)

							__lowerCamelCase		       =    torch.tensor([-0.30_16, -0.77_13, -0.42_05]							).to(lowerCamelCase__							)

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


