code: def model_loss(y, model, mean=True):
      """
      Define loss of TF graph
      :param y: correct labels
      :param model: output of the model
      :param mean: boolean indicating whether should return mean of loss
                   or vector of losses for each input of the batch
      :return: return mean of loss if True, otherwise return vector with per
               sample loss
      """
      warnings.warn(
          "This function is deprecated and will be removed on or after"
          " 2019-04-05. Switch to cleverhans.train.train."
      )
      op = model.op
      if op.type == "Softmax":
          (logits,) = op.inputs
      else:
          logits = model
  
      out = softmax_cross_entropy_with_logits(logits=logits, labels=y)
  
      if mean:
          out = reduce_mean(out)
      return out
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  import math
  import os
  import time
  import warnings
  import numpy
  import six
  from six.moves import xrange
  import tensorflow
  from cleverhans.compat import device_lib
  from cleverhans.compat import reduce_sum, reduce_mean
  from cleverhans.compat import reduce_max
  from cleverhans.compat import softmax_cross_entropy_with_logits
  from cleverhans.utils import batch_indices, _ArgsWrapper, create_logger
label_desc: Use image node_id 1 for calling a global function with example usage: model_loss(y, model, mean) and returns: out