





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A       : List[Any]						    = {
    "configuration_big_bird": ["BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP", "BigBirdConfig", "BigBirdOnnxConfig"],
}

try:
       if not is_sentencepiece_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __A       : Dict						    = ["BigBirdTokenizer"]

try:
       if not is_tokenizers_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __A       : Dict						    = ["BigBirdTokenizerFast"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __A       : Optional[Any]						    = [
           "BIG_BIRD_PRETRAINED_MODEL_ARCHIVE_LIST",
           "BigBirdForCausalLM",
           "BigBirdForMaskedLM",
           "BigBirdForMultipleChoice",
           "BigBirdForPreTraining",
           "BigBirdForQuestionAnswering",
           "BigBirdForSequenceClassification",
           "BigBirdForTokenClassification",
           "BigBirdLayer",
           "BigBirdModel",
           "BigBirdPreTrainedModel",
           "load_tf_weights_in_big_bird",
       ]

try:
       if not is_flax_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __A       : Optional[int]						    = [
           "FlaxBigBirdForCausalLM",
           "FlaxBigBirdForMaskedLM",
           "FlaxBigBirdForMultipleChoice",
           "FlaxBigBirdForPreTraining",
           "FlaxBigBirdForQuestionAnswering",
           "FlaxBigBirdForSequenceClassification",
           "FlaxBigBirdForTokenClassification",
           "FlaxBigBirdModel",
           "FlaxBigBirdPreTrainedModel",
       ]

if TYPE_CHECKING:
       from .configuration_big_bird import BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP, BigBirdConfig, BigBirdOnnxConfig

       try:
              if not is_sentencepiece_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_big_bird import BigBirdTokenizer

       try:
              if not is_tokenizers_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_big_bird_fast import BigBirdTokenizerFast

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_big_bird import (
                  BIG_BIRD_PRETRAINED_MODEL_ARCHIVE_LIST,
                  BigBirdForCausalLM,
                  BigBirdForMaskedLM,
                  BigBirdForMultipleChoice,
                  BigBirdForPreTraining,
                  BigBirdForQuestionAnswering,
                  BigBirdForSequenceClassification,
                  BigBirdForTokenClassification,
                  BigBirdLayer,
                  BigBirdModel,
                  BigBirdPreTrainedModel,
                  load_tf_weights_in_big_bird,
              )

       try:
              if not is_flax_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_flax_big_bird import (
                  FlaxBigBirdForCausalLM,
                  FlaxBigBirdForMaskedLM,
                  FlaxBigBirdForMultipleChoice,
                  FlaxBigBirdForPreTraining,
                  FlaxBigBirdForQuestionAnswering,
                  FlaxBigBirdForSequenceClassification,
                  FlaxBigBirdForTokenClassification,
                  FlaxBigBirdModel,
                  FlaxBigBirdPreTrainedModel,
              )

else:
       import sys

       __A       : int						    = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)












import numpy as np





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   List[Any]:




    """simple docstring"""




    _A    =       np.array(_SCREAMING_SNAKE_CASE							)
    _A    =       np.array(_SCREAMING_SNAKE_CASE							)

    _A    =       abs(predict - actual							)
    _A    =       difference.mean()

    return score





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   Optional[int]:




    """simple docstring"""




    _A    =       np.array(_SCREAMING_SNAKE_CASE							)
    _A    =       np.array(_SCREAMING_SNAKE_CASE							)

    _A    =       predict - actual
    _A    =       np.square(_SCREAMING_SNAKE_CASE							)

    _A    =       square_diff.mean()
    return score





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   Tuple:




    """simple docstring"""




    _A    =       np.array(_SCREAMING_SNAKE_CASE							)
    _A    =       np.array(_SCREAMING_SNAKE_CASE							)

    _A    =       predict - actual
    _A    =       np.square(_SCREAMING_SNAKE_CASE							)
    _A    =       square_diff.mean()
    _A    =       np.sqrt(_SCREAMING_SNAKE_CASE							)
    return score





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   List[Any]:




    """simple docstring"""




    _A    =       np.array(_SCREAMING_SNAKE_CASE							)
    _A    =       np.array(_SCREAMING_SNAKE_CASE							)

    _A    =       np.log(predict + 1							)
    _A    =       np.log(actual + 1							)

    _A    =       log_predict - log_actual
    _A    =       np.square(_SCREAMING_SNAKE_CASE							)
    _A    =       square_diff.mean()

    _A    =       np.sqrt(_SCREAMING_SNAKE_CASE							)

    return score





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   Optional[int]:




    """simple docstring"""




    _A    =       np.array(_SCREAMING_SNAKE_CASE							)
    _A    =       np.array(_SCREAMING_SNAKE_CASE							)

    _A    =       predict - actual
    _A    =       np.sum(_SCREAMING_SNAKE_CASE							) / len(_SCREAMING_SNAKE_CASE							)
    _A    =       np.sum(_SCREAMING_SNAKE_CASE							) / len(_SCREAMING_SNAKE_CASE							)
    # print(numerator, denumerator)
    _A    =       float(_SCREAMING_SNAKE_CASE							) / denumerator * 100

    return score





def 							__lowerCAmelCase(					_SCREAMING_SNAKE_CASE       ,    _SCREAMING_SNAKE_CASE							)       ->   Dict:




    """simple docstring"""




    return np.mean(np.array(_SCREAMING_SNAKE_CASE							) == np.array(_SCREAMING_SNAKE_CASE							)							)





