code: def _run_notebook(tmpdir, notebook_path, transform=None):
      # read in the notebook as JSON, and extract a python script from it
      notebook = json.load(open(notebook_path, encoding="utf-8"))
      source_cells = [
          cell["source"]
          for cell in notebook["cells"]
          if cell["cell_type"] == "code"
      ]
      lines = [
          transform(line.rstrip()) if transform else line
          for line in itertools.chain(*source_cells)
          if not (line.startswith("%") or line.startswith("!"))
      ]
  
      # save the script to a file, and run with the current python executable
      # we're doing this in a subprocess to avoid some issues using 'exec'
      # that were causing a segfault with globals of the exec'ed function going
      # out of scope
      script_path = os.path.join(tmpdir, "notebook.py")
      with open(script_path, "w") as script:
          script.write("\n".join(lines))
      subprocess.check_output([sys.executable, script_path])
  
file_path: Merlin/tests/unit/examples/test_scaling_criteo_optimize_notebook.py
imports: import itertools
  import json
  import os
  import subprocess
  import sys
  from distutils.spawn import find_executable
  from os.path import dirname, realpath
  import pytest
  import cudf
  from tests.conftest import get_cuda_cluster
label_desc: Use image node_id 2 for calling a global function with example usage: _run_notebook(tmpdir, notebook_path, transform) without return types