

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


_lowerCamelCase							       =logging.get_logger(__name__)

_lowerCamelCase							       ={
    "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json",
}



class 		a_       (							A__     ):



      """simple docstring"""







      __UpperCAmelCase					=      'lxmert'
      __UpperCAmelCase					=      {}
      def __init__(      self     :							Tuple			,snake_case     :							int=30522			,snake_case     :							Union[str, Any]=768			,snake_case     :							List[str]=12			,snake_case     :							Any=9500			,snake_case     :							int=1600			,snake_case     :							Any=400			,snake_case     :							Dict=3072			,snake_case     :							int="gelu"			,snake_case     :							List[Any]=0.1			,snake_case     :							Any=0.1			,snake_case     :							Optional[Any]=512			,snake_case     :							str=2			,snake_case     :							Optional[Any]=0.02			,snake_case     :							Optional[Any]=1e-12			,snake_case     :							Dict=9			,snake_case     :							Any=5			,snake_case     :							int=5			,snake_case     :							Tuple=2048			,snake_case     :							Union[str, Any]=4			,snake_case     :							Optional[Any]=6.67			,snake_case     :							Optional[int]=True			,snake_case     :							str=True			,snake_case     :							List[Any]=True			,snake_case     :							List[Any]=True			,snake_case     :							int=True			,snake_case     :							Dict=True			,snake_case     :							int=True			,**snake_case     :							int			,):
           SCREAMING_SNAKE_CASE      						=vocab_size
           SCREAMING_SNAKE_CASE      						=hidden_size
           SCREAMING_SNAKE_CASE      						=num_attention_heads
           SCREAMING_SNAKE_CASE      						=hidden_act
           SCREAMING_SNAKE_CASE      						=intermediate_size
           SCREAMING_SNAKE_CASE      						=hidden_dropout_prob
           SCREAMING_SNAKE_CASE      						=attention_probs_dropout_prob
           SCREAMING_SNAKE_CASE      						=max_position_embeddings
           SCREAMING_SNAKE_CASE      						=type_vocab_size
           SCREAMING_SNAKE_CASE      						=initializer_range
           SCREAMING_SNAKE_CASE      						=layer_norm_eps
           SCREAMING_SNAKE_CASE      						=num_qa_labels
           SCREAMING_SNAKE_CASE      						=num_object_labels
           SCREAMING_SNAKE_CASE      						=num_attr_labels
           SCREAMING_SNAKE_CASE      						=l_layers
           SCREAMING_SNAKE_CASE      						=x_layers
           SCREAMING_SNAKE_CASE      						=r_layers
           SCREAMING_SNAKE_CASE      						=visual_feat_dim
           SCREAMING_SNAKE_CASE      						=visual_pos_dim
           SCREAMING_SNAKE_CASE      						=visual_loss_normalizer
           SCREAMING_SNAKE_CASE      						=task_matched
           SCREAMING_SNAKE_CASE      						=task_mask_lm
           SCREAMING_SNAKE_CASE      						=task_obj_predict
           SCREAMING_SNAKE_CASE      						=task_qa
           SCREAMING_SNAKE_CASE      						=visual_obj_loss
           SCREAMING_SNAKE_CASE      						=visual_attr_loss
           SCREAMING_SNAKE_CASE      						=visual_feat_loss
           SCREAMING_SNAKE_CASE      						={'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
           super().__init__(**__snake_case				)






'''simple docstring'''






import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin

class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	lowerCamelCase__			 =       """MCTCTFeatureExtractor"""
	lowerCamelCase__			 =       """AutoTokenizer"""







	def __init__(						self			:     Dict		,			__snake_case			:     Optional[int]		,			__snake_case			:     List[str]		)			->		str:
								super().__init__(__snake_case		,			__snake_case		)
								UpperCAmelCase :       List[Any] 							=		self.feature_extractor
								UpperCAmelCase :       Union[str, Any] 							=		False







	def __call__(						self			:     Any		,			*__snake_case			:     List[str]		,			**__snake_case			:     Any		)			->		List[Any]:
								# For backward compatibility
								if self._in_target_context_manager:
															return self.current_processor(*__snake_case		,			**__snake_case		)

								if "raw_speech" in kwargs:
															warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''		)
															UpperCAmelCase :       int 							=		kwargs.pop('''raw_speech'''		)
								else:
															UpperCAmelCase :       Union[str, Any] 							=		kwargs.pop('''audio'''		,			__snake_case		)
								UpperCAmelCase :       Optional[Any] 							=		kwargs.pop('''sampling_rate'''		,			__snake_case		)
								UpperCAmelCase :       Dict 							=		kwargs.pop('''text'''		,			__snake_case		)
								if len(__snake_case		) > 0:
															UpperCAmelCase :       Any 							=		args[0]
															UpperCAmelCase :       Optional[int] 							=		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:
															UpperCAmelCase :       List[str] 							=		self.feature_extractor(__snake_case		,			*__snake_case		,			sampling_rate=__snake_case		,			**__snake_case		)
								if text is not None:
															UpperCAmelCase :       int 							=		self.tokenizer(__snake_case		,			**__snake_case		)

								if text is None:
															return inputs
								elif audio is None:
															return encodings
								else:
															UpperCAmelCase :       str 							=		encodings['''input_ids''']
															return inputs







	def      A	(						self			:     List[Any]		,			*__snake_case			:     List[Any]		,			**__snake_case			:     List[Any]		)			->		str:
								return self.tokenizer.batch_decode(*__snake_case		,			**__snake_case		)







	def      A	(						self			:     List[Any]		,			*__snake_case			:     int		,			**__snake_case			:     Optional[int]		)			->		Any:
								# For backward compatibility
								if self._in_target_context_manager:
															return self.current_processor.pad(*__snake_case		,			**__snake_case		)

								UpperCAmelCase :       List[Any] 							=		kwargs.pop('''input_features'''		,			__snake_case		)
								UpperCAmelCase :       Optional[Any] 							=		kwargs.pop('''labels'''		,			__snake_case		)
								if len(__snake_case		) > 0:
															UpperCAmelCase :       List[str] 							=		args[0]
															UpperCAmelCase :       List[Any] 							=		args[1:]

								if input_features is not None:
															UpperCAmelCase :       Tuple 							=		self.feature_extractor.pad(__snake_case		,			*__snake_case		,			**__snake_case		)
								if labels is not None:
															UpperCAmelCase :       Optional[int] 							=		self.tokenizer.pad(__snake_case		,			**__snake_case		)

								if labels is None:
															return input_features
								elif input_features is None:
															return labels
								else:
															UpperCAmelCase :       List[str] 							=		labels['''input_ids''']
															return input_features







	def      A	(						self			:     Union[str, Any]		,			*__snake_case			:     Optional[Any]		,			**__snake_case			:     Optional[int]		)			->		Optional[Any]:
								return self.tokenizer.decode(*__snake_case		,			**__snake_case		)







	@contextmanager
	def      A	(						self			:     Any		)			->		Optional[int]:
								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.'''		)
								UpperCAmelCase :       Dict 							=		True
								UpperCAmelCase :       List[Any] 							=		self.tokenizer
								yield
								UpperCAmelCase :       Tuple 							=		self.feature_extractor
								UpperCAmelCase :       List[Any] 							=		False





