from tensorflow.python.ops import math_ops



def _run_metrics(predictions, targets, metrics, weights):
  result = {}
  targets = math_ops.cast(targets, predictions.dtype)
  for name, metric in six.iteritems(metrics or {}):
    if "weights" in inspect.getargspec(metric)[0]:
      result[name] = metric(predictions, targets, weights=weights)
