



"""simple docstring"""


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


__A :				Tuple					    = logging.get_logger(__name__)

__A :				str					    = {
    '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json''',
}
class       _a			(       _snake_case):
			"""simple docstring"""
			UpperCamelCase__         =						"""lxmert"""
			UpperCamelCase__         =						{}



			def __init__(		self  :     List[Any]					, __UpperCamelCase  :     Optional[Any]=3_0_5_2_2					, __UpperCamelCase  :     int=7_6_8					, __UpperCamelCase  :     Any=1_2					, __UpperCamelCase  :     Union[str, Any]=9_5_0_0					, __UpperCamelCase  :     int=1_6_0_0					, __UpperCamelCase  :     List[str]=4_0_0					, __UpperCamelCase  :     Tuple=3_0_7_2					, __UpperCamelCase  :     Optional[Any]="gelu"					, __UpperCamelCase  :     Union[str, Any]=0.1					, __UpperCamelCase  :     List[Any]=0.1					, __UpperCamelCase  :     List[Any]=5_1_2					, __UpperCamelCase  :     int=2					, __UpperCamelCase  :     Dict=0.0_2					, __UpperCamelCase  :     Dict=1e-12					, __UpperCamelCase  :     Optional[int]=9					, __UpperCamelCase  :     Dict=5					, __UpperCamelCase  :     List[str]=5					, __UpperCamelCase  :     str=2_0_4_8					, __UpperCamelCase  :     Any=4					, __UpperCamelCase  :     Tuple=6.6_7					, __UpperCamelCase  :     Dict=True					, __UpperCamelCase  :     Any=True					, __UpperCamelCase  :     Optional[int]=True					, __UpperCamelCase  :     Dict=True					, __UpperCamelCase  :     Any=True					, __UpperCamelCase  :     Dict=True					, __UpperCamelCase  :     str=True					, **__UpperCamelCase  :     Dict					, )->Optional[Any]:
							_UpperCAmelCase      		=     vocab_size
							_UpperCAmelCase      		=     hidden_size
							_UpperCAmelCase      		=     num_attention_heads
							_UpperCAmelCase      		=     hidden_act
							_UpperCAmelCase      		=     intermediate_size
							_UpperCAmelCase      		=     hidden_dropout_prob
							_UpperCAmelCase      		=     attention_probs_dropout_prob
							_UpperCAmelCase      		=     max_position_embeddings
							_UpperCAmelCase      		=     type_vocab_size
							_UpperCAmelCase      		=     initializer_range
							_UpperCAmelCase      		=     layer_norm_eps
							_UpperCAmelCase      		=     num_qa_labels
							_UpperCAmelCase      		=     num_object_labels
							_UpperCAmelCase      		=     num_attr_labels
							_UpperCAmelCase      		=     l_layers
							_UpperCAmelCase      		=     x_layers
							_UpperCAmelCase      		=     r_layers
							_UpperCAmelCase      		=     visual_feat_dim
							_UpperCAmelCase      		=     visual_pos_dim
							_UpperCAmelCase      		=     visual_loss_normalizer
							_UpperCAmelCase      		=     task_matched
							_UpperCAmelCase      		=     task_mask_lm
							_UpperCAmelCase      		=     task_obj_predict
							_UpperCAmelCase      		=     task_qa
							_UpperCAmelCase      		=     visual_obj_loss
							_UpperCAmelCase      		=     visual_attr_loss
							_UpperCAmelCase      		=     visual_feat_loss
							_UpperCAmelCase      		=     {'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
							super().__init__(**_lowerCamelCase )







import warnings

from ...utils import is_sklearn_available, requires_backends


if is_sklearn_available():
     from scipy.stats import pearsonr, spearmanr
     from sklearn.metrics import fa_score, matthews_corrcoef


snake_case							:       List[str]										=	(
    '''This metric will be removed from the library soon, metrics should be handled with the 🤗 Evaluate '''
    '''library. You can have a look at this example script for pointers: '''
    '''https://github.com/huggingface/transformers/blob/main/examples/pytorch/text-classification/run_glue.py'''
)
def 							__lowerCamelCase		(					UpperCAmelCase_		:						List[str]					,    UpperCAmelCase_		:						Optional[Any]		):




      """simple docstring"""





      warnings.warn(UpperCAmelCase_					,    UpperCAmelCase_		)
      requires_backends(UpperCAmelCase_					,    '''sklearn'''		)
      return (preds == labels).mean()
def 							__lowerCamelCase		(					UpperCAmelCase_		:						str					,    UpperCAmelCase_		:						int		):




      """simple docstring"""





      warnings.warn(UpperCAmelCase_					,    UpperCAmelCase_		)
      requires_backends(UpperCAmelCase_					,    '''sklearn'''		)
      a		:Dict									=			simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)
      a		:Any									=			fa_score(y_true=UpperCAmelCase_					,    y_pred=UpperCAmelCase_		)
      return {
          "acc": acc,
          "f1": fa,
          "acc_and_f1": (acc + fa) / 2,
      }
def 							__lowerCamelCase		(					UpperCAmelCase_		:						Dict					,    UpperCAmelCase_		:						List[Any]		):




      """simple docstring"""





      warnings.warn(UpperCAmelCase_					,    UpperCAmelCase_		)
      requires_backends(UpperCAmelCase_					,    '''sklearn'''		)
      a		:str									=			pearsonr(UpperCAmelCase_					,    UpperCAmelCase_		)[0]
      a		:Union[str, Any]									=			spearmanr(UpperCAmelCase_					,    UpperCAmelCase_		)[0]
      return {
          "pearson": pearson_corr,
          "spearmanr": spearman_corr,
          "corr": (pearson_corr + spearman_corr) / 2,
      }
def 							__lowerCamelCase		(					UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						Dict		):




      """simple docstring"""





      warnings.warn(UpperCAmelCase_					,    UpperCAmelCase_		)
      requires_backends(UpperCAmelCase_					,    '''sklearn'''		)
      assert len(UpperCAmelCase_		) == len(UpperCAmelCase_		), F'''Predictions and labels have mismatched lengths {len(UpperCAmelCase_		)} and {len(UpperCAmelCase_		)}'''
      if task_name == "cola":
            return {"mcc": matthews_corrcoef(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "sst-2":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "mrpc":
            return acc_and_fa(UpperCAmelCase_					,    UpperCAmelCase_		)
      elif task_name == "sts-b":
            return pearson_and_spearman(UpperCAmelCase_					,    UpperCAmelCase_		)
      elif task_name == "qqp":
            return acc_and_fa(UpperCAmelCase_					,    UpperCAmelCase_		)
      elif task_name == "mnli":
            return {"mnli/acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "mnli-mm":
            return {"mnli-mm/acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "qnli":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "rte":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "wnli":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      elif task_name == "hans":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      else:
            raise KeyError(UpperCAmelCase_		)






def 							__lowerCamelCase		(					UpperCAmelCase_		:						List[str]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						List[Any]		):




      """simple docstring"""





      warnings.warn(UpperCAmelCase_					,    UpperCAmelCase_		)
      requires_backends(UpperCAmelCase_					,    '''sklearn'''		)
      if len(UpperCAmelCase_		) != len(UpperCAmelCase_		):
            raise ValueError(F'''Predictions and labels have mismatched lengths {len(UpperCAmelCase_		)} and {len(UpperCAmelCase_		)}'''		)
      if task_name == "xnli":
            return {"acc": simple_accuracy(UpperCAmelCase_					,    UpperCAmelCase_		)}
      else:
            raise KeyError(UpperCAmelCase_		)





