code: def margin_logit_loss(
      model_logits, label, nb_classes=10, num_classes=None
  ):
      """Computes difference between logit for `label` and next highest logit.
  
      The loss is high when `label` is unlikely (targeted by default).
      This follows the same interface as `loss_fn` for TensorOptimizer and
      projected_optimization, i.e. it returns a batch of loss values.
      """
      if num_classes is not None:
          warnings.warn(
              "`num_classes` is depreciated. Switch to `nb_classes`."
              " `num_classes` may be removed on or after 2019-04-23."
          )
          nb_classes = num_classes
          del num_classes
      if "int" in str(label.dtype):
          logit_mask = tf.one_hot(label, depth=nb_classes, axis=-1)
      else:
          logit_mask = label
      if "int" in str(logit_mask.dtype):
          logit_mask = tf.to_float(logit_mask)
      try:
          label_logits = reduce_sum(logit_mask * model_logits, axis=-1)
      except TypeError:
          raise TypeError(
              "Could not take row-wise dot product between "
              "logit mask, of dtype "
              + str(logit_mask.dtype)
              + " and model_logits, of dtype "
              + str(model_logits.dtype)
          )
      logits_with_target_label_neg_inf = (
          model_logits - logit_mask * 99999
      )
      highest_nonlabel_logits = reduce_max(
          logits_with_target_label_neg_inf, axis=-1
      )
      loss = highest_nonlabel_logits - label_logits
      return loss
  
imports: import warnings
  import numpy
  from six.moves import xrange
  import tensorflow
  import tensorflow_addons
  from cleverhans.attacks.attack import Attack
  from cleverhans.compat import reduce_mean, reduce_sum, reduce_max
  from cleverhans.model import Model
  from cleverhans import utils_tf
label_desc: Use image node_id 2 for calling a global function with example usage: margin_logit_loss(model_logits, label, nb_classes, num_classes) and returns: loss