code: def _make_stat_maps_contrast_clusters(
      stat_img,
      contrasts_plots,
      threshold,
      alpha,
      cluster_threshold,
      height_control,
      two_sided,
      min_distance,
      bg_img,
      cut_coords,
      display_mode,
      plot_type,
  ):
      """Populate a smaller HTML sub-template with the proper values, \
      make a list containing one or more of such components \
      & return the list to be inserted into the HTML Report Template.
  
      Each component contains the HTML code for
      a contrast & its corresponding statistical maps & cluster table;
  
      Parameters
      ----------
      stat_img : Niimg-like object or None
         Statistical image (presumably in z scale)
         whenever height_control is 'fpr' or None,
         stat_img=None is acceptable.
         If it is 'fdr' or 'bonferroni',
         an error is raised if stat_img is None.
  
      contrasts_plots : Dict[str, str]
          Contains contrast names & HTML code of the contrast's SVG plot.
  
      threshold : float
         Desired threshold in z-scale.
         This is used only if height_control is None
  
      alpha : float
          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 : float
          Cluster size threshold. In the returned thresholded map,
          sets of connected voxels (`clusters`) with size smaller
          than this number will be removed.
  
      height_control : string
          False positive control meaning of cluster forming
          threshold: 'fpr' 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.
  
      bg_img : Niimg-like object
          Only used when plot_type is 'slice'.
          See :ref:`extracting_data`.
          The background image for stat maps to be plotted on upon.
          If nothing is specified, the MNI152 template will be used.
          To turn off background image, just pass "bg_img=False".
  
      %(cut_coords)s
  
      display_mode : string
          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'.
  
      plot_type : string {'slice', 'glass'}
          The type of plot to be drawn.
  
      Returns
      -------
      all_components : List[String]
          Each element is a set of HTML code for
          contrast name, contrast plot, statistical map, cluster table.
  
      """
      all_components = []
      components_template_path = os.path.join(
          HTML_TEMPLATE_ROOT_PATH,
          "stat_maps_contrast_clusters_template.html",
      )
      with open(components_template_path) as html_template_obj:
          components_template_text = html_template_obj.read()
      for contrast_name, stat_map_img in stat_img.items():
          component_text_ = string.Template(components_template_text)
          thresholded_stat_map, threshold = threshold_stats_img(
              stat_img=stat_map_img,
              threshold=threshold,
              alpha=alpha,
              cluster_threshold=cluster_threshold,
              height_control=height_control,
          )
          table_details = _clustering_params_to_dataframe(
              threshold,
              cluster_threshold,
              min_distance,
              height_control,
              alpha,
          )
          stat_map_svg = _stat_map_to_svg(
              stat_img=thresholded_stat_map,
              bg_img=bg_img,
              cut_coords=cut_coords,
              display_mode=display_mode,
              plot_type=plot_type,
              table_details=table_details,
          )
          cluster_table = get_clusters_table(
              stat_map_img,
              stat_threshold=threshold,
              cluster_threshold=cluster_threshold,
              min_distance=min_distance,
              two_sided=two_sided,
          )
  
          cluster_table_html = _dataframe_to_html(
              cluster_table,
              precision=2,
              index=False,
              classes="cluster-table",
          )
          table_details_html = _dataframe_to_html(
              table_details,
              precision=2,
              header=False,
              classes="cluster-details-table",
          )
          components_values = {
              "contrast_name": escape(contrast_name),
              "contrast_plot": contrasts_plots[contrast_name],
              "stat_map_img": stat_map_svg,
              "cluster_table_details": table_details_html,
              "cluster_table": cluster_table_html,
          }
          component_text_ = component_text_.safe_substitute(
              **components_values
          )
          all_components.append(component_text_)
      return all_components
  
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 12 for calling a global function with example usage: _make_stat_maps_contrast_clusters(stat_img, contrasts_plots, threshold, alpha, cluster_threshold, height_control, two_sided, min_distance, bg_img, cut_coords, display_mode, plot_type) and returns: all_components