

import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
 from PIL import Image



class     lowercase_       (    unittest.TestCase  ,				__lowercase	):



      def 		UpperCamelCase_						(     self :							Union[str, Any]						)       ->	Optional[int]:
        _snake_case		=				load_tool('''image-question-answering'''						)
        self.tool.setup()
        _snake_case		=				load_tool('''image-question-answering'''     ,   remote=_A						)



      def 		UpperCamelCase_						(     self :							Optional[int]						)       ->	str:
        _snake_case		=				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
        _snake_case		=				self.tool(_A     ,   '''How many cats are sleeping on the couch?'''						)
        self.assertEqual(_A     ,   '''2'''						)



      def 		UpperCamelCase_						(     self :							Dict						)       ->	Union[str, Any]:
        _snake_case		=				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
        _snake_case		=				self.remote_tool(_A     ,   '''How many cats are sleeping on the couch?'''						)
        self.assertEqual(_A     ,   '''2'''						)



      def 		UpperCamelCase_						(     self :							Any						)       ->	int:
        _snake_case		=				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
        _snake_case		=				self.tool(image=_A     ,   question='''How many cats are sleeping on the couch?'''						)
        self.assertEqual(_A     ,   '''2'''						)







      def 		UpperCamelCase_						(     self :							Tuple						)       ->	Tuple:
        _snake_case		=				Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''						)						) / '''000000039769.png'''						)
        _snake_case		=				self.remote_tool(image=_A     ,   question='''How many cats are sleeping on the couch?'''						)
        self.assertEqual(_A     ,   '''2'''						)






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


snake_case     :    Any						=    logging.get_logger(__name__)

snake_case     :    List[str]						=    {
    'MCG-NJU/videomae-base': 'https://huggingface.co/MCG-NJU/videomae-base/resolve/main/config.json',
}




class 				lowerCAmelCase__	(						UpperCamelCase    ):
					__A  :     str     =    'videomae'







					def __init__(							self   :  Optional[Any]      ,		_A   :  str=224      ,		_A   :  Union[str, Any]=16      ,		_A   :  int=3      ,		_A   :  Tuple=16      ,		_A   :  int=2      ,		_A   :  List[Any]=768      ,		_A   :  List[Any]=12      ,		_A   :  Tuple=12      ,		_A   :  List[Any]=3072      ,		_A   :  Union[str, Any]="gelu"      ,		_A   :  Any=0.0      ,		_A   :  str=0.0      ,		_A   :  Tuple=0.02      ,		_A   :  Optional[Any]=1e-12      ,		_A   :  Tuple=True      ,		_A   :  Dict=True      ,		_A   :  str=6      ,		_A   :  Optional[int]=384      ,		_A   :  Any=4      ,		_A   :  Any=1536      ,		_A   :  Optional[int]=True      ,		**_A   :  Tuple      ,		):
											super().__init__(**_A)

											A__						:				List[str]         =			image_size
											A__						:				Union[str, Any]         =			patch_size
											A__						:				Optional[int]         =			num_channels
											A__						:				int         =			num_frames
											A__						:				List[Any]         =			tubelet_size

											A__						:				str         =			hidden_size
											A__						:				Optional[Any]         =			num_hidden_layers
											A__						:				int         =			num_attention_heads
											A__						:				List[Any]         =			intermediate_size
											A__						:				Optional[int]         =			hidden_act
											A__						:				Any         =			hidden_dropout_prob
											A__						:				str         =			attention_probs_dropout_prob
											A__						:				List[Any]         =			initializer_range
											A__						:				str         =			layer_norm_eps
											A__						:				Any         =			qkv_bias
											A__						:				Union[str, Any]         =			use_mean_pooling

											A__						:				int         =			decoder_num_attention_heads
											A__						:				Tuple         =			decoder_hidden_size
											A__						:				int         =			decoder_num_hidden_layers
											A__						:				int         =			decoder_intermediate_size
											A__						:				Any         =			norm_pix_loss