code: def _build_grid_str(specs, grid_ref, insets, insets_ref, row_seq):
      # Compute rows and columns
      rows = len(specs)
      cols = len(specs[0])
  
      # Initialize constants
      sp = "  "  # space between cell
      s_str = "[ "  # cell start string
      e_str = " ]"  # cell end string
  
      s_top = "⎡ "  # U+23A1
      s_mid = "⎢ "  # U+23A2
      s_bot = "⎣ "  # U+23A3
  
      e_top = " ⎤"  # U+23A4
      e_mid = " ⎟"  # U+239F
      e_bot = " ⎦"  # U+23A6
  
      colspan_str = "       -"  # colspan string
      rowspan_str = "       :"  # rowspan string
      empty_str = "    (empty) "  # empty cell string
      # Init grid_str with intro message
      grid_str = "This is the format of your plot grid:\n"
  
      # Init tmp list of lists of strings (sorta like 'grid_ref' but w/ strings)
      _tmp = [["" for c in range(cols)] for r in range(rows)]
  
      # Define cell string as function of (r, c) and grid_ref
      def _get_cell_str(r, c, subplot_refs):
          layout_keys = sorted(
              {k for ref in subplot_refs for k in ref.layout_keys}
          )
  
          ref_str = ",".join(layout_keys)
  
          # Replace yaxis2 -> y2
          ref_str = ref_str.replace("axis", "")
          return "({r},{c}) {ref}".format(r=r + 1, c=c + 1, ref=ref_str)
  
      # Find max len of _cell_str, add define a padding function
      cell_len = (
          max(
              [
                  len(_get_cell_str(r, c, ref))
                  for r, row_ref in enumerate(grid_ref)
                  for c, ref in enumerate(row_ref)
                  if ref
              ]
          )
          + len(s_str)
          + len(e_str)
      )
  
      def _pad(s, cell_len=cell_len):
          return " " * (cell_len - len(s))
  
      # Loop through specs, fill in _tmp
      for r, spec_row in enumerate(specs):
          for c, spec in enumerate(spec_row):
              ref = grid_ref[r][c]
              if ref is None:
                  if _tmp[r][c] == "":
                      _tmp[r][c] = empty_str + _pad(empty_str)
                  continue
  
              if spec["rowspan"] > 1:
                  cell_str = s_top + _get_cell_str(r, c, ref)
              else:
                  cell_str = s_str + _get_cell_str(r, c, ref)
  
              if spec["colspan"] > 1:
                  for cc in range(1, spec["colspan"] - 1):
                      _tmp[r][c + cc] = colspan_str + _pad(colspan_str)
  
                  if spec["rowspan"] > 1:
                      _tmp[r][c + spec["colspan"] - 1] = (
                          colspan_str + _pad(colspan_str + e_str)
                      ) + e_top
                  else:
                      _tmp[r][c + spec["colspan"] - 1] = (
                          colspan_str + _pad(colspan_str + e_str)
                      ) + e_str
              else:
                  padding = " " * (cell_len - len(cell_str) - 2)
                  if spec["rowspan"] > 1:
                      cell_str += padding + e_top
                  else:
                      cell_str += padding + e_str
  
              if spec["rowspan"] > 1:
                  for cc in range(spec["colspan"]):
                      for rr in range(1, spec["rowspan"]):
                          row_str = rowspan_str + _pad(rowspan_str)
                          if cc == 0:
                              if rr < spec["rowspan"] - 1:
                                  row_str = s_mid + row_str[2:]
                              else:
                                  row_str = s_bot + row_str[2:]
  
                          if cc == spec["colspan"] - 1:
                              if rr < spec["rowspan"] - 1:
                                  row_str = row_str[:-2] + e_mid
                              else:
                                  row_str = row_str[:-2] + e_bot
  
                          _tmp[r + rr][c + cc] = row_str
  
              _tmp[r][c] = cell_str + _pad(cell_str)
  
      # Append grid_str using data from _tmp in the correct order
      for r in row_seq[::-1]:
          grid_str += sp.join(_tmp[r]) + "\n"
  
      # Append grid_str to include insets info
      if insets:
          grid_str += "\nWith insets:\n"
          for i_inset, inset in enumerate(insets):
              r = inset["cell"][0] - 1
              c = inset["cell"][1] - 1
              ref = grid_ref[r][c]
  
              subplot_labels_str = ",".join(
                  insets_ref[i_inset][0].layout_keys
              )
  
              # Replace, e.g., yaxis2 -> y2
              subplot_labels_str = subplot_labels_str.replace(
                  "axis", ""
              )
  
              grid_str += (
                  s_str
                  + subplot_labels_str
                  + e_str
                  + " over "
                  + s_str
                  + _get_cell_str(r, c, ref)
                  + e_str
                  + "\n"
              )
      return grid_str
  
file_path: catboost/contrib/python/plotly/py2/plotly/subplots.py
imports: from __future__ import absolute_import, unicode_literals
  import collections
label_desc: Use image node_id 12 for calling a global function with example usage: _build_grid_str(specs, grid_ref, insets, insets_ref, row_seq) and returns: grid_str, str, unknown