

'''simple docstring'''




class 							lowercase_						:

  '''simple docstring'''





  def __init__(  self  )				->					Any:


    """simple docstring"""
    UpperCAmelCase    				=						0
    UpperCAmelCase    				=						0
    UpperCAmelCase    				=						{}
  def     snake_case_      (  self ,			a_  )				->					Any:


    """simple docstring"""
    if vertex not in self.adjacency:
      UpperCAmelCase    				=						{}
      self.num_vertices += 1
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_  )				->					Any:


    """simple docstring"""
    self.add_vertex(__UpperCamelCase  )
    self.add_vertex(__UpperCamelCase  )

    if head == tail:
      return

    UpperCAmelCase    				=						weight
    UpperCAmelCase    				=						weight
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						self.get_edges()
    for edge in edges:
      UpperCAmelCase				,   UpperCAmelCase				,   UpperCAmelCase    				=						edge
      edges.remove((tail, head, weight)  )
    for i in range(len(__UpperCamelCase  )  ):
      UpperCAmelCase    				=						list(edges[i]  )

    edges.sort(key=lambda a_  : e[2]  )
    for i in range(len(__UpperCamelCase  ) - 1  ):
      if edges[i][2] >= edges[i + 1][2]:
        UpperCAmelCase    				=						edges[i][2] + 1
    for edge in edges:
      UpperCAmelCase				,   UpperCAmelCase				,   UpperCAmelCase    				=						edge
      UpperCAmelCase    				=						weight
      UpperCAmelCase    				=						weight
  def __str__(  self  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						''
    for tail in self.adjacency:
      for head in self.adjacency[tail]:
        UpperCAmelCase    				=						self.adjacency[head][tail]
        string += F'''{head} -> {tail} == {weight}\n'''
    return string.rstrip('\n'  )
  def     snake_case_      (  self  )				->					Union[str, Any]:


    """simple docstring"""
    UpperCAmelCase    				=						[]
    for tail in self.adjacency:
      for head in self.adjacency[tail]:
        output.append((tail, head, self.adjacency[head][tail])  )
    return output
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    return self.adjacency.keys()
  @staticmethod
  def     snake_case_      (  a_=None ,			a_=None  )				->					int:


    """simple docstring"""
    UpperCAmelCase    				=						Graph()
    if vertices is None:
      UpperCAmelCase    				=						[]
    if edges is None:
      UpperCAmelCase    				=						[]
    for vertex in vertices:
      g.add_vertex(__UpperCamelCase  )
    for edge in edges:
      g.add_edge(*__UpperCamelCase  )
    return g



  class 							lowercase_						:

    '''simple docstring'''





    def __init__(  self  )				->					Union[str, Any]:


      """simple docstring"""
      UpperCAmelCase    				=						{}
      UpperCAmelCase    				=						{}
    def __len__(  self  )				->					Optional[int]:


      """simple docstring"""
      return len(self.parent  )
    def     snake_case_      (  self ,			a_  )				->					Union[str, Any]:


      """simple docstring"""
      if item in self.parent:
        return self.find(__UpperCamelCase  )

      UpperCAmelCase    				=						item
      UpperCAmelCase    				=						0
      return item
    def     snake_case_      (  self ,			a_  )				->					Optional[Any]:


      """simple docstring"""
      if item not in self.parent:
        return self.make_set(__UpperCamelCase  )
      if item != self.parent[item]:
        UpperCAmelCase    				=						self.find(self.parent[item]  )
      return self.parent[item]





    def     snake_case_      (  self ,			a_ ,			a_  )				->					Tuple:


      """simple docstring"""
      UpperCAmelCase    				=						self.find(__UpperCamelCase  )
      UpperCAmelCase    				=						self.find(__UpperCamelCase  )

      if roota == roota:
        return roota

      if self.rank[roota] > self.rank[roota]:
        UpperCAmelCase    				=						roota
        return roota

      if self.rank[roota] < self.rank[roota]:
        UpperCAmelCase    				=						roota
        return roota

      if self.rank[roota] == self.rank[roota]:
        self.rank[roota] += 1
        UpperCAmelCase    				=						roota
        return roota
      return None




  @staticmethod
  def     snake_case_      (  a_  )				->					List[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						graph.num_vertices

    UpperCAmelCase    				=						Graph.UnionFind()
    UpperCAmelCase    				=						[]
    while num_components > 1:
      UpperCAmelCase    				=						{}
      for vertex in graph.get_vertices():
        UpperCAmelCase    				=						-1

      UpperCAmelCase    				=						graph.get_edges()
      for edge in edges:
        UpperCAmelCase				,   UpperCAmelCase				,   UpperCAmelCase    				=						edge
        edges.remove((tail, head, weight)  )
      for edge in edges:
        UpperCAmelCase				,   UpperCAmelCase				,   UpperCAmelCase    				=						edge
        UpperCAmelCase    				=						union_find.find(__UpperCamelCase  )
        UpperCAmelCase    				=						union_find.find(__UpperCamelCase  )
        if seta != seta:
          if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
            UpperCAmelCase    				=						[head, tail, weight]

          if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
            UpperCAmelCase    				=						[head, tail, weight]
      for vertex in cheap_edge:
        if cheap_edge[vertex] != -1:
          UpperCAmelCase				,   UpperCAmelCase				,   UpperCAmelCase    				=						cheap_edge[vertex]
          if union_find.find(__UpperCamelCase  ) != union_find.find(__UpperCamelCase  ):
            union_find.union(__UpperCamelCase ,			__UpperCamelCase  )
            mst_edges.append(cheap_edge[vertex]  )
            UpperCAmelCase    				=						num_components - 1
    UpperCAmelCase    				=						Graph.build(edges=__UpperCamelCase  )
    return mst




from sklearn.metrics import mean_squared_error

import datasets


A		: List[Any]								=     '''\
@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}
}
'''

A		: str								=     '''\
Mean Squared Error(MSE) is the average of the square of difference between the predicted
and actual values.
'''


A		: Any								=     '''
Args:
    predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.
    references: array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.
    sample_weight: array-like of shape (n_samples,), default=None
        Sample weights.
    multioutput: {"raw_values", "uniform_average"} or array-like of shape (n_outputs,), default="uniform_average"
        Defines aggregating of multiple output values. Array-like value defines weights used to average errors.

        "raw_values" : Returns a full set of errors in case of multioutput input.

        "uniform_average" : Errors of all outputs are averaged with uniform weight.

    squared : bool, default=True
        If True returns MSE value, if False returns RMSE (Root Mean Squared Error) value.

Returns:
    mse : mean squared error.
Examples:

    >>> mse_metric = datasets.load_metric("mse")
    >>> predictions = [2.5, 0.0, 2, 8]
    >>> references = [3, -0.5, 2, 7]
    >>> results = mse_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {\'mse\': 0.375}
    >>> rmse_result = mse_metric.compute(predictions=predictions, references=references, squared=False)
    >>> print(rmse_result)
    {\'mse\': 0.6123724356957945}

    If you\'re using multi-dimensional lists, then set the config as follows :

    >>> mse_metric = datasets.load_metric("mse", "multilist")
    >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]
    >>> references = [[0, 2], [-1, 2], [8, -5]]
    >>> results = mse_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {\'mse\': 0.7083333333333334}
    >>> results = mse_metric.compute(predictions=predictions, references=references, multioutput=\'raw_values\')
    >>> print(results) # doctest: +NORMALIZE_WHITESPACE
    {\'mse\': array([0.41666667, 1. ])}
'''



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






			def    UpperCamelCase_				(      self  ):
									return datasets.MetricInfo(
									    description=_DESCRIPTION				,			citation=_CITATION				,			inputs_description=_KWARGS_DESCRIPTION				,			features=datasets.Features(self._get_feature_types()  )				,			reference_urls=[
									        """https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html"""
									    ]				,			)






			def    UpperCamelCase_				(      self  ):
									if self.config_name == "multilist":
															return {
															    "predictions": datasets.Sequence(datasets.Value("""float"""  )  ),
															    "references": datasets.Sequence(datasets.Value("""float"""  )  ),
															}
									else:
															return {
															    "predictions": datasets.Value("""float"""  ),
															    "references": datasets.Value("""float"""  ),
															}






			def    UpperCamelCase_				(      self				,			__UpperCamelCase				,			__UpperCamelCase				,			__UpperCamelCase=None				,			__UpperCamelCase="uniform_average"				,			__UpperCamelCase=True  ):
									_lowercase					       =					mean_squared_error(
									    __UpperCamelCase				,			__UpperCamelCase				,			sample_weight=__UpperCamelCase				,			multioutput=__UpperCamelCase				,			squared=__UpperCamelCase  )

									return {"mse": mse}