Creates a finalizer function for the given Keras metric.

metric An instance of tf.keras.metrics.Metric or a no-arg callable that constructs a tf.keras.metrics.Metric.

A 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().

TypeError If metric is not a tf.keras.metrics.Metric and not a no-arg callable that returns a tf.keras.metrics.Metric.