




"""simple docstring"""







import copy
from typing import Dict

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING
from ..bit import BitConfig


a								=							logging.get_logger(__name__)

a								=							{
    'google/vit-hybrid-base-bit-384': 'https://huggingface.co/vit-hybrid-base-bit-384/resolve/main/config.json',
    # See all ViT hybrid models at https://huggingface.co/models?filter=vit
}






class  SCREAMING_SNAKE_CASE__   (   _a   ):
						_a        =  'vit-hybrid'


						def __init__(							self			:     int  ,  lowerCAmelCase			:     List[Any]=None  ,  lowerCAmelCase			:     List[Any]=768  ,  lowerCAmelCase			:     List[Any]=12  ,  lowerCAmelCase			:     Tuple=12  ,  lowerCAmelCase			:     Union[str, Any]=3072  ,  lowerCAmelCase			:     Union[str, Any]="gelu"  ,  lowerCAmelCase			:     Any=0.0  ,  lowerCAmelCase			:     List[str]=0.0  ,  lowerCAmelCase			:     Any=0.02  ,  lowerCAmelCase			:     Optional[int]=1e-12  ,  lowerCAmelCase			:     Any=224  ,  lowerCAmelCase			:     Optional[int]=1  ,  lowerCAmelCase			:     List[Any]=3  ,  lowerCAmelCase			:     Any=[1, 1024, 24, 24]  ,  lowerCAmelCase			:     List[Any]=True  ,  **lowerCAmelCase			:     List[str]  ,  ):
										super().__init__(**lowerCAmelCase   )

										if backbone_config is None:
														logger.info("""`backbone_config` is `None`. Initializing the config with a `BiT` backbone."""   )
														lowerCAmelCase		=			{
														    """global_padding""": """same""",
														    """layer_type""": """bottleneck""",
														    """depths""": [3, 4, 9],
														    """out_features""": ["""stage3"""],
														    """embedding_dynamic_padding""": True,
														}

										if isinstance(lowerCAmelCase  ,  lowerCAmelCase   ):
														if "model_type" in backbone_config:
																		lowerCAmelCase		=			CONFIG_MAPPING[backbone_config["""model_type"""]]
														else:
																		logger.info(
																		    """`model_type` is not found in `backbone_config`. Use `Bit` as the backbone configuration class."""   )
																		lowerCAmelCase		=			BitConfig
														lowerCAmelCase		=			backbone_config_class(**lowerCAmelCase   )

										lowerCAmelCase		=			backbone_featmap_shape
										lowerCAmelCase		=			backbone_config
										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		=			initializer_range
										lowerCAmelCase		=			layer_norm_eps
										lowerCAmelCase		=			image_size
										lowerCAmelCase		=			patch_size
										lowerCAmelCase		=			num_channels
										lowerCAmelCase		=			qkv_bias




						def 					__lowercase	(							self			:     Tuple   ):
										lowerCAmelCase		=			copy.deepcopy(self.__dict__   )
										lowerCAmelCase		=			self.backbone_config.to_dict()
										lowerCAmelCase		=			self.__class__.model_type
										return output











"""simple docstring"""







import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class  SCREAMING_SNAKE_CASE__   (   _a   ):
						_a        =  ['image_processor', 'tokenizer']
						_a        =  'VideoMAEImageProcessor'
						_a        =  ('CLIPTokenizer', 'CLIPTokenizerFast')


						def __init__(							self			:     Union[str, Any]  ,  lowerCAmelCase			:     Optional[Any]=None  ,  lowerCAmelCase			:     Tuple=None  ,  **lowerCAmelCase			:     List[str]   ):
										lowerCAmelCase		=			None
										if "feature_extractor" in kwargs:
														warnings.warn(
														    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
														    """ instead."""  ,  lowerCAmelCase  ,  )
														lowerCAmelCase		=			kwargs.pop("""feature_extractor"""   )

										lowerCAmelCase		=			image_processor if image_processor is not None else feature_extractor
										if image_processor is None:
														raise ValueError("""You need to specify an `image_processor`."""   )
										if tokenizer is None:
														raise ValueError("""You need to specify a `tokenizer`."""   )

										super().__init__(lowerCAmelCase  ,  lowerCAmelCase   )
										lowerCAmelCase		=			self.image_processor


						def __call__(							self			:     Union[str, Any]  ,  lowerCAmelCase			:     str=None  ,  lowerCAmelCase			:     Tuple=None  ,  lowerCAmelCase			:     int=None  ,  **lowerCAmelCase			:     str   ):

										if text is None and videos is None:
														raise ValueError("""You have to specify either text or videos. Both cannot be none."""   )

										if text is not None:
														lowerCAmelCase		=			self.tokenizer(lowerCAmelCase  ,  return_tensors=lowerCAmelCase  ,  **lowerCAmelCase   )

										if videos is not None:
														lowerCAmelCase		=			self.image_processor(lowerCAmelCase  ,  return_tensors=lowerCAmelCase  ,  **lowerCAmelCase   )

										if text is not None and videos is not None:
														lowerCAmelCase		=			image_features.pixel_values
														return encoding
										elif text is not None:
														return encoding
										else:
														return BatchEncoding(data=dict(**lowerCAmelCase   )  ,  tensor_type=lowerCAmelCase   )


						def 					__lowercase	(							self			:     str  ,  *lowerCAmelCase			:     List[str]  ,  **lowerCAmelCase			:     int   ):
										return self.tokenizer.batch_decode(*lowerCAmelCase  ,  **lowerCAmelCase   )


						def 					__lowercase	(							self			:     List[str]  ,  *lowerCAmelCase			:     Any  ,  **lowerCAmelCase			:     List[Any]   ):
										return self.tokenizer.decode(*lowerCAmelCase  ,  **lowerCAmelCase   )


						@property
						def 					__lowercase	(							self			:     Dict   ):
										return ["input_ids", "attention_mask", "position_ids", "pixel_values"]


						@property
						def 					__lowercase	(							self			:     List[str]   ):
										warnings.warn(
										    """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""  ,  lowerCAmelCase  ,  )
										return self.image_processor_class




						@property
						def 					__lowercase	(							self			:     Tuple   ):
										warnings.warn(
										    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""  ,  lowerCAmelCase  ,  )
										return self.image_processor





