code: def write_script(self, preamble, fd):
      import nbformat
  
      nb = nbformat.reads(self.source, as_version=nbformat.NO_CONVERT)
  
      self.remove_preamble_cell(nb)
      self.insert_preamble_cell(preamble, nb)
  
      fd.write(nbformat.writes(nb).encode())
  
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 the JupyterNotebook obj's underlying member method code with example usage: obj.write_script(preamble, fd) without return types