
"""simple docstring"""





import copy
import os
from typing import Union

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


_a														=		logging.get_logger(__name__)

_a														=		{
    """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-base/blob/main/config.json""",
    """BridgeTower/bridgetower-base-itm-mlm""": (
        """https://huggingface.co/BridgeTower/bridgetower-base-itm-mlm/blob/main/config.json"""
    ),
}






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'bridgetower_vision_model'



		def __init__(					self				,		__a=7_68				,		__a=12				,		__a=3				,		__a=16				,		__a=2_88				,		__a=1				,		__a=1e-05				,		__a=False				,		__a=True				,		__a=False				,		**__a				,		)       ->       Dict:






							'''simple docstring'''
							super().__init__(**__a)
							_UpperCamelCase							 =  hidden_size
							_UpperCamelCase							 =  num_hidden_layers
							_UpperCamelCase							 =  num_channels
							_UpperCamelCase							 =  patch_size
							_UpperCamelCase							 =  image_size
							_UpperCamelCase							 =  initializer_factor
							_UpperCamelCase							 =  layer_norm_eps
							_UpperCamelCase							 =  stop_gradient
							_UpperCamelCase							 =  share_layernorm
							_UpperCamelCase							 =  remove_last_layer




		@classmethod
		def 						UpperCAmelCase							(					cls				,		__a				,		**__a)       ->       "PretrainedConfig":






							'''simple docstring'''
							_UpperCamelCase ,  _UpperCamelCase							 =  cls.get_config_dict(__a				,		**__a)

							if config_dict.get('''model_type''') == "bridgetower":
												_UpperCamelCase							 =  config_dict['''text_config''']

							if "model_type" in config_dict and hasattr(cls				,		'''model_type''') and config_dict["model_type"] != cls.model_type:
												logger.warning(
												    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
												    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.''')

							return cls.from_dict(__a				,		**__a)






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'bridgetower_text_model'



		def __init__(					self				,		__a=5_02_65				,		__a=7_68				,		__a=12				,		__a=12				,		__a=1				,		__a=30_72				,		__a="gelu"				,		__a=0.1				,		__a=0.1				,		__a=5_14				,		__a=1				,		__a=1e-05				,		__a=1				,		__a=0				,		__a=2				,		__a="absolute"				,		__a=True				,		**__a				,		)       ->       List[Any]:






							'''simple docstring'''
							super().__init__(**__a)

							_UpperCamelCase							 =  vocab_size
							_UpperCamelCase							 =  hidden_size
							_UpperCamelCase							 =  num_hidden_layers
							_UpperCamelCase							 =  num_attention_heads
							_UpperCamelCase							 =  hidden_act
							_UpperCamelCase							 =  initializer_factor
							_UpperCamelCase							 =  intermediate_size
							_UpperCamelCase							 =  hidden_dropout_prob
							_UpperCamelCase							 =  attention_probs_dropout_prob
							_UpperCamelCase							 =  max_position_embeddings
							_UpperCamelCase							 =  type_vocab_size
							_UpperCamelCase							 =  layer_norm_eps
							_UpperCamelCase							 =  position_embedding_type
							_UpperCamelCase							 =  use_cache
							_UpperCamelCase							 =  pad_token_id
							_UpperCamelCase							 =  bos_token_id
							_UpperCamelCase							 =  eos_token_id




		@classmethod
		def 						UpperCAmelCase							(					cls				,		__a				,		**__a)       ->       "PretrainedConfig":






							'''simple docstring'''
							_UpperCamelCase ,  _UpperCamelCase							 =  cls.get_config_dict(__a				,		**__a)

							if config_dict.get('''model_type''') == "bridgetower":
												_UpperCamelCase							 =  config_dict['''text_config''']

							if "model_type" in config_dict and hasattr(cls				,		'''model_type''') and config_dict["model_type"] != cls.model_type:
												logger.warning(
												    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
												    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.''')

							return cls.from_dict(__a				,		**__a)






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'bridgetower'



		def __init__(					self				,		__a=True				,		__a="gelu"				,		__a=7_68				,		__a=1				,		__a=1e-05				,		__a=False				,		__a="add"				,		__a=12				,		__a=6				,		__a=False				,		__a=False				,		__a=None				,		__a=None				,		**__a				,		)       ->       Any:






							'''simple docstring'''
							# TODO: remove this once the Hub files are updated.
							_UpperCamelCase							 =  kwargs.pop('''text_config_dict'''				,		__a)
							_UpperCamelCase							 =  kwargs.pop('''vision_config_dict'''				,		__a)

							super().__init__(**__a)
							_UpperCamelCase							 =  share_cross_modal_transformer_layers
							_UpperCamelCase							 =  hidden_act
							_UpperCamelCase							 =  hidden_size
							_UpperCamelCase							 =  initializer_factor
							_UpperCamelCase							 =  layer_norm_eps
							_UpperCamelCase							 =  share_link_tower_layers
							_UpperCamelCase							 =  link_tower_type
							_UpperCamelCase							 =  num_attention_heads
							_UpperCamelCase							 =  num_hidden_layers
							_UpperCamelCase							 =  tie_word_embeddings
							_UpperCamelCase							 =  init_layernorm_from_vision_encoder

							if text_config is None:
												_UpperCamelCase							 =  {}
												logger.info('''`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.''')

							if vision_config is None:
												_UpperCamelCase							 =  {}
												logger.info('''`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values.''')

							_UpperCamelCase							 =  BridgeTowerTextConfig(**__a)
							_UpperCamelCase							 =  BridgeTowerVisionConfig(**__a)



		@classmethod
		def 						UpperCAmelCase							(					cls				,		__a				,		__a				,		**__a)       ->       Optional[Any]:






							'''simple docstring'''
							return cls(text_config=text_config.to_dict()				,		vision_config=vision_config.to_dict()				,		**__a)




		def 						UpperCAmelCase							(					self)       ->       Optional[int]:






							'''simple docstring'''
							_UpperCamelCase							 =  copy.deepcopy(self.__dict__)
							_UpperCamelCase							 =  self.text_config.to_dict()
							_UpperCamelCase							 =  self.vision_config.to_dict()
							_UpperCamelCase							 =  self.__class__.model_type
							return output








