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

        Args:
            model (`nn.Module`):
                Pytorch model.
            inputs (`Any`):
                Input tensor collection.

        Returns:
            (`float`)
                Epoch average metric.
        """
        model.eval()
        epoch_metric = None
        labels = inputs[1]
        outputs = model(inputs[0])
        if self.metric is not None:
            self.metric.update(send_to_device(outputs, self.configs.device),
                               send_to_device(labels, self.configs.device))
            epoch_metric = self.metric.compute().item()
        return epoch_metric
Compute the step metric.
It is recommended to subclass `Trainer` and override this method when deal with custom metric in custom task.
When it is overridden, another method `compute_loss()` often needs to be overridden.

Args:
model (`nn.Module`):
Pytorch model.
inputs (`Any`):
Input tensor collection.

Returns:
(`float`)
Epoch average metric.
towhee/trainer/trainer.py