code: def cosine_grad(x, y):
      result = 0.0
      norm_x = 0.0
      norm_y = 0.0
      for i in range(x.shape[0]):
          result += x[i] * y[i]
          norm_x += x[i] ** 2
          norm_y += y[i] ** 2
  
      if norm_x == 0.0 and norm_y == 0.0:
          dist = 0.0
          grad = np.zeros(x.shape)
      elif norm_x == 0.0 or norm_y == 0.0:
          dist = 1.0
          grad = np.zeros(x.shape)
      else:
          grad = -(x * result - y * norm_x) / np.sqrt(
              norm_x**3 * norm_y
          )
          dist = 1.0 - (result / np.sqrt(norm_x * norm_y))
  
      return dist, grad
  
imports: import numba
  import numpy
  import scipy.stats
  from sklearn.metrics import pairwise_distances
label_desc: Use image node_id 35 for calling a global function with example usage: cosine_grad(x, y) and returns: dist,  grad