code: def notebook(
      path,
      basedir,
      input,
      output,
      params,
      wildcards,
      threads,
      resources,
      log,
      config,
      rulename,
      conda_env,
      conda_base_path,
      container_img,
      singularity_args,
      env_modules,
      bench_record,
      jobid,
      bench_iteration,
      cleanup_scripts,
      shadow_dir,
      edit,
      sourcecache_path,
      runtime_sourcecache_path,
  ):
      """
      Load a script from the given basedir + path and execute it.
      """
      draft = False
      path = format(path, wildcards=wildcards, params=params)
      if edit is not None:
          if is_local_file(path):
              if not os.path.isabs(path):
                  local_path = os.path.join(basedir, path)
              else:
                  local_path = path
              if not os.path.exists(local_path):
                  # draft the notebook, it does not exist yet
                  language = None
                  draft = True
                  path = f"file://{os.path.abspath(local_path)}"
                  if path.endswith(".py.ipynb"):
                      language = "jupyter_python"
                  elif path.endswith(".r.ipynb"):
                      language = "jupyter_r"
                  else:
                      raise WorkflowError(
                          "Notebook to edit has to end on .py.ipynb or .r.ipynb in order "
                          "to decide which programming language shall be used."
                      )
          else:
              raise WorkflowError(
                  "Notebook {} is not local, but edit mode is only allowed for "
                  "local notebooks.".format(path)
              )
  
      if not draft:
          path, source, language, is_local, cache_path = get_source(
              path,
              SourceCache(sourcecache_path, runtime_sourcecache_path),
              basedir,
              wildcards,
              params,
          )
      else:
          source = None
          cache_path = None
          is_local = True
          path = infer_source_file(path)
  
      exec_class = get_exec_class(language)
  
      executor = exec_class(
          path,
          cache_path,
          source,
          basedir,
          input,
          output,
          params,
          wildcards,
          threads,
          resources,
          log,
          config,
          rulename,
          conda_env,
          conda_base_path,
          container_img,
          singularity_args,
          env_modules,
          bench_record,
          jobid,
          bench_iteration,
          cleanup_scripts,
          shadow_dir,
          is_local,
      )
  
      if edit is None:
          executor.evaluate(edit=edit)
      elif edit.draft_only:
          executor.draft()
          msg = f"Generated skeleton notebook:\n{path} "
          if conda_env and not container_img:
              msg += (
                  "\n\nEditing with VSCode:\nOpen notebook, run command 'Select notebook kernel' (Ctrl+Shift+P or Cmd+Shift+P), and choose:"
                  "\n{}\n".format(
                      str(
                          Path(conda_env)
                          / "bin"
                          / executor.get_interpreter_exec()
                      )
                  )
              )
              msg += (
                  "\nEditing with Jupyter CLI:"
                  "\nconda activate {}\njupyter notebook {}\n".format(
                      conda_env, path
                  )
              )
          logger.info(msg)
      elif draft:
          executor.draft_and_edit(listen=edit)
      else:
          executor.evaluate(edit=edit)
  
imports: from abc import abstractmethod
  import os
  from pathlib import Path
  import tempfile
  import re
  from snakemake.exceptions import WorkflowError
  from snakemake.script import get_source, ScriptBase, PythonScript, RScript
  from snakemake.logging import logger
  from snakemake.common import is_local_file
  from snakemake.common import ON_WINDOWS
  from snakemake.sourcecache import SourceCache, infer_source_file
  from snakemake.utils import format
label_desc: Use image node_id 3 for calling a global function with example usage: notebook(path, basedir, input, output, params, wildcards, threads, resources, log, config, rulename, conda_env, conda_base_path, container_img, singularity_args, env_modules, bench_record, jobid, bench_iteration, cleanup_scripts, shadow_dir, edit, sourcecache_path, runtime_sourcecache_path) without return types