





import re
import string

import numpy as np

import datasets


SCREAMING_SNAKE_CASE__       :			Union[str, Any]			      =						"""
Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.
"""

SCREAMING_SNAKE_CASE__       :			Dict			      =						"""
Args:
    predictions: List of predicted texts.
    references: List of reference texts.
    regexes_to_ignore: List, defaults to None. Regex expressions of characters to
        ignore when calculating the exact matches. Note: these regexes are removed
        from the input data before the changes based on the options below (e.g. ignore_case,
        ignore_punctuation, ignore_numbers) are applied.
    ignore_case: Boolean, defaults to False. If true, turns everything
        to lowercase so that capitalization differences are ignored.
    ignore_punctuation: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
    ignore_numbers: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
Returns:
    exact_match: Dictionary containing exact_match rate. Possible values are between 0.0 and 100.0, inclusive.
Examples:
    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    25.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    50.0


    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    75.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)
    >>> print(round(results[\"exact_match\"], 1))
    100.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"The cat sat on the mat.\", \"Theaters are great.\", \"It's like comparing oranges and apples.\"]
    >>> preds = [\"The cat sat on the mat?\", \"Theaters are great.\", \"It's like comparing apples and oranges.\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    33.3

"""

SCREAMING_SNAKE_CASE__       :			str			      =						"""
"""







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





   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





      return datasets.MetricInfo(
          description=_DESCRIPTION					,			citation=_CITATION					,			inputs_description=_KWARGS_DESCRIPTION					,			features=datasets.Features(
              {
                  "predictions": datasets.Value("string"					,			id="sequence"      ),
                  "references": datasets.Value("string"					,			id="sequence"      ),
              }      )					,			reference_urls=[]					,			)





   def 	_snake_case ( self					,			snake_case					,			snake_case					,			snake_case=None					,			snake_case=False					,			snake_case=False					,			snake_case=False					,			)				->  Optional[Any]:
      """simple docstring"""





      if regexes_to_ignore is not None:
         for s in regexes_to_ignore:
            a__	:						int      		=  np.array([re.sub(snake_case					,			""					,			snake_case      ) for x in predictions]      )
            a__	:						List[Any]      		=  np.array([re.sub(snake_case					,			""					,			snake_case      ) for x in references]      )
      else:
         a__	:						str      		=  np.asarray(snake_case      )
         a__	:						Union[str, Any]      		=  np.asarray(snake_case      )

      if ignore_case:
         a__	:						Optional[int]      		=  np.char.lower(snake_case      )
         a__	:						int      		=  np.char.lower(snake_case      )

      if ignore_punctuation:
         a__	:						List[str]      		=  string.punctuation.maketrans(""					,			""					,			string.punctuation      )
         a__	:						str      		=  np.char.translate(snake_case					,			table=snake_case      )
         a__	:						Optional[int]      		=  np.char.translate(snake_case					,			table=snake_case      )

      if ignore_numbers:
         a__	:						Optional[Any]      		=  string.digits.maketrans(""					,			""					,			string.digits      )
         a__	:						Optional[Any]      		=  np.char.translate(snake_case					,			table=snake_case      )
         a__	:						int      		=  np.char.translate(snake_case					,			table=snake_case      )

      a__	:						Tuple      		=  predictions == references

      return {"exact_match": np.mean(snake_case      ) * 100}








import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING


SCREAMING_SNAKE_CASE__       :			int			      =						logging.get_logger(__name__)







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						int     		=				"""upernet"""





   def __init__( self					,			snake_case=None					,			snake_case=512					,			snake_case=0.02					,			snake_case=[1, 2, 3, 6]					,			snake_case=True					,			snake_case=0.4					,			snake_case=384					,			snake_case=256					,			snake_case=1					,			snake_case=False					,			snake_case=255					,			**snake_case					,			)				->  Optional[Any]:
      """simple docstring"""





      super().__init__(**snake_case      )

      if backbone_config is None:
         logger.info("`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."      )
         a__	:						List[str]      		=  CONFIG_MAPPING["resnet"](out_features=["stage1", "stage2", "stage3", "stage4"]      )
      elif isinstance(snake_case					,			snake_case      ):
         a__	:						Optional[int]      		=  backbone_config.get("model_type"      )
         a__	:						str      		=  CONFIG_MAPPING[backbone_model_type]
         a__	:						str      		=  config_class.from_dict(snake_case      )

      a__	:						int      		=  backbone_config
      a__	:						Optional[Any]      		=  hidden_size
      a__	:						Optional[Any]      		=  initializer_range
      a__	:						Tuple      		=  pool_scales
      a__	:						Optional[Any]      		=  use_auxiliary_head
      a__	:						Optional[Any]      		=  auxiliary_loss_weight
      a__	:						Dict      		=  auxiliary_in_channels
      a__	:						Optional[int]      		=  auxiliary_channels
      a__	:						Any      		=  auxiliary_num_convs
      a__	:						Any      		=  auxiliary_concat_input
      a__	:						int      		=  loss_ignore_index





   def 	_snake_case ( self      )				->  str:
      """simple docstring"""





      a__	:						Tuple      		=  copy.deepcopy(self.__dict__      )
      a__	:						Optional[Any]      		=  self.backbone_config.to_dict()
      a__	:						List[Any]      		=  self.__class__.model_type
      return output

