def mark_as_required(self):
    """Adds this loss to the MARKED_LOSSES collection."""
    if self not in tf.get_collection(bookkeeper.GraphKeys.MARKED_LOSSES):
      tf.add_to_collection(bookkeeper.GraphKeys.MARKED_LOSSES, self)