code: def generate_report(estimator):
      """Generate a report for Nilearn objects.
  
      Reports are useful to visualize steps in a processing pipeline.
      Example use case: visualize the overlap of a mask and reference image
      in NiftiMasker.
  
      Parameters
      ----------
      estimator : Object instance of BaseEstimator.
          Object for which the report should be generated.
  
      Returns
      -------
      report : HTMLReport
  
      """
      if hasattr(estimator, "_report_content"):
          data = estimator._report_content
      else:
          data = {}
      if not hasattr(estimator, "_reporting_data"):
          warnings.warn(
              "This object has not been fitted yet ! "
              "Make sure to run `fit` before inspecting reports."
          )
          return _update_template(
              title="Empty Report",
              docstring=(
                  "This report was not generated. Please `fit` the object."
              ),
              content=_embed_img(None),
              overlay=None,
              parameters={},
              data=data,
          )
  
      elif estimator._reporting_data is None:
          warnings.warn(
              "Report generation not enabled ! "
              "No visual outputs will be created."
          )
          return _update_template(
              title="Empty Report",
              docstring=(
                  "This report was not "
                  "generated. Please check "
                  "that reporting is enabled."
              ),
              content=_embed_img(None),
              overlay=None,
              parameters={},
              data=data,
          )
  
      return _create_report(estimator, data)
  
imports: import copy
  import os
  import warnings
  from pathlib import Path
  from string import Template
  from nilearn.externals import tempita
  from nilearn.plotting.html_document import HTMLDocument
  from nilearn.reporting.utils import figure_to_svg_base64
label_desc: Use image node_id 6 for calling a global function with example usage: generate_report(estimator) and returns: _create_report, _update_template, _update_template