"""simple docstring"""





from sklearn.metrics import matthews_corrcoef

import datasets


_a														=		"""
Compute the Matthews correlation coefficient (MCC)

The Matthews correlation coefficient is used in machine learning as a
measure of the quality of binary and multiclass classifications. It takes
into account true and false positives and negatives and is generally
regarded as a balanced measure which can be used even if the classes are of
very different sizes. The MCC is in essence a correlation coefficient value
between -1 and +1. A coefficient of +1 represents a perfect prediction, 0
an average random prediction and -1 an inverse prediction.  The statistic
is also known as the phi coefficient. [source: Wikipedia]
"""

_a														=		"""
Args:
    predictions (list of int): Predicted labels, as returned by a model.
    references (list of int): Ground truth labels.
    sample_weight (list of int, float, or bool): Sample weights. Defaults to `None`.
Returns:
    matthews_correlation (dict containing float): Matthews correlation.
Examples:
    Example 1, a basic example with only predictions and references as inputs:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3])
        >>> print(round(results['matthews_correlation'], 2))
        0.54

    Example 2, the same example as above, but also including sample weights:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3],
        ...                                     sample_weight=[0.5, 3, 1, 1, 1, 2])
        >>> print(round(results['matthews_correlation'], 2))
        0.1

    Example 3, the same example as above, but with sample weights that cause a negative correlation:
        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")
        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],
        ...                                     predictions=[1, 2, 2, 0, 3, 3],
        ...                                     sample_weight=[0.5, 1, 0, 0, 0, 1])
        >>> print(round(results['matthews_correlation'], 2))
        -0.25
"""

_a														=		"""\
@article{scikit-learn,
  title={Scikit-learn: Machine Learning in {P}ython},
  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.
         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.
         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and
         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},
  journal={Journal of Machine Learning Research},
  volume={12},
  pages={2825--2830},
  year={2011}
}
"""






@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION      ,     _KWARGS_DESCRIPTION	)
class     _UpperCAmelCase(    datasets.Metric	):



		def 						UpperCAmelCase							(					self)       ->       List[Any]:






							'''simple docstring'''
							return datasets.MetricInfo(
							    description=_DESCRIPTION				,		citation=_CITATION				,		inputs_description=_KWARGS_DESCRIPTION				,		features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''int32'''),
							            '''references''': datasets.Value('''int32'''),
							        })				,		reference_urls=[
							        '''https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html'''
							    ]				,		)




		def 						UpperCAmelCase							(					self				,		__a				,		__a				,		__a=None)       ->       Dict:






							'''simple docstring'''
							return {
							    "matthews_correlation": float(matthews_corrcoef(__a				,		__a				,		sample_weight=__a)),
							}






