code: def render_matrix(matrix, ax, color):
      from matplotlib.patches import Rectangle
      from matplotlib.collections import PatchCollection
  
      rows, cols = matrix.shape
      x_ticks = [matrix[0, i] for i in range(1, cols)]
      y_ticks = [matrix[i, 0] for i in range(1, rows)]
  
      max_density = 0
      for y in range(rows - 2):
          for x in range(cols - 2):
              area = (x_ticks[x + 1] - x_ticks[x]) * (
                  y_ticks[y + 1] - y_ticks[y]
              )
              density = matrix[y + 1, x + 1] / area
              if max_density < density:
                  max_density = density
  
      boxes = []
      for y in range(rows - 2):
          for x in range(cols - 2):
              width = x_ticks[x + 1] - x_ticks[x]
              height = y_ticks[y + 1] - y_ticks[y]
              area = width * height
              density = matrix[y + 1, x + 1] / area
              density = max(density, 1)
              # alpha = np.log(density) / np.log(max_density)
              alpha = density / max_density
              rect = Rectangle(
                  (x_ticks[x], y_ticks[y]),
                  width,
                  height,
                  alpha=alpha,
                  color=color,
              )
              boxes.append(rect)
  
      pc = PatchCollection(boxes, match_original=True)
  
      ax.add_collection(pc)
  
      # Plot something
      _ = ax.errorbar([], [], xerr=[], yerr=[], fmt="None", ecolor="k")
  
      return x_ticks[0], x_ticks[-1], y_ticks[0], y_ticks[-1]
  
imports: from typing import List
  import numpy
  import tensorflow
label_desc: Use image node_id 1 for calling the MatPlotLibTensorBoardAnalytics obj's underlying member method code with example usage: obj.render_matrix(matrix, ax, color) and returns: x_ticks,  x_ticks,  y_ticks,  y_ticks