






'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__lowerCamelCase : List[Any]											=			logging.get_logger(__name__)

__lowerCamelCase : List[Any]											=			{
    """facebook/data2vec-vision-base-ft""": (
        """https://huggingface.co/facebook/data2vec-vision-base-ft/resolve/main/config.json"""
    ),
}

class       UpperCAmelCase (						snake_case_  ):
		UpperCAmelCase					:	Any 			=		"""data2vec-vision"""




		def __init__(self      :	Union[str, Any]							,			A__      :	Optional[int]=7_6_8							,			A__      :	Optional[int]=1_2							,			A__      :	int=1_2							,			A__      :	Tuple=3_0_7_2							,			A__      :	str="gelu"							,			A__      :	Dict=0.0							,			A__      :	Dict=0.0							,			A__      :	Tuple=0.0_2							,			A__      :	Optional[int]=1e-12							,			A__      :	str=2_2_4							,			A__      :	Union[str, Any]=1_6							,			A__      :	int=3							,			A__      :	List[str]=False							,			A__      :	str=False							,			A__      :	Any=False							,			A__      :	List[Any]=False							,			A__      :	Union[str, Any]=0.1							,			A__      :	str=0.1							,			A__      :	List[str]=True							,			A__      :	List[str]=[3, 5, 7, 1_1]							,			A__      :	Any=[1, 2, 3, 6]							,			A__      :	List[str]=True							,			A__      :	Any=0.4							,			A__      :	List[str]=2_5_6							,			A__      :	Union[str, Any]=1							,			A__      :	List[Any]=False							,			A__      :	int=2_5_5							,			**A__      :	Optional[int]							,			)					-> int:
						super().__init__(**A__				)

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

						lowercase         = image_size
						lowercase         = patch_size
						lowercase         = num_channels
						lowercase         = use_mask_token
						lowercase         = use_absolute_position_embeddings
						lowercase         = use_relative_position_bias
						lowercase         = use_shared_relative_position_bias
						lowercase         = layer_scale_init_value
						lowercase         = drop_path_rate
						lowercase         = use_mean_pooling
						# decode head attributes (semantic segmentation)
						lowercase         = out_indices
						lowercase         = pool_scales
						# auxiliary head attributes (semantic segmentation)
						lowercase         = use_auxiliary_head
						lowercase         = auxiliary_loss_weight
						lowercase         = auxiliary_channels
						lowercase         = auxiliary_num_convs
						lowercase         = auxiliary_concat_input
						lowercase         = semantic_loss_ignore_index




class       UpperCAmelCase (						snake_case_  ):
		UpperCAmelCase					:	Optional[Any] 			=		version.parse('''1.11'''  )




		@property
		def 				UpperCAmelCase__   (self      :	Dict				)					-> List[str]:
						return OrderedDict(
						    [
						        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
						    ]				)





		@property
		def 				UpperCAmelCase__   (self      :	Dict				)					-> Tuple:
						return 1e-4











'''simple docstring'''

import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin

class       UpperCAmelCase (						_lowercase  ):
		UpperCAmelCase					:	Optional[Any] 			=		'''MCTCTFeatureExtractor'''
		UpperCAmelCase					:	Tuple 			=		'''AutoTokenizer'''




		def __init__(self      :	int							,			A__      :	Tuple							,			A__      :	Union[str, Any]				)					-> Dict:
						super().__init__(A__							,			A__				)
						lowercase         = self.feature_extractor
						lowercase         = False




		def __call__(self      :	Tuple							,			*A__      :	str							,			**A__      :	Dict				)					-> int:
						# For backward compatibility
						if self._in_target_context_manager:
										return self.current_processor(*A__							,			**A__				)

						if "raw_speech" in kwargs:
										warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."				)
										lowercase         = kwargs.pop("raw_speech"				)
						else:
										lowercase         = kwargs.pop("audio"							,			A__				)
						lowercase         = kwargs.pop("sampling_rate"							,			A__				)
						lowercase         = kwargs.pop("text"							,			A__				)
						if len(A__				) > 0:
										lowercase         = args[0]
										lowercase         = args[1:]

						if audio is None and text is None:
										raise ValueError("You need to specify either an `audio` or `text` input to process."				)

						if audio is not None:
										lowercase         = self.feature_extractor(A__							,			*A__							,			sampling_rate=A__							,			**A__				)
						if text is not None:
										lowercase         = self.tokenizer(A__							,			**A__				)

						if text is None:
										return inputs
						elif audio is None:
										return encodings
						else:
										lowercase         = encodings["input_ids"]
										return inputs




		def 				UpperCAmelCase__   (self      :	Tuple							,			*A__      :	str							,			**A__      :	str				)					-> str:
						return self.tokenizer.batch_decode(*A__							,			**A__				)




		def 				UpperCAmelCase__   (self      :	Any							,			*A__      :	List[Any]							,			**A__      :	List[str]				)					-> Tuple:
						# For backward compatibility
						if self._in_target_context_manager:
										return self.current_processor.pad(*A__							,			**A__				)

						lowercase         = kwargs.pop("input_features"							,			A__				)
						lowercase         = kwargs.pop("labels"							,			A__				)
						if len(A__				) > 0:
										lowercase         = args[0]
										lowercase         = args[1:]

						if input_features is not None:
										lowercase         = self.feature_extractor.pad(A__							,			*A__							,			**A__				)
						if labels is not None:
										lowercase         = self.tokenizer.pad(A__							,			**A__				)

						if labels is None:
										return input_features
						elif input_features is None:
										return labels
						else:
										lowercase         = labels["input_ids"]
										return input_features




		def 				UpperCAmelCase__   (self      :	Tuple							,			*A__      :	Optional[int]							,			**A__      :	Optional[int]				)					-> Tuple:
						return self.tokenizer.decode(*A__							,			**A__				)





		@contextmanager
		def 				UpperCAmelCase__   (self      :	Optional[Any]				)					-> Union[str, Any]:
						warnings.warn(
						    "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
						    "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
						    "your audio inputs, or in a separate call."				)
						lowercase         = True
						lowercase         = self.tokenizer
						yield
						lowercase         = self.feature_extractor
						lowercase         = False




