def metrics(self, x, y, **kwargs):
        """Add metrics to the task.

        Metrics are just functions:
        - output metrics are a function of output and target
        - loss metrics are a function of loss (e.g. perplexity)
        """
        output_metrics = {
            name: U.discard_kwargs(M.output_metric_fns[name])(x, y, **kwargs)
            for name in self.metric_names if name in M.output_metric_fns
        }
        loss_metrics = {
            name: U.discard_kwargs(M.loss_metric_fns[name])(x, y, self.loss, **kwargs)
            for name in self.metric_names if name in M.loss_metric_fns
        }
        return {**output_metrics, **loss_metrics}
Add metrics to the task.

        Metrics are just functions:
        - output metrics are a function of output and target
        - loss metrics are a function of loss (e.g. perplexity)
        
analyze/convnexts4nd/src/tasks/tasks.py