code: def generate_harness(path):
      # grandparent is global config, parent is org config.
      # it's ok if they don't exist.
      hc = "harness.conf"
      config_paths = [
          path.parent.parent / hc,
          path.parent / hc,
          path / hc,
      ]
      # used to make PROJECT_DIR work just like shell
      interp = configparser.ExtendedInterpolation()
      conf = configparser.ConfigParser(interpolation=interp)
      conf.read(config_paths)
  
      # Build the model args. We don't have to interpolate the path here, it can
      # be handled in the file directly thanks to interpolation. Also, fall back
      # to the last two parts of the directory path as the HF name.
      fallback_path = os.path.join(*path.parts[-2:])
  
      model_path = conf["model"].get("path", fallback_path)
      # tokenizer is technically not required, but almost always present
      tokenizer = conf["model"].get("tokenizer")
      # args are technically not required
      args = conf["model"].get("args")
      model_args = f"pretrained={model_path}"
  
      if tokenizer in ("''", '""'):
          tokenizer = None
      if tokenizer:
          model_args += "," + f"tokenizer={tokenizer}"
  
      if args in ("''", '""'):
          args = None
      if args:
          model_args += "," + args
  
      # Make the task list. Basically just attaching prompt versions, but some tasks
      # have no prompt versions because they don't use prompts.
      tasks = []
      fewshot = []
      for key, val in conf.items():
          if not key.startswith("tasks."):
              continue
  
          name = key.split(".", 1)[1]
          prompt = val["prompt"]
          # By default configparser doesn't handle empty strings
          # properly, so check for obvious attempts and fix them.
          if prompt in ("''", '""'):
              prompt = ""
          if prompt:
              name = f"{name}-{prompt}"
          tasks.append(name)
          fewshot.append(val["fewshot"])
  
      tasks = ",".join(tasks)
      fewshot = ",".join(fewshot)
  
      output_path = path / "result.json"
      model_type = conf["model"]["model"]
      script = (
          "python main.py "
          f"--device cuda "
          f"--model {model_type} "
          f"--model_args {model_args} "
          f"--tasks {tasks} "
          f"--num_fewshot {fewshot} "
          f"--output_path {output_path} "
      )
      return script.strip()
  
imports: import os
  import sys
  import configparser
  from pathlib import Path
  import argparse
label_desc: Use image node_id 1 for calling a global function with example usage: generate_harness(path) and returns: script