def is_distinct(self, referred_size, referred_color, referred_shape,
                  actual_object, other_object):
    """Check whether other object is distinct from the referred actual object."""
    other_size, other_color, other_shape = other_object
    actual_size, actual_color, _ = actual_object
    # E.g. distinct from 'circle' -> no other circles.
    if not referred_size and not referred_color:
      if referred_shape == other_shape:
        return False
      return True
    # E.g. distinct from 'red circle' -> no other red circles of any size.
    if not referred_size:
      if referred_color == other_color and referred_shape == other_shape:
        return False
      return True
    if referred_size == "small":
      all_other_sizes = self.get_larger_sizes(actual_size)
    elif referred_size == "big":
      all_other_sizes = self.get_smaller_sizes(actual_size)
    # E.g. distinct from 'small circle' ->
    # no circles of size <= than target in any color.
    if not referred_color:
      if other_shape == referred_shape and other_size not in all_other_sizes:
        return False
      return True
    # E.g. distinct from 'small red circle' -> no red circles of size <= target.
    if (other_shape == referred_shape and other_color == actual_color and
        other_size not in all_other_sizes):
      return False
    return True
Check whether other object is distinct from the referred actual object.
language/gscan/data/dataset.py