class_docstr: A object which creates evaluation metrics for Subnetworks.
class_docstr_tok: ["A","object","which","creates","evaluation","metrics","for","Subnetworks","."]
docstr: Creates evaluation metrics from the given arguments.
  
  Args:
    features: Input `dict` of `Tensor` objects.
    labels: Labels `Tensor` or a dictionary of string label name to `Tensor`
      (for multi-head).
    estimator_spec: The `EstimatorSpec` created by a `Head` instance.
    metric_fn: A function which should obey the following signature:
    - Args: can only have following three arguments in any order:
      * predictions: Predictions `Tensor` or dict of `Tensor` created by given
        `Head`.
      * features: Input `dict` of `Tensor` objects created by `input_fn` which
        is given to `estimator.evaluate` as an argument.
      * labels:  Labels `Tensor` or dict of `Tensor` (for multi-head) created
        by `input_fn` which is given to `estimator.evaluate` as an argument.
    - Returns: Dict of metric results keyed by name. Final metrics are a union
      of this and `estimator`s existing metrics. If there is a name conflict
      between this and `estimator`s existing metrics, this will override the
      existing one. The values of the dict are the results of calling a metric
      function, namely a `(metric_tensor, update_op)` tuple.
docstr_tok: ["Creates","evaluation","metrics","from","the","given","arguments",".","Args",":","features",":","Input","`","dict","`","of","`","Tensor","`","objects",".","labels",":","Labels","`","Tensor","`","or","a","dictionary","of","string","label","name","to","`","Tensor","`","(","for","multi-head",")",".","estimator_spec",":","The","`","EstimatorSpec","`","created","by","a","`","Head","`","instance",".","metric_fn",":","A","function","which","should","obey","the","following","signature",":","-","Args",":","can","only","have","following","three","arguments","in","any","order",":","*","predictions",":","Predictions","`","Tensor","`","or","dict","of","`","Tensor","`","created","by","given","`","Head","`",".","*","features",":","Input","`","dict","`","of","`","Tensor","`","objects","created","by","`","input_fn","`","which","is","given","to","`","estimator.evaluate","`","as","an","argument",".","*","labels",":","Labels","`","Tensor","`","or","dict","of","`","Tensor","`","(","for","multi-head",")","created","by","`","input_fn","`","which","is","given","to","`","estimator.evaluate","`","as","an","argument",".","-","Returns",":","Dict","of","metric","results","keyed","by","name",".","Final","metrics","are","a","union","of","this","and","`","estimator","`","s","existing","metrics",".","If","there","is","a","name","conflict","between","this","and","`","estimator","`","s","existing","metrics",",","this","will","override","the","existing","one",".","The","values","of","the","dict","are","the","results","of","calling","a","metric","function",",","namely","a","`","(","metric_tensor",",","update_op",")","`","tuple","."]
code: def create_eval_metrics(
      self, features, labels, estimator_spec, metric_fn
  ):
      """Creates evaluation metrics from the given arguments.
  
      Args:
        features: Input `dict` of `Tensor` objects.
        labels: Labels `Tensor` or a dictionary of string label name to `Tensor`
          (for multi-head).
        estimator_spec: The `EstimatorSpec` created by a `Head` instance.
        metric_fn: A function which should obey the following signature:
        - Args: can only have following three arguments in any order:
          * predictions: Predictions `Tensor` or dict of `Tensor` created by given
            `Head`.
          * features: Input `dict` of `Tensor` objects created by `input_fn` which
            is given to `estimator.evaluate` as an argument.
          * labels:  Labels `Tensor` or dict of `Tensor` (for multi-head) created
            by `input_fn` which is given to `estimator.evaluate` as an argument.
        - Returns: Dict of metric results keyed by name. Final metrics are a union
          of this and `estimator`s existing metrics. If there is a name conflict
          between this and `estimator`s existing metrics, this will override the
          existing one. The values of the dict are the results of calling a metric
          function, namely a `(metric_tensor, update_op)` tuple.
      """
  
      # If estimator_spec is not a TPUEstimatorSpec we create dummy metric_fn
      # and args.
      if isinstance(estimator_spec, tf.estimator.EstimatorSpec):
          spec_fn, spec_args = (
              lambda: estimator_spec.eval_metric_ops,
              [],
          )
      else:
          spec_fn, spec_args = estimator_spec.eval_metrics
      self._eval_metrics_store.add_eval_metrics(
          self._templatize_metric_fn(spec_fn), spec_args
      )
  
      loss_fn = lambda loss: {"loss": tf_compat.v1.metrics.mean(loss)}
      loss_fn_args = [tf.reshape(estimator_spec.loss, [1])]
  
      if not self._use_tpu:
          loss_ops = _call_eval_metrics((loss_fn, loss_fn_args))
          loss_fn, loss_fn_args = lambda: loss_ops, []
      self._eval_metrics_store.add_eval_metrics(
          self._templatize_metric_fn(loss_fn), loss_fn_args
      )
  
      # NOTE: the user supplied metrics_fn must be added last. This is because we
      # want user metrics to override AdaNet's metrics.
      if metric_fn:
          metric_fn_args = {}
          # Calling low level getargs for py_2_and_3 compatibility.
          argspec = inspect.getargs(metric_fn.__code__).args
          if "features" in argspec:
              metric_fn_args["features"] = features
          if "labels" in argspec:
              metric_fn_args["labels"] = labels
          if "predictions" in argspec:
              metric_fn_args["predictions"] = estimator_spec.predictions
  
          if not self._use_tpu:
              metric_fn_ops = _call_eval_metrics(
                  (metric_fn, metric_fn_args)
              )
              metric_fn, metric_fn_args = lambda: metric_fn_ops, []
          self._eval_metrics_store.add_eval_metrics(
              self._templatize_metric_fn(metric_fn), metric_fn_args
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import inspect
  from absl import logging
  from adanet import tf_compat
  import six
  import tensorflow.compat.v2
label_desc: Use image node_id 2 for calling the _SubnetworkMetrics obj's underlying member method code with example usage: obj.create_eval_metrics(features, labels, estimator_spec, metric_fn) without return types