code: def make_glm_report(
      model,
      contrasts,
      title=None,
      bg_img="MNI152TEMPLATE",
      threshold=3.09,
      alpha=0.001,
      cluster_threshold=0,
      height_control="fpr",
      two_sided=False,
      min_distance=8.0,
      plot_type="slice",
      cut_coords=None,
      display_mode=None,
      report_dims=(1600, 800),
  ):
      """Return HTMLReport object \
      for a report which shows all important aspects of a fitted GLM.
  
      The object can be opened in a browser, displayed in a notebook,
      or saved to disk as a standalone HTML file.
  
      Examples
      --------
      report = make_glm_report(model, contrasts)
      report.open_in_browser()
      report.save_as_html(destination_path)
  
      Parameters
      ----------
      model : FirstLevelModel or SecondLevelModel object
          A fitted first or second level model object.
          Must have the computed design matrix(ces).
  
      contrasts : Dict[string, ndarray] or String or List[String] or ndarray or
          List[ndarray]
  
          Contrasts information for a first or second level model.
  
          Example:
  
              Dict of :term:`contrast` names and coefficients,
              or list of :term:`contrast` names
              or list of :term:`contrast` coefficients
              or :term:`contrast` name
              or :term:`contrast` coefficient
  
              Each :term:`contrast` name must be a string.
              Each :term:`contrast` coefficient must be a list
              or numpy array of ints.
  
          Contrasts are passed to ``contrast_def`` for FirstLevelModel
          (:func:`nilearn.glm.first_level.FirstLevelModel.compute_contrast`)
          & second_level_contrast for SecondLevelModel
          (:func:`nilearn.glm.second_level.SecondLevelModel.compute_contrast`)
  
      title : String, optional
          If string, represents the web page's title and primary heading,
          model type is sub-heading.
          If None, page titles and headings are autogenerated
          using :term:`contrast` names.
  
      bg_img : Niimg-like object, default='MNI152TEMPLATE'
          See :ref:`extracting_data`.
          The background image for mask and stat maps to be plotted on upon.
          To turn off background image, just pass "bg_img=None".
  
      threshold : float, default=3.09
          Cluster forming threshold in same scale as `stat_img` (either a
          t-scale or z-scale value). Used only if height_control is None.
  
      alpha : float, default=0.001
          Number controlling the thresholding (either a p-value or q-value).
          Its actual meaning depends on the height_control parameter.
          This function translates alpha to a z-scale threshold.
  
      cluster_threshold : int, default=0
          Cluster size threshold, in voxels.
  
      height_control : string, default='fpr'
          false positive control meaning of cluster forming
          threshold: 'fpr' (default) or 'fdr' or 'bonferroni' or None.
  
      two_sided : `bool`, default=False
          Whether to employ two-sided thresholding or to evaluate positive values
          only.
  
      min_distance : float, default=8
          For display purposes only.
          Minimum distance between subpeaks in mm.
  
      plot_type : String, {'slice', 'glass'}, default='slice'
          Specifies the type of plot to be drawn for the statistical maps.
  
      %(cut_coords)s
  
      display_mode : string, optional
          Default is 'z' if plot_type is 'slice'; '
          ortho' if plot_type is 'glass'.
  
          Choose the direction of the cuts:
          'x' - sagittal, 'y' - coronal, 'z' - axial,
          'l' - sagittal left hemisphere only,
          'r' - sagittal right hemisphere only,
          'ortho' - three cuts are performed in orthogonal directions.
  
          Possible values are:
          'ortho', 'x', 'y', 'z', 'xz', 'yx', 'yz',
          'l', 'r', 'lr', 'lzr', 'lyr', 'lzry', 'lyrz'.
  
      report_dims : Sequence[int, int], default=(1600, 800)
          Specifies width, height (in pixels) of report window within a notebook.
          Only applicable when inserting the report into a Jupyter notebook.
          Can be set after report creation using report.width, report.height.
  
      Returns
      -------
      report_text : HTMLReport Object
          Contains the HTML code for the :term:`GLM` Report.
  
      """
      if bg_img == "MNI152TEMPLATE":
          bg_img = MNI152TEMPLATE
      if not display_mode:
          display_mode_selector = {"slice": "z", "glass": "lzry"}
          display_mode = display_mode_selector[plot_type]
  
      try:
          design_matrices = model.design_matrices_
      except AttributeError:
          design_matrices = [model.design_matrix_]
  
      html_head_template_path = os.path.join(
          HTML_TEMPLATE_ROOT_PATH, "report_head_template.html"
      )
  
      html_body_template_path = os.path.join(
          HTML_TEMPLATE_ROOT_PATH, "report_body_template.html"
      )
  
      with open(html_head_template_path) as html_head_file_obj:
          html_head_template_text = html_head_file_obj.read()
      report_head_template = string.Template(html_head_template_text)
  
      with open(html_body_template_path) as html_body_file_obj:
          html_body_template_text = html_body_file_obj.read()
      report_body_template = string.Template(html_body_template_text)
  
      contrasts = _coerce_to_dict(contrasts)
      contrast_plots = _plot_contrasts(contrasts, design_matrices)
      page_title, page_heading_1, page_heading_2 = _make_headings(
          contrasts,
          title,
          model,
      )
      with pd.option_context("display.max_colwidth", 100):
          model_attributes = _model_attributes_to_dataframe(model)
          model_attributes_html = _dataframe_to_html(
              model_attributes,
              precision=2,
              header=False,
              sparsify=False,
          )
      statistical_maps = _make_stat_maps(model, contrasts)
      html_design_matrices = _dmtx_to_svg_url(design_matrices)
  
      # Select mask_img to use for plotting
      if isinstance(model.mask_img, NiftiMasker):
          mask_img = model.masker_.mask_img_
      else:
          try:
              # check that mask_img is a niiimg-like object
              check_niimg(model.mask_img)
              mask_img = model.mask_img
          except Exception:
              mask_img = model.masker_.mask_img_
  
      mask_plot_html_code = _mask_to_svg(
          mask_img=mask_img,
          bg_img=bg_img,
      )
      all_components = _make_stat_maps_contrast_clusters(
          stat_img=statistical_maps,
          contrasts_plots=contrast_plots,
          threshold=threshold,
          alpha=alpha,
          cluster_threshold=cluster_threshold,
          height_control=height_control,
          two_sided=two_sided,
          min_distance=min_distance,
          bg_img=bg_img,
          cut_coords=cut_coords,
          display_mode=display_mode,
          plot_type=plot_type,
      )
      all_components_text = "\n".join(all_components)
      report_values_head = {
          "page_title": escape(page_title),
      }
      report_values_body = {
          "page_heading_1": page_heading_1,
          "page_heading_2": page_heading_2,
          "model_attributes": model_attributes_html,
          "all_contrasts_with_plots": "".join(contrast_plots.values()),
          "design_matrices": html_design_matrices,
          "mask_plot": mask_plot_html_code,
          "component": all_components_text,
      }
      report_text_body = report_body_template.safe_substitute(
          **report_values_body
      )
      report_text = HTMLReport(
          body=report_text_body,
          head_tpl=report_head_template,
          head_values=report_values_head,
      )
      # setting report size for better visual experience in Jupyter Notebooks.
      report_text.width, report_text.height = _check_report_dims(
          report_dims
      )
      return report_text
  
imports: import os
  import string
  import warnings
  from collections import OrderedDict
  from collections.abc import Iterable
  from html import escape
  import numpy
  import pandas
  from matplotlib import pyplot
  from nilearn.plotting import plot_glass_brain, plot_roi, plot_stat_map
  from nilearn.plotting.img_plotting import MNI152TEMPLATE
  from nilearn.plotting.matrix_plotting import plot_contrast_matrix, plot_design_matrix
  from nilearn.reporting.html_report import HTMLReport
  from .._utils import fill_doc
  from nilearn._utils import check_niimg
  from nilearn.maskers import NiftiMasker
  from nilearn.reporting.get_clusters_table import get_clusters_table
  from nilearn.reporting.utils import figure_to_svg_quoted
label_desc: Use image node_id 1 for calling a global function with example usage: make_glm_report(model, contrasts, title, bg_img, threshold, alpha, cluster_threshold, height_control, two_sided, min_distance, plot_type, cut_coords, display_mode, report_dims) and returns: report_text