code: def pdist_squareformed_numpy(a):
      
      a = np.array(a, dtype=np.float64)
      a_sumrows = np.einsum('ij,ij->i', a, a)
      dist = a_sumrows[:, None] + a_sumrows - 2 * np.dot(a, a.T)
      np.fill_diagonal(dist, 0)
      return dist
docs: Compute spatial distance using pure numpy
      (similar to scipy.spatial.distance.cdist())
  
      Thanks to Divakar Roy (@droyed) at stackoverflow.com
  
      Note this needs at least np.float64 precision!
  
      Returns: dist