code: def _notebook_run(filepath):
      """Execute a notebook via nbconvert and collect output.
      :returns (parsed nb object, execution errors)
  
      Source of this function: http://www.christianmoscardi.com/blog/2016/01/20/jupyter-testing.html
      """
      with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
          args = [
              "jupyter",
              "nbconvert",
              "--to",
              "notebook",
              "--execute",
              #          "--ExecutePreprocessor.timeout=600",
              "-y",
              "--no-prompt",
              "--output",
              fout.name,
              filepath,
          ]
          subprocess.check_call(args)
  
          fout.seek(0)
          nb = nbformat.read(fout, nbformat.current_nbformat)
  
      errors = [
          output
          for cell in nb.cells
          if "outputs" in cell
          for output in cell["outputs"]
          if output.output_type == "error"
      ]
  
      return nb, errors
  
file_path: dowhy/tests/test_notebooks.py
imports: import os
  import subprocess
  import tempfile
  import nbformat
  import pytest
  from pytest import mark
label_desc: Use image node_id 1 for calling a global function with example usage: _notebook_run(filepath) and returns: nb,  errors