code: def _interpolate_zmap(
      zmap: dict[tuple[int, int], float], contour_plot_num: int
  ) -> np.ndarray:
      # Implements interpolation formulation used in Plotly
      # to interpolate heatmaps and contour plots
      # https://github.com/plotly/plotly.js/blob/95b3bd1bb19d8dc226627442f8f66bce9576def8/src/traces/heatmap/interp2d.js#L15-L20
      # citing their doc:
      #
      # > Fill in missing data from a 2D array using an iterative
      # > poisson equation solver with zero-derivative BC at edges.
      # > Amazingly, this just amounts to repeatedly averaging all the existing
      # > nearest neighbors
      #
      # Plotly's algorithm is equivalent to solve the following linear simultaneous equation.
      # It is discretization form of the Poisson equation.
      #
      #     z[x, y] = zmap[(x, y)]                                  (if zmap[(x, y)] is given)
      # 4 * z[x, y] = z[x-1, y] + z[x+1, y] + z[x, y-1] + z[x, y+1] (if zmap[(x, y)] is not given)
  
      a_data = []
      a_row = []
      a_col = []
      b = np.zeros(contour_plot_num**2)
      for x in range(contour_plot_num):
          for y in range(contour_plot_num):
              grid_index = y * contour_plot_num + x
              if (x, y) in zmap:
                  a_data.append(1)
                  a_row.append(grid_index)
                  a_col.append(grid_index)
                  b[grid_index] = zmap[(x, y)]
              else:
                  for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
                      if (
                          0 <= x + dx < contour_plot_num
                          and 0 <= y + dy < contour_plot_num
                      ):
                          a_data.append(1)
                          a_row.append(grid_index)
                          a_col.append(grid_index)
                          a_data.append(-1)
                          a_row.append(grid_index)
                          a_col.append(
                              grid_index + dy * contour_plot_num + dx
                          )
  
      z = scipy.sparse.linalg.spsolve(
          scipy.sparse.csc_matrix((a_data, (a_row, a_col))), b
      )
  
      return z.reshape((contour_plot_num, contour_plot_num))
  
imports: from __future__ import annotations
  from typing import Callable
  from typing import Sequence
  import numpy
  from optuna._experimental import experimental_func
  from optuna._imports import try_import
  from optuna.logging import get_logger
  from optuna.study import Study
  from optuna.trial import FrozenTrial
  from optuna.visualization._contour import _AxisInfo
  from optuna.visualization._contour import _ContourInfo
  from optuna.visualization._contour import _get_contour_info
  from optuna.visualization._contour import _PlotValues
  from optuna.visualization._contour import _SubContourInfo
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 7 for calling a global function with example usage: _interpolate_zmap(zmap, contour_plot_num) and returns: z