parameters: (metric)
return_statement: return metric
docstring: Returns a clone of the metric if stateful, otherwise returns it as is.
docstring_summary: Returns a clone of the metric if stateful, otherwise returns it as is.
docstring_tokens: Returns a clone of the metric if stateful otherwise returns it as is .
function: def clone_metric(metric):
    """Returns a clone of the metric if stateful, otherwise returns it as is."""
    if isinstance(metric, Metric):
      with ops.init_scope():
        return metric.__class__.from_config(metric.get_config())
    return metric
function_tokens: def clone_metric ( metric ) : if isinstance ( metric , Metric ) : with ops . init_scope ( ) : return metric . __class__ . from_config ( metric . get_config ( ) ) return metric