def place_target_reference_object(self, ref_predicate,
                                    is_distinct_from_target, target_position):
    """Place and return target's refenrece object and its position."""
    possible_ref_objects = self.generate_possible_targets(
        referred_size=self._vocabulary.translate_word(ref_predicate["size"]),
        referred_color=self._vocabulary.translate_word(ref_predicate["color"]),
        referred_shape=self._vocabulary.translate_word(ref_predicate["noun"]))
    possible_ref_objects = self.filter_distinct_objects(is_distinct_from_target,
                                                        possible_ref_objects)
    if not possible_ref_objects:
      return None, None
    ref_object = random.sample(possible_ref_objects, k=1).pop()
    ref_object = world_lib.Object(*ref_object)
    # Always have a valid position as invalid situations are already removed.
    ref_position = self._world.get_relative_position(
        target_position,
        self._vocabulary.translate_word(ref_predicate["location"]))
    self._world.place_object(ref_object, position=ref_position)
    self._world.reference_object = ref_object
    return ref_object, ref_position
Place and return target's refenrece object and its position.
language/gscan/data/dataset.py