import math


def computeRMS(y_true, y_pred, distances):
  """Helper function to compute RMS of a given multiclass problem.

  Args:
    y_true: The ground truth labels
    y_pred: The predicted labels
    distances: A symmetric matrix defining the distance between two labels.
  """
  
  rms = 0.0;
  
  for i in range(len(y_true)):
    yt = y_true[i]
    yp = y_pred[i]
    rms += distances[yt][yp]**2
  
  rms = math.sqrt(rms/len(y_true))
  
  return rms