code: def dist2(ls, x1, x2=None):
      # Assumes NxD and MxD matrices.
      # Compute the squared distance matrix, given length scales.
  
      if x2 is None:
          # Find distance with self for x1.
  
          # Rescale.
          xx1 = x1 / ls
          xx2 = xx1
  
      else:
          # Rescale.
          xx1 = x1 / ls
          xx2 = x2 / ls
  
      r2 = np.maximum(
          -(
              np.dot(xx1, 2 * xx2.T)
              - np.sum(xx1 * xx1, axis=1)[:, np.newaxis]
              - np.sum(xx2 * xx2, axis=1)[:, np.newaxis].T
          ),
          0.0,
      )
  
      return r2
  
file_path: auptimizer/src/aup/Proposer/spearmint/gp.py
imports: import numpy
  import scipy.linalg
  import scipy.optimize
  import scipy.io
label_desc: Use image node_id 1 for calling a global function with example usage: dist2(ls, x1, x2) and returns: r2