code: def gaussian_energy_grad(x, y):  # pragma: no cover
      mu_1 = x[0] - y[0]
      mu_2 = x[1] - y[1]
  
      # Ensure width are positive
      x[2] = np.abs(x[2])
      y[2] = np.abs(y[2])
  
      # Ensure heights are positive
      x[3] = np.abs(x[3])
      y[3] = np.abs(y[3])
  
      # Ensure angle is in range -pi,pi
      x[4] = np.arcsin(np.sin(x[4]))
      y[4] = np.arcsin(np.sin(y[4]))
  
      # Covariance entries for y
      a = y[2] * np.cos(y[4]) ** 2 + y[3] * np.sin(y[4]) ** 2
      b = (y[2] - y[3]) * np.sin(y[4]) * np.cos(y[4])
      c = y[3] * np.cos(y[4]) ** 2 + y[2] * np.sin(y[4]) ** 2
  
      # Sum of covariance matrices
      sigma_11 = x[2] * np.cos(x[4]) ** 2 + x[3] * np.sin(x[4]) ** 2 + a
      sigma_12 = (x[2] - x[3]) * np.sin(x[4]) * np.cos(x[4]) + b
      sigma_22 = x[2] * np.sin(x[4]) ** 2 + x[3] * np.cos(x[4]) ** 2 + c
  
      # Determinant of the sum of covariances
      det_sigma = np.abs(sigma_11 * sigma_22 - sigma_12**2)
      x_inv_sigma_y_numerator = (
          sigma_22 * mu_1**2
          - 2 * sigma_12 * mu_1 * mu_2
          + sigma_11 * mu_2**2
      )
  
      if det_sigma < 1e-32:
          return (
              mu_1**2 + mu_2**2,
              np.array([0.0, 0.0, 1.0, 1.0, 0.0], dtype=np.float32),
          )
  
      dist = (
          x_inv_sigma_y_numerator / det_sigma
          + np.log(det_sigma)
          + np.log(2 * np.pi)
      )
  
      grad = np.zeros(5, np.float32)
      grad[0] = (2 * sigma_22 * mu_1 - 2 * sigma_12 * mu_2) / det_sigma
      grad[1] = (2 * sigma_11 * mu_2 - 2 * sigma_12 * mu_1) / det_sigma
  
      grad[2] = mu_2 * (
          mu_2 * np.cos(x[4]) ** 2 - mu_1 * np.cos(x[4]) * np.sin(x[4])
      )
      grad[2] += mu_1 * (
          mu_1 * np.sin(x[4]) ** 2 - mu_2 * np.cos(x[4]) * np.sin(x[4])
      )
      grad[2] *= det_sigma
      grad[2] -= x_inv_sigma_y_numerator * np.cos(x[4]) ** 2 * sigma_22
      grad[2] -= x_inv_sigma_y_numerator * np.sin(x[4]) ** 2 * sigma_11
      grad[2] += (
          x_inv_sigma_y_numerator
          * 2
          * sigma_12
          * np.sin(x[4])
          * np.cos(x[4])
      )
      grad[2] /= det_sigma**2 + 1e-8
  
      grad[3] = mu_1 * (
          mu_1 * np.cos(x[4]) ** 2 - mu_2 * np.cos(x[4]) * np.sin(x[4])
      )
      grad[3] += mu_2 * (
          mu_2 * np.sin(x[4]) ** 2 - mu_1 * np.cos(x[4]) * np.sin(x[4])
      )
      grad[3] *= det_sigma
      grad[3] -= x_inv_sigma_y_numerator * np.sin(x[4]) ** 2 * sigma_22
      grad[3] -= x_inv_sigma_y_numerator * np.cos(x[4]) ** 2 * sigma_11
      grad[3] -= (
          x_inv_sigma_y_numerator
          * 2
          * sigma_12
          * np.sin(x[4])
          * np.cos(x[4])
      )
      grad[3] /= det_sigma**2 + 1e-8
  
      grad[4] = (x[3] - x[2]) * (
          2 * mu_1 * mu_2 * np.cos(2 * x[4])
          - (mu_1**2 - mu_2**2) * np.sin(2 * x[4])
      )
      grad[4] *= det_sigma
      grad[4] -= (
          x_inv_sigma_y_numerator
          * (x[3] - x[2])
          * np.sin(2 * x[4])
          * sigma_22
      )
      grad[4] -= (
          x_inv_sigma_y_numerator
          * (x[2] - x[3])
          * np.sin(2 * x[4])
          * sigma_11
      )
      grad[4] -= (
          x_inv_sigma_y_numerator
          * 2
          * sigma_12
          * (x[2] - x[3])
          * np.cos(2 * x[4])
      )
      grad[4] /= det_sigma**2 + 1e-8
  
      return dist, grad
  
imports: import numba
  import numpy
  import scipy.stats
  from sklearn.metrics import pairwise_distances
label_desc: Use image node_id 49 for calling a global function with example usage: gaussian_energy_grad(x, y) and returns: dist,  grad, unknown,  np