class_docstr: Wrapper converting a loss function into a `Loss` object.
  
  This is to reuse logic of sample-weighted loss computation in `Loss` base
  class.
  
  Attributes:
    loss_fn: Underlying loss function.
    weight: Weight of this loss term in total loss. Should be applied outside
      of this class, e.g. `total_loss += loss.weight * loss(y_true, y_pred)`.
    batch_size_reduction: Whether to perform `SUM_OVER_BATCH_SIZE` reduction.
      This field is set in lieu of having `reduction=SUM_OVER_BATCH_SIZE`,
      because the latter is not supported when using with
      `tf.distribute.Strategy`.
docstr: Resolves potentially ambiguous metric name based on the loss function.
docstr_tok: ["Resolves","potentially","ambiguous","metric","name","based","on","the","loss","function","."]
code: def resolve_metric(self, metric):
      """Resolves potentially ambiguous metric name based on the loss function."""
      # This method is intended for the scenario that a Keras model is compiled
      # with a metric which meaning depends on the learning task. For example,
      # `'accuracy'` may refer to `tf.keras.metrics.binary_accuracy` for binary
      # classification tasks, to `tf.keras.metrics.categorical_accuracy` for
      # multi-class classification tasks with one-hot labels, or to
      # `tf.keras.metrics.sparse_categorical_accuracy` for mult-class
      # classification tasks with index labels. In such scenario the loss
      # function can help deduce the desired metric function since they share the
      # same input `(y_true, y_pred)`.
      # The list of such metrics is defined in `get_metric_function()` in
      # https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/engine/training_utils.py
      if metric not in ("accuracy", "acc", "crossentropy", "ce"):
          return metric
      if self._is_binary_classification_loss():
          prefix = "binary_"
      elif self._is_sparse_categorical_loss():
          prefix = "sparse_categorical_"
      else:
          prefix = "categorical_"
      suffix = (
          "accuracy"
          if metric in ("accuracy", "acc")
          else "crossentropy"
      )
      return prefix + suffix
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import functools
  import types
  import attr
  import neural_structured_learning.configs
  from neural_structured_learning.lib import adversarial_neighbor
  import six
  import tensorflow
label_desc: Use image node_id 6 for calling the _LossWrapper obj's underlying member method code with example usage: obj.resolve_metric(metric) and returns: unknown, metric