import six
import sympy


def normalize_weights(weights):
  """Normalizes the weights (as sympy.Rational) in dictionary of weights."""
  weight_sum = sum(six.itervalues(weights))
  return {
      i: sympy.Rational(weight, weight_sum)
      for i, weight in six.iteritems(weights)
  }