code: def textsynth_mock_completion(**kwargs):
      # Mock completion function
      # Loads from a cached+pickled response if it exists, otherwise it will actually try to ping
      import requests
  
      os.makedirs("tests/testdata", exist_ok=True)
      hash_kwargs = {k: v for k, v in kwargs.items() if k != "headers"}
      hash = hashlib.sha256(
          json.dumps(hash_kwargs, sort_keys=True).encode("utf-8")
      ).hexdigest()
      fname = f"tests/testdata/textsynth_test_{hash}.pkl"
  
      if os.path.exists(fname):
          with open(fname, "rb") as fh:
              return pickle.load(fh)
      ret = requests.post(**kwargs)
      with open(fname, "wb") as fh:
          pickle.dump(ret, fh)
      return ret
  
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 6 for calling a global function with example usage: textsynth_mock_completion() and returns: ret, pickle