keras/src/layers/layer.py/Layer/metrics_variables
class Layer:    def metrics_variables(self):
        """List of all metric variables."""
        vars = []
        for metric in self.metrics:
            vars.extend(metric.variables)
        return vars