class_docstr: Filter samples based on text perplexity
  
  Example::
  
      sample 1: "I love textflint", score: 6.7
      sample 2: "I love TextFlinet", score: 6.34
docstr: Calculate the score based on text perplexity
  
  :param sample: data sample
  :param list fields: list of field str
  :param kwargs:
  :return int: score for sample
code: def _score(self, sample, fields, **kwargs):
      r"""
      Calculate the score based on text perplexity
  
      :param sample: data sample
      :param list fields: list of field str
      :param kwargs:
      :return int: score for sample
  
      """
      if not self.model:
          self.load_model()
  
      perplexity = 0
      for field in fields:
          tokens = sample.get_words(field)
          indexed_tokens = self.tokenizer.convert_tokens_to_ids(tokens)[
              : self.max_sent_size
          ]
          tokens_tensor = torch.tensor(
              [indexed_tokens], dtype=torch.long, device=self.device
          )
          with torch.no_grad():
              output = self.model(tokens_tensor, labels=tokens_tensor)
          loss = output.loss
          perplexity += math.exp(loss.item())
      return perplexity
  
file_path: textflint/textflint/generation/subpopulation/UT/lm.py
imports: import torch
  import math
  from ..subpopulation import SubPopulation
label_desc: Use image node_id 4 for calling the LMSubPopulation obj's underlying member method code with example usage: obj._score(sample, fields) and returns: perplexity