code: def plot_2d_grid(weights, ax=None, color="green", hexagon=False):
      if weights.ndim != 3:
          raise ValueError(
              "Number of dimensions should be equal to 3 "
              "(shape: (2, height, width)), got {} instead"
              "".format(weights.ndim)
          )
  
      n_features = weights.shape[0]
  
      if n_features != 2:
          raise ValueError("First dimension should be equal to 2")
  
      if ax is None:
          ax = plt.gca()
  
      for (neuron_x, neuron_y), neighbours in iter_neighbours(
          weights, hexagon
      ):
          for neigbour_x, neigbour_y in neighbours:
              neurons_x_coords = (neuron_x, neigbour_x)
              neurons_y_coords = (neuron_y, neigbour_y)
  
              neurons = weights[:, neurons_x_coords, neurons_y_coords]
              ax.plot(*neurons, color=color)
  
file_path: neupy/examples/competitive/utils.py
imports: from itertools import product
  import numpy
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: plot_2d_grid(weights, ax, color, hexagon) without return types