code: def test_gpt3_perplexity():
      if "OPENAI_API_SECRET_KEY" not in os.environ:
          os.environ["OPENAI_API_SECRET_KEY"] = ""
      gpt3 = models.get_model("gpt3").create_from_arg_string(
          "engine=ada"
      )
      test_string = "We study empirical scaling laws for language model performance on the cross-entropy loss."
      perplexity = gpt3.loglikelihood_rolling([(test_string,)])[0]
      tgt = -84.38819608
      assert perplexity == pytest.approx(tgt, rel=1e-3)
  
      # Hack: modify gpt3 to have shorter context length to induce rolling windows
      with mock.patch.object(
          models.gpt3.GPT3LM,
          "max_length",
          new_callable=mock.PropertyMock,
      ) as mock_max_length:
          mock_max_length.return_value = 5
          gpt3 = models.get_model("gpt3").create_from_arg_string(
              "engine=ada"
          )
          perplexity = gpt3.loglikelihood_rolling([(test_string,)])[0]
      tgt = -101.81967209999999
      assert perplexity == pytest.approx(tgt, rel=1e-3)
  
file_path: lm-evaluation-harness/tests/test_models.py
imports: import hashlib
  import json
  import openai
  import os
  import pickle
  import pytest
  import unittest.mock
  import lm_eval.models
label_desc: Use image node_id 5 for calling a global function with example usage: test_gpt3_perplexity() without return types