docstr: :param engine: str
      OpenAI API engine (e.g. davinci)
  :param truncate: bool
      Truncate input if too long (if False and input is too long, throw error)
docstr_tok: [":","param","engine",":","str","OpenAI","API","engine","(","e.g",".","davinci",")",":","param","truncate",":","bool","Truncate","input","if","too","long","(","if","False","and","input","is","too","long",",","throw","error",")"]
code: def __init__(self, engine, truncate=False):
      """
  
      :param engine: str
          OpenAI API engine (e.g. davinci)
      :param truncate: bool
          Truncate input if too long (if False and input is too long, throw error)
      """
      super().__init__()
  
      import openai
  
      self.engine = engine
      self.tokenizer = transformers.GPT2TokenizerFast.from_pretrained(
          "gpt2"
      )
  
      self.vocab_size = self.tokenizer.vocab_size
  
      # to make the annoying "Using pad_token, but it is not set yet." error go away
      self.tokenizer.pad_token = "<|endoftext|>"
      assert self.tokenizer.encode("hello\n\nhello") == [
          31373,
          198,
          198,
          31373,
      ]
      self.truncate = truncate
      self.end_of_text_token_id = self.tokenizer.convert_tokens_to_ids(
          ["<|endoftext|>"]
      )[0]
  
      # Read from environment variable OPENAI_API_SECRET_KEY
      openai.api_key = os.environ["OPENAI_API_SECRET_KEY"]
  
imports: import os
  import numpy
  import transformers
  from lm_eval.base import BaseLM
  from lm_eval import utils
  from tqdm import tqdm
  import time
label_desc: Use image node_id 1 to create a new GPT3LM object from inherited base classes: BaseLM with example: obj = GPT3LM(engine, truncate)