# tff.learning.metrics.create_keras_metric_finalizer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

Creates a finalizer function for the given Keras metric.

    tff.learning.metrics.create_keras_metric_finalizer(
        metric: Union[tf.keras.metrics.Metric, Callable[[], tf.keras.metrics.Metric]]
    ) -> KerasMetricFinalizer

<br />

<br />

<br />

| ## Args ||
|---|---|
| `metric` | An instance of [`tf.keras.metrics.Metric`](https://www.tensorflow.org/api_docs/python/tf/keras/Metric) or a no-arg callable that constructs a [`tf.keras.metrics.Metric`](https://www.tensorflow.org/api_docs/python/tf/keras/Metric). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A [`tf.function`](https://www.tensorflow.org/api_docs/python/tf/function) decorated callable that takes in the unfinalized metric values (i.e., tensor values of the variables in `keras_metric.variables`), and returns the value of `keras_metric.result()`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `metric` is not a [`tf.keras.metrics.Metric`](https://www.tensorflow.org/api_docs/python/tf/keras/Metric) and not a no-arg callable that returns a [`tf.keras.metrics.Metric`](https://www.tensorflow.org/api_docs/python/tf/keras/Metric). |

<br />