code: def render_notebook(
      filename: Path, replacements: Dict[str, str]
  ) -> str:
      """Takes path to the notebook, returns executed and rendered version
      :param filename: notebook
      :param replacements: dictionary with text replacements done before executing
      :return: notebook, rendered as string
      """
      with filename.open("r") as f:
          nb_as_str = f.read()
      for original, replacement in replacements.items():
          nb_as_str = nb_as_str.replace(original, replacement)
  
      nb = nbformat.read(StringIO(nb_as_str), nbformat.NO_CONVERT)
      ep = ExecutePreprocessor(timeout=60, kernel_name="python3")
      ep.preprocess(
          nb, {"metadata": {"path": str(filename.parent.absolute())}}
      )
  
      result_as_stream = StringIO()
      nbformat.write(nb, result_as_stream)
      return result_as_stream.getvalue()
  
file_path: einops/tests/test_notebooks.py
imports: from typing import Dict
  from io import StringIO
  from tests import parse_backends_to_test, is_backend_tested
  from pathlib import Path
  import nbformat
  import pytest
  from nbconvert.preprocessors import ExecutePreprocessor
label_desc: Use image node_id 1 for calling a global function with example usage: render_notebook(filename, replacements) and returns: result_as_stream