code: def spread(self, X):
          
          distance, _ = self.distance_function(X, self.weights)
          dists_per_neuron = defaultdict(list)
          for x, y in zip(np.argmin(distance, 1), distance):
              dists_per_neuron[x].append(y[x])
  
          out = np.zeros(self.num_neurons)
          average_spread = {k: np.mean(v)
                            for k, v in dists_per_neuron.items()}
  
          for x, y in average_spread.items():
              out[x] = y
          return out
docs: Calculate the average spread for each node.
  
          The average spread is a measure of how far each neuron is from the
          data points which cluster to it.
  
          Parameters
          ----------
          X : numpy array
              The input data.
  
          Returns
          -------
          spread : numpy array
              The average distance from each neuron to each data point.