    def compute_loss(self, model: nn.Module, inputs: Any):
        """
        Compute the step loss.
        It is recommended to subclass `Trainer` and override this method when deal with custom loss in custom task.
        When it is overridden, another method `compute_metric()` often needs to be overridden.

        Args:
            model (`nn.Module`):
                Pytorch model.
            inputs (`Any`):
                Model inputs when training.

        Returns:
            (`Any`)
                Loss values with `grad_fn`.
        """
        self.set_train_mode(model)
        labels = inputs[1]
        outputs = model(inputs[0])
        loss = self.loss(outputs, labels)
        return loss
Compute the step loss.
It is recommended to subclass `Trainer` and override this method when deal with custom loss in custom task.
When it is overridden, another method `compute_metric()` often needs to be overridden.

Args:
model (`nn.Module`):
Pytorch model.
inputs (`Any`):
Model inputs when training.

Returns:
(`Any`)
Loss values with `grad_fn`.
towhee/trainer/trainer.py