code: def main():
      args = parser.parse_args()
      full_path = args.full_path
      force = args.force
      if full_path is None:
          full_path = os.path.join(
              BASE_PATH, "..", "examples", "notebooks"
          )
      notebook = args.notebook
      if notebook is None:
          notebooks = glob.glob(os.path.join(full_path, "*.ipynb"))
      else:
          if not notebook.endswith(".ipynb"):
              notebook = notebook + ".ipynb"
          notebook = os.path.abspath(os.path.join(full_path, notebook))
          if not os.path.exists(notebook):
              raise FileNotFoundError(f"Notebook {notebook} not found.")
          notebooks = [notebook]
      if not notebooks:
          import warnings
  
          warnings.warn("No notebooks found", UserWarning)
      for nb in notebooks:
          nb_full_name = os.path.split(nb)[1]
          nb_name = os.path.splitext(nb_full_name)[0]
          py_name = nb_name + ".py"
          # Get base directory to notebook
          out_file = os.path.split(nb)[0]
          # Write to ../python
          out_file = os.path.join(out_file, "..", "python", py_name)
          if is_newer(out_file, nb) and not force:
              logger.info(
                  "Skipping {}, exported version newer than "
                  "notebook".format(nb_name)
              )
              continue
          logger.info(f"Converting {nb_name}")
          with open(nb, encoding="utf8") as nb_file:
              converter = nbconvert.PythonExporter()
              python = converter.from_file(nb_file)
              code = python[0].split("\n")
              code_out = []
              for i, block in enumerate(code):
                  if "get_ipython" in block:
                      continue
                  elif block.startswith("# In[ ]:"):
                      continue
                  if block.startswith("#"):
                      # Wrap comments from Markdown
                      block = textwrap.fill(block, width=74)
                      block = block.replace("\n", "\n# ")
                  code_out.append(block)
              if not code_out[0]:
                  code_out = code_out[1:]
              loc = 0
              for i, line in enumerate(code_out):
                  if "# coding: utf" in line:
                      loc = i + 1
                      break
              code_out.insert(
                  loc, DO_NOT_EDIT.format(notebook=nb_full_name)
              )
              code_out = "\n".join(code_out)
              code_out, success = FormatCode(
                  code_out, style_config="pep8"
              )
              with open(
                  out_file, "w", encoding="utf8", newline="\n"
              ) as of:
                  of.write(code_out)
  
file_path: statsmodels/tools/export_notebooks_to_python.py
imports: import argparse
  import glob
  import logging
  import os
  import textwrap
  import nbconvert
  from yapf.yapflib.yapf_api import FormatCode
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types