docstr: Constraint using OpenAI GPT2 language model perplexity of x_adv.
  
  :param ~textflint.input.dataset origin_dataset:
          the dataset of origin sample
  :param ~textflint.input.dataset trans_dataset:
      the dataset of translate sample
  :param str|list fields: the name of the origin field need compare.
code: def __init__(self, origin_dataset, trans_dataset, fields):
      r"""
      Constraint using OpenAI GPT2 language model perplexity of x_adv.
  
      :param ~textflint.input.dataset origin_dataset:
              the dataset of origin sample
      :param ~textflint.input.dataset trans_dataset:
          the dataset of translate sample
      :param str|list fields: the name of the origin field need compare.
  
      """
      super().__init__(origin_dataset, trans_dataset, fields)
      r"""
          :param ~textflint.input.dataset origin_dataset:
                  the dataset of origin sample
          :param ~textflint.input.dataset trans_dataset:
              the dataset of translate sample
          :param str|list fields: the name of the origin field need compare.
          
          """
      self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
      self.tokenizer.pad_token = self.tokenizer.eos_token
      self.model = GPT2LMHeadModel.from_pretrained("gpt2")
  
file_path: textflint/textflint/generation/validator/gpt2_perplexity.py
imports: import math
  import torch
  from transformers import GPT2Tokenizer, GPT2LMHeadModel
  from .validator import Validator
label_desc: Use image node_id 1 to create a new GPT2Perplexity object from inherited base classes: Validator with example: obj = GPT2Perplexity(origin_dataset, trans_dataset, fields)