code: def class_and_confidence(
      sess,
      model,
      x,
      y=None,
      batch_size=None,
      devices=None,
      feed=None,
      attack=None,
      attack_params=None,
  ):
      """
      Return the model's classification of the input data, and the confidence
      (probability) assigned to each example.
      :param sess: tf.Session
      :param model: cleverhans.model.Model
      :param x: numpy array containing input examples (e.g. MNIST().x_test )
      :param y: numpy array containing true labels
        (Needed only if using an attack that avoids these labels)
      :param batch_size: Number of examples to use in a single evaluation batch.
          If not specified, this function will use a reasonable guess and
          may run out of memory.
          When choosing the batch size, keep in mind that the batch will
          be divided up evenly among available devices. If you can fit 128
          examples in memory on one GPU and you have 8 GPUs, you probably
          want to use a batch size of 1024 (unless a different batch size
          runs faster with the ops you are using, etc.)
      :param devices: An optional list of string device names to use.
        If not specified, this function will use all visible GPUs.
      :param feed: An optional dictionary that is appended to the feeding
               dictionary before the session runs. Can be used to feed
               the learning phase of a Keras model for instance.
      :param attack: cleverhans.attack.Attack
        Optional. If no attack specified, evaluates the model on clean data.
        If attack is specified, evaluates the model on adversarial examples
        created by the attack.
      :param attack_params: dictionary
        If attack is specified, this dictionary is passed to attack.generate
        as keyword arguments.
      :return:
        an ndarray of ints indicating the class assigned to each example
        an ndarray of probabilities assigned to the prediction for each example
      """
  
      _check_x(x)
      inputs = [x]
      if attack is not None:
          inputs.append(y)
          _check_y(y)
          if x.shape[0] != y.shape[0]:
              raise ValueError(
                  "Number of input examples and labels do not match."
              )
  
      factory = _ClassAndProbFactory(model, attack, attack_params)
  
      out = batch_eval_multi_worker(
          sess,
          factory,
          inputs,
          batch_size=batch_size,
          devices=devices,
          feed=feed,
      )
  
      classes, confidence = out
  
      assert classes.shape == (x.shape[0],)
      assert confidence.shape == (x.shape[0],)
      min_confidence = confidence.min()
      if min_confidence < 0.0:
          raise ValueError(
              "Model does not return valid probabilities: "
              + str(min_confidence)
          )
      max_confidence = confidence.max()
      if max_confidence > 1.0:
          raise ValueError(
              "Model does not return valid probablities: "
              + str(max_confidence)
          )
      assert confidence.min() >= 0.0, confidence.min()
  
      return out
  
imports: from distutils.version import LooseVersion
  import warnings
  import numpy
  from six.moves import range
  import tensorflow
  import cleverhans
  from cleverhans import canary
  from cleverhans.utils import create_logger
  from cleverhans.utils_tf import infer_devices
label_desc: Use image node_id 2 for calling a global function with example usage: class_and_confidence(sess, model, x, y, batch_size, devices, feed, attack, attack_params) and returns: out