code: 
  
  
  
  
  
  import torch
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments
  
  import datasets
  
  
  _UpperCamelCase       = '''\
  @article{eddine2021frugalscore,
    title={FrugalScore: Learning Cheaper, Lighter and Faster Evaluation Metrics for Automatic Text Generation},
    author={Eddine, Moussa Kamal and Shang, Guokan and Tixier, Antoine J-P and Vazirgiannis, Michalis},
    journal={arXiv preprint arXiv:2110.08559},
    year={2021}
  }
  '''
  
  _UpperCamelCase       = '''\
  FrugalScore is a reference-based metric for NLG models evaluation. It is based on a distillation approach that allows to learn a fixed, low cost version of any expensive NLG metric, while retaining most of its original performance.
  '''
  
  
  _UpperCamelCase       = '''
  Calculates how good are predictions given some references, using certain scores.
  Args:
      predictions (list of str): list of predictions to score. Each predictions
          should be a string.
      references (list of str): list of reference for each prediction. Each
          reference should be a string.
      batch_size (int): the batch size for predictions.
      max_length (int): maximum sequence length.
      device (str): either gpu or cpu
  Returns:
      scores (list of int): list of scores.
  Examples:
      >>> frugalscore = datasets.load_metric("frugalscore")
      >>> results = frugalscore.compute(predictions=[\'hello there\', \'huggingface\'], references=[\'hello world\', \'hugging face\'])
      >>> print([round(s, 3) for s in results["scores"]])
      [0.631, 0.645]
  '''
  
  
  
  
  @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION ,   _KWARGS_DESCRIPTION    )
  class 				_lowerCamelCase (    datasets.Metric    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        def 						UpperCAmelCase		( self   )       ->   Dict:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          return datasets.MetricInfo(
              description=_DESCRIPTION				,						citation=_CITATION				,						inputs_description=_KWARGS_DESCRIPTION				,						features=datasets.Features(
                  {
                      "predictions": datasets.Value("string"   ),
                      "references": datasets.Value("string"   ),
                  }   )				,						homepage="https://github.com/moussaKam/FrugalScore"				,						)
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   Dict:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          if self.config_name == "default":
            __snake_case   :				List[Any]        =       "moussaKam/frugalscore_tiny_bert-base_bert-score"
          else:
            __snake_case   :				str        =       self.config_name
          __snake_case   :				Tuple        =       AutoModelForSequenceClassification.from_pretrained(UpperCAmelCase   )
          __snake_case   :				Union[str, Any]        =       AutoTokenizer.from_pretrained(UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase=32				,						UpperCAmelCase=128				,						UpperCAmelCase=None				,						)       ->   int:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          assert len(UpperCAmelCase   ) == len(
              UpperCAmelCase   ), "predictions and references should have the same number of sentences."
          if device is not None:
            assert device in ["gpu", "cpu"], "device should be either gpu or cpu."
          else:
            __snake_case   :				List[str]        =       "gpu" if torch.cuda.is_available() else "cpu"
          __snake_case   :				int        =       TrainingArguments(
              "trainer"				,						fpaa=(device == "gpu")				,						per_device_eval_batch_size=UpperCAmelCase				,						report_to="all"				,						no_cuda=(device == "cpu")				,						log_level="warning"				,						)
          __snake_case   :				Union[str, Any]        =       {"sentence1": predictions, "sentence2": references}
          __snake_case   :				List[Any]        =       datasets.Dataset.from_dict(UpperCAmelCase   )
  
          def tokenize_function(UpperCAmelCase   ):
            return self.tokenizer(
                data["sentence1"]				,						data["sentence2"]				,						max_length=UpperCAmelCase				,						truncation=UpperCAmelCase				,						padding=UpperCAmelCase   )
  
          __snake_case   :				List[Any]        =       raw_datasets.map(UpperCAmelCase				,						batched=UpperCAmelCase   )
          tokenized_datasets.remove_columns(["sentence1", "sentence2"]   )
          __snake_case   :				Union[str, Any]        =       Trainer(self.model				,						UpperCAmelCase				,						tokenizer=self.tokenizer   )
          __snake_case   :				List[Any]        =       trainer.predict(UpperCAmelCase   )
          return {"scores": list(predictions.predictions.squeeze(-1   )   )}
  
  
style_context: 
  
  
  
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
  
  
  _UpperCamelCase       = {'''configuration_nat''': ['''NAT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NatConfig''']}
  
  
  try:
       if not is_torch_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       _UpperCamelCase       = [
           '''NAT_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''NatForImageClassification''',
           '''NatModel''',
           '''NatPreTrainedModel''',
           '''NatBackbone''',
       ]
  
  if TYPE_CHECKING:
       from .configuration_nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig
  
       try:
            if not is_torch_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .modeling_nat import (
                NAT_PRETRAINED_MODEL_ARCHIVE_LIST,
                NatBackbone,
                NatForImageClassification,
                NatModel,
                NatPreTrainedModel,
            )
  
  else:
       import sys
  
       _UpperCamelCase       = _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
  
  