def _update_loss(self, loss: str, outputs, inputs):
        '''Update the loss and return the weighted loss.'''
        # Update the loss
        val = self._losses_func[loss](outputs, inputs)
        # self.losses_values[loss] += val.detach()
        getattr(self, loss).add_(val.detach())
        # Return a weighted sum
        weighted_loss = self._params[loss] * val
        return weighted_loss
Update the loss and return the weighted loss.
mGPT/losses/base.py