def make_gmm_unaries(X, fg_gmm, bg_gmm):
  """
  Make unaries by log probability under GMM.

  Take
    X: data in N x K ndarray where N is no. samples and K is no. features
    fg_gmm, bg_gmm: fitted sklearn.mixture.gmm

  Give
    fg_unary, bg_unary: log probabilities under the fg and bg gmms resp.
  """
  fg_un, _ = fg_gmm.score_samples(X)
  bg_un, _ = bg_gmm.score_samples(X)
  return fg_un, bg_un