def _ratio(numerator_expression, denominator_expression):
  """Creates an `Expression` for a ratio.

  The result of this function is an `Expression` representing:
    numerator / denominator_bound
  where denominator_bound satisfies the following:
    denominator_lower_bound <= denominator_bound <= 1
  The resulting `Expression` will include both the implicit denominator_bound
  slack variable, and implicit constraints.

  Args:
    numerator_expression: `Expression`, the numerator of the ratio.
    denominator_expression: `Expression`, the denominator of the ratio.

  Returns:
    An `Expression` representing the ratio.

  Raises:
    TypeError: if either numerator_expression or denominator_expression is not
      an `Expression`.
  """
  return expression.BoundedExpression(
      lower_bound=_ratio_bound(
          numerator_expression=numerator_expression,
          denominator_expression=denominator_expression,
          lower_bound=True,
          upper_bound=False),
      upper_bound=_ratio_bound(
          numerator_expression=numerator_expression,
          denominator_expression=denominator_expression,
          lower_bound=False,
          upper_bound=True))