def METHOD_NAME(
    tmpdir,
    notebook_path,
    input_path,
    output_path,
    batch_size=None,
    clean_up=False,
    transform=None,
):
    #     os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)
    if batch_size and not os.environ.get("BATCH_SIZE", None):
        os.environ["BATCH_SIZE"] = str(batch_size)
    if not os.environ.get("INPUT_DATA_DIR", None):
        os.environ["INPUT_DATA_DIR"] = input_path
    if not os.environ.get("OUTPUT_DATA_DIR", None):
        os.environ["OUTPUT_DATA_DIR"] = output_path
    # make directories if not there
    if not os.path.exists(os.environ["OUTPUT_DATA_DIR"]):
        os.makedirs(os.environ["OUTPUT_DATA_DIR"])
    # read in the notebook as JSON, and extract a python script from it
    notebook = json.load(open(notebook_path))
    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])
    # clear out products
    if clean_up:
        shutil.rmtree(output_path)