def target_loss(self, true_targets, targets, weights=None):
    """A loss for training a task model.

    This loss measures the discrepancy between the task outputs, the true and
    predicted ones.