code: def init_figure(
      args,
      subplot_type,
      frame_list,
      nrows,
      ncols,
      col_labels,
      row_labels,
  ):
      # Build subplot specs
      specs = [
          [dict(type=subplot_type or "domain")] * ncols
          for _ in range(nrows)
      ]
  
      # Default row/column widths uniform
      column_widths = [1.0] * ncols
      row_heights = [1.0] * nrows
      facet_col_wrap = args.get("facet_col_wrap", 0)
  
      # Build column_widths/row_heights
      if subplot_type == "xy":
          if args.get("marginal_x") is not None:
              if args["marginal_x"] == "histogram" or (
                  "color" in args and args["color"]
              ):
                  main_size = 0.74
              else:
                  main_size = 0.84
  
              row_heights = [main_size] * (nrows - 1) + [1 - main_size]
              vertical_spacing = 0.01
          elif facet_col_wrap:
              vertical_spacing = args.get("facet_row_spacing") or 0.07
          else:
              vertical_spacing = args.get("facet_row_spacing") or 0.03
  
          if args.get("marginal_y") is not None:
              if args["marginal_y"] == "histogram" or (
                  "color" in args and args["color"]
              ):
                  main_size = 0.74
              else:
                  main_size = 0.84
  
              column_widths = [main_size] * (ncols - 1) + [
                  1 - main_size
              ]
              horizontal_spacing = 0.005
          else:
              horizontal_spacing = args.get("facet_col_spacing") or 0.02
      else:
          # Other subplot types:
          #   'scene', 'geo', 'polar', 'ternary', 'mapbox', 'domain', None
          #
          # We can customize subplot spacing per type once we enable faceting
          # for all plot types
          if facet_col_wrap:
              vertical_spacing = args.get("facet_row_spacing") or 0.07
          else:
              vertical_spacing = args.get("facet_row_spacing") or 0.03
          horizontal_spacing = args.get("facet_col_spacing") or 0.02
  
      if facet_col_wrap:
          subplot_labels = [None] * nrows * ncols
          while len(col_labels) < nrows * ncols:
              col_labels.append(None)
          for i in range(nrows):
              for j in range(ncols):
                  subplot_labels[i * ncols + j] = col_labels[
                      (nrows - 1 - i) * ncols + j
                  ]
  
      def _spacing_error_translator(e, direction, facet_arg):
          """
          Translates the spacing errors thrown by the underlying make_subplots
          routine into one that describes an argument adjustable through px.
          """
          if ("%s spacing" % (direction,)) in e.args[0]:
              e.args = (
                  e.args[0]
                  + """
  Use the {facet_arg} argument to adjust this spacing.""".format(
                      facet_arg=facet_arg
                  ),
              )
              raise e
  
      # Create figure with subplots
      try:
          fig = make_subplots(
              rows=nrows,
              cols=ncols,
              specs=specs,
              shared_xaxes="all",
              shared_yaxes="all",
              row_titles=[]
              if facet_col_wrap
              else list(reversed(row_labels)),
              column_titles=[] if facet_col_wrap else col_labels,
              subplot_titles=subplot_labels if facet_col_wrap else [],
              horizontal_spacing=horizontal_spacing,
              vertical_spacing=vertical_spacing,
              row_heights=row_heights,
              column_widths=column_widths,
              start_cell="bottom-left",
          )
      except ValueError as e:
          _spacing_error_translator(
              e, "Horizontal", "facet_col_spacing"
          )
          _spacing_error_translator(e, "Vertical", "facet_row_spacing")
  
      # Remove explicit font size of row/col titles so template can take over
      for annot in fig.layout.annotations:
          annot.update(font=None)
  
      return fig
  
imports: import plotly.graph_objs
  import plotly.io
  from collections import namedtuple, OrderedDict
  from ._special_inputs import IdentityMap, Constant, Range
  from .trendline_functions import ols, lowess, rolling, expanding, ewm
  from _plotly_utils.basevalidators import ColorscaleValidator
  from plotly.colors import qualitative, sequential
  import math
  from packaging import version
  import pandas
  import numpy
  from plotly._subplots import make_subplots, _set_trace_grid_reference, _subplot_type_for_trace_type
label_desc: Use image node_id 38 for calling a global function with example usage: init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_labels) and returns: fig