code: def write_metadata(localdir, srcdir, **kwargs):
      """Write meta.json file with some information on our setup."""
      if not localdir:
          return
  
      metadata = {
          "env": os.environ.copy(),
          "date_start": time.strftime("%Y-%m-%d %H:%M:%S"),
      }
      metadata.update(kwargs)
  
      try:
          import git
      except ImportError:
          logging.warning(
              "Couldn't import gitpython module; install it with `pip install gitpython`."
          )
      else:
          try:
              repo = git.Repo(
                  path=srcdir, search_parent_directories=True
              )
              metadata["git"] = {
                  "commit": repo.commit().hexsha,
                  "is_dirty": repo.is_dirty(),
                  "path": repo.git_dir,
              }
              if not repo.head.is_detached:
                  metadata["git"]["branch"] = repo.active_branch.name
          except git.InvalidGitRepositoryError:
              pass
  
      if "git" not in metadata:
          logging.warning("Couldn't determine git data.")
  
      symlink = os.path.join(localdir, "meta.json")
      filename = "%s.%s.%d" % (
          symlink,
          time.strftime("%Y%m%d-%H%M%S"),
          os.getpid(),
      )
  
      with open(filename, "w") as f:
          json.dump(metadata, f, indent=2, sort_keys=True)
  
      symlink_path(os.path.relpath(filename, start=localdir), symlink)
  
imports: import csv
  import json
  import logging
  import os
  import time
label_desc: Use image node_id 3 for calling a global function with example usage: write_metadata(localdir, srcdir) without return types