code: def get_xhat_y_hat(prototypes, w, x):
      M = softmax(-cdist(x, prototypes), axis=1)
      x_hat = np.matmul(M, prototypes)
      y_hat = np.clip(
          np.matmul(M, w.reshape((-1, 1))),
          np.finfo(float).eps,
          1.0 - np.finfo(float).eps,
      )
      return M, x_hat, y_hat
  
imports: import numpy
  from scipy.spatial.distance import cdist
  from scipy.special import softmax
label_desc: Use image node_id 2 for calling a global function with example usage: get_xhat_y_hat(prototypes, w, x) and returns: M,  x_hat,  y_hat