def _same_dimension(x, y):
  """Determines if two `tf.Dimension`s are the same.

  Args:
    x: a `tf.Dimension` object.
    y: a `tf.Dimension` object.

  Returns:
    True iff `x` and `y` are either both _unknown_ (i.e. `None`), or both have
    the same value.
  """
  if x is None:
    return y is None
  else:
    return y is not None and x.value == y.value