code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import torch
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments
  
  import datasets
  
  
  lowerCAmelCase__   	=				'''\
  @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}
  }
  '''
  
  lowerCAmelCase__   	=				'''\
  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.
  '''
  
  
  lowerCAmelCase__   	=				'''
  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 				_lowerCamelCase				(		self)    ->       Optional[int]:
              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 				_lowerCamelCase				(		self				,		__lowerCamelCase)    ->       Any:
              if self.config_name == "default":
                     _A   : List[Any]       					=				"moussaKam/frugalscore_tiny_bert-base_bert-score"
              else:
                     _A   : Any       					=				self.config_name
              _A   : int       					=				AutoModelForSequenceClassification.from_pretrained(__SCREAMING_SNAKE_CASE)
              _A   : str       					=				AutoTokenizer.from_pretrained(__SCREAMING_SNAKE_CASE)
  
  
       def 				_lowerCamelCase				(		self				,		__lowerCamelCase				,		__lowerCamelCase				,		__lowerCamelCase=3_2				,		__lowerCamelCase=1_2_8				,		__lowerCamelCase=None				,		)    ->       int:
              assert len(__SCREAMING_SNAKE_CASE) == len(
                  __SCREAMING_SNAKE_CASE), "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:
                     _A   : Union[str, Any]       					=				"gpu" if torch.cuda.is_available() else "cpu"
              _A   : str       					=				TrainingArguments(
                  "trainer"				,		fpaa=(device == "gpu")				,		per_device_eval_batch_size=__SCREAMING_SNAKE_CASE				,		report_to="all"				,		no_cuda=(device == "cpu")				,		log_level="warning"				,		)
              _A   : List[str]       					=				{"sentence1": predictions, "sentence2": references}
              _A   : Dict       					=				datasets.Dataset.from_dict(__SCREAMING_SNAKE_CASE)
  
              def tokenize_function(__lowerCamelCase):
                     return self.tokenizer(
                         data["sentence1"]				,		data["sentence2"]				,		max_length=__SCREAMING_SNAKE_CASE				,		truncation=__SCREAMING_SNAKE_CASE				,		padding=__SCREAMING_SNAKE_CASE)
  
              _A   : Optional[Any]       					=				raw_datasets.map(__SCREAMING_SNAKE_CASE				,		batched=__SCREAMING_SNAKE_CASE)
              tokenized_datasets.remove_columns(["sentence1", "sentence2"])
              _A   : Optional[int]       					=				Trainer(self.model				,		__SCREAMING_SNAKE_CASE				,		tokenizer=self.tokenizer)
              _A   : Any       					=				trainer.predict(__SCREAMING_SNAKE_CASE)
              return {"scores": list(predictions.predictions.squeeze(-1))}
  
style_context: 
  
  
  lowerCAmelCase__   	=				'\n# Transformers installation\n! pip install transformers datasets evaluate\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n'
  
  lowerCAmelCase__   	=				[{'type': 'code', 'content': INSTALL_CONTENT}]
  lowerCAmelCase__   	=				{
      '{processor_class}': 'FakeProcessorClass',
      '{model_class}': 'FakeModelClass',
      '{object_class}': 'FakeObjectClass',
  }
  