code: def iter_neighbours(weights, hexagon=False):
      _, grid_height, grid_width = weights.shape
  
      hexagon_even_actions = (
          (-1, 0),
          (0, -1),
          (1, 0),
          (0, 1),
          (1, 1),
          (-1, 1),
      )
      hexagon_odd_actions = (
          (-1, 0),
          (0, -1),
          (1, 0),
          (0, 1),
          (-1, -1),
          (1, -1),
      )
      rectangle_actions = ((-1, 0), (0, -1), (1, 0), (0, 1))
  
      for neuron_x, neuron_y in product(
          range(grid_height), range(grid_width)
      ):
          neighbours = []
  
          if hexagon and neuron_x % 2 == 1:
              actions = hexagon_even_actions
          elif hexagon:
              actions = hexagon_odd_actions
          else:
              actions = rectangle_actions
  
          for shift_x, shift_y in actions:
              neigbour_x = neuron_x + shift_x
              neigbour_y = neuron_y + shift_y
  
              if (
                  0 <= neigbour_x < grid_height
                  and 0 <= neigbour_y < grid_width
              ):
                  neighbours.append((neigbour_x, neigbour_y))
  
          yield (neuron_x, neuron_y), neighbours
  
file_path: neupy/examples/competitive/utils.py
imports: from itertools import product
  import numpy
  import matplotlib.pyplot
label_desc: Use image node_id 1 for calling a global function with example usage: iter_neighbours(weights, hexagon) without return types