



import re
import string

import numpy as np

import datasets


A_		:     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.
'''

A_		:     Optional[Any]        =     '''
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

'''

A_		:     List[Any]        =     '''
'''



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

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


    """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 		A							(      self			:       Any							,   __lowerCAmelCase			:       str							,   __lowerCAmelCase			:       int							,   __lowerCAmelCase			:       Union[str, Any]=None							,   __lowerCAmelCase			:       str=False							,   __lowerCAmelCase			:       Dict=False							,   __lowerCAmelCase			:       Tuple=False							,   )       ->				str:


    """simple docstring"""






    if regexes_to_ignore is not None:
     for s in regexes_to_ignore:
      a						=		np.array([re.sub(__lowerCAmelCase							,   ""							,   __lowerCAmelCase							) for x in predictions]							)
      a						=		np.array([re.sub(__lowerCAmelCase							,   ""							,   __lowerCAmelCase							) for x in references]							)
    else:
     a						=		np.asarray(__lowerCAmelCase							)
     a						=		np.asarray(__lowerCAmelCase							)

    if ignore_case:
     a						=		np.char.lower(__lowerCAmelCase							)
     a						=		np.char.lower(__lowerCAmelCase							)

    if ignore_punctuation:
     a						=		string.punctuation.maketrans(""							,   ""							,   string.punctuation							)
     a						=		np.char.translate(__lowerCAmelCase							,   table=__lowerCAmelCase							)
     a						=		np.char.translate(__lowerCAmelCase							,   table=__lowerCAmelCase							)

    if ignore_numbers:
     a						=		string.digits.maketrans(""							,   ""							,   string.digits							)
     a						=		np.char.translate(__lowerCAmelCase							,   table=__lowerCAmelCase							)
     a						=		np.char.translate(__lowerCAmelCase							,   table=__lowerCAmelCase							)

    a						=		predictions == references

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






from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


A_		:     int        =     logging.get_logger(__name__)

A_		:     str        =     {
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}



class 		_lowercase		(       UpperCAmelCase__,   UpperCAmelCase__	):
   _UpperCAmelCase     	=			'''focalnet'''

   def __init__(      self			:       int							,   __lowerCAmelCase			:       Optional[Any]=224							,   __lowerCAmelCase			:       Any=4							,   __lowerCAmelCase			:       Any=3							,   __lowerCAmelCase			:       Tuple=96							,   __lowerCAmelCase			:       Dict=False							,   __lowerCAmelCase			:       Optional[int]=[192, 384, 768, 768]							,   __lowerCAmelCase			:       Union[str, Any]=[2, 2, 6, 2]							,   __lowerCAmelCase			:       Optional[int]=[2, 2, 2, 2]							,   __lowerCAmelCase			:       Union[str, Any]=[3, 3, 3, 3]							,   __lowerCAmelCase			:       str="gelu"							,   __lowerCAmelCase			:       Any=4.0							,   __lowerCAmelCase			:       Optional[int]=0.0							,   __lowerCAmelCase			:       Tuple=0.1							,   __lowerCAmelCase			:       str=False							,   __lowerCAmelCase			:       Optional[int]=1E-4							,   __lowerCAmelCase			:       Optional[Any]=False							,   __lowerCAmelCase			:       Union[str, Any]=False							,   __lowerCAmelCase			:       str=False							,   __lowerCAmelCase			:       Any=0.0_2							,   __lowerCAmelCase			:       str=1E-5							,   __lowerCAmelCase			:       Optional[Any]=32							,   __lowerCAmelCase			:       Dict=None							,   __lowerCAmelCase			:       str=None							,   **__lowerCAmelCase			:       Any							,   )       ->				List[str]:


    """simple docstring"""






    super().__init__(**__lowerCAmelCase							)

    a						=		image_size
    a						=		patch_size
    a						=		num_channels
    a						=		embed_dim
    a						=		use_conv_embed
    a						=		hidden_sizes
    a						=		depths
    a						=		focal_levels
    a						=		focal_windows
    a						=		hidden_act
    a						=		mlp_ratio
    a						=		hidden_dropout_prob
    a						=		drop_path_rate
    a						=		use_layerscale
    a						=		layerscale_value
    a						=		use_post_layernorm
    a						=		use_post_layernorm_in_modulation
    a						=		normalize_modulator
    a						=		initializer_range
    a						=		layer_norm_eps
    a						=		encoder_stride
    a						=		["stem"] + [f"""stage{idx}""" for idx in range(1							,   len(self.depths							) + 1							)]
    a		,  a						=		get_aligned_output_features_output_indices(
        out_features=__lowerCAmelCase							,   out_indices=__lowerCAmelCase							,   stage_names=self.stage_names							)

