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`.
code: def __call__(self, *args, **kwargs):
      if isinstance(self.loss_fn, tf.keras.losses.Loss):
          loss_value = self.loss_fn(*args, **kwargs)
      else:
          loss_value = super(_LossWrapper, self).__call__(
              *args, **kwargs
          )
      if self.batch_size_reduction:
          size = tf.cast(tf.size(loss_value), dtype=loss_value.dtype)
          loss_value = tf.math.divide_no_nan(
              tf.math.reduce_sum(loss_value), size
          )
      return loss_value
  
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 3 for calling the _LossWrapper obj's underlying member method code with example usage: obj.__call__() and returns: loss_value