code: def do_one(
      nb,
      to=None,
      execute=None,
      timeout=None,
      kernel_name=None,
      report_error=True,
      error_fail=False,
      skip_existing=False,
      execute_only=False,
  ):
      import jupyter_client
      from traitlets.traitlets import TraitError
  
      os.chdir(SOURCE_DIR)
      name = os.path.basename(nb)
      dst = os.path.join(EXECUTED_DIR, name)
      hash_file = f"{os.path.splitext(dst)[0]}.json"
      existing_hash = ""
      if os.path.exists(hash_file):
          with open(hash_file, encoding="utf-8") as hf:
              existing_hash = json.load(hf)
      with open(nb, mode="rb") as f:
          current_hash = hashlib.sha512(f.read()).hexdigest()
      update_needed = existing_hash != current_hash
      # Update if dst missing
      update_needed = update_needed or not os.path.exists(dst)
      update_needed = update_needed or not skip_existing
      if not update_needed:
          print(f"Skipping {nb}")
  
      if execute and update_needed:
          print("Executing {} to {}".format(nb, dst))
          try:
              nb = execute_nb(
                  nb, dst, timeout=timeout, kernel_name=kernel_name
              )
          except Exception as e:
              if report_error:
                  print(
                      Fore.RED
                      + error_message.format(
                          notebook=nb,
                          exception=str(e),
                          message=str(e.args[0]),
                      )
                  )
                  print(Fore.RESET)
              if error_fail:
                  raise
      elif not execute:
          print("Copying (without executing) {} to {}".format(nb, dst))
          shutil.copy(nb, dst)
  
      if execute_only:
          with open(hash_file, encoding="utf-8", mode="w") as hf:
              json.dump(current_hash, hf)
          return dst
  
      dst = os.path.splitext(os.path.join(DST_DIR, name))[0] + "." + to
      print("Converting {} to {}".format(nb, dst))
      try:
          convert(nb, dst, to=to)
          with open(hash_file, encoding="utf-8", mode="w") as hf:
              json.dump(current_hash, hf)
      except TraitError:
          kernels = jupyter_client.kernelspec.find_kernel_specs()
          msg = (
              "Could not find kernel named `%s`, Available kernels:\n %s"
              % kernel_name,
              kernels,
          )
          raise ValueError(msg)
  
      return dst
  
file_path: statsmodels/tools/nbgenerate.py
imports: import argparse
  import asyncio
  from functools import partial
  import hashlib
  import json
  import os
  import shutil
  import sys
  from colorama import Fore, init
  from nbconvert import HTMLExporter, RSTExporter
  from nbconvert.preprocessors import ExecutePreprocessor
  import nbformat
label_desc: Use image node_id 4 for calling a global function with example usage: do_one(nb, to, execute, timeout, kernel_name, report_error, error_fail, skip_existing, execute_only) and returns: dst, dst