code: def mnist_blackbox(
      train_start=0,
      train_end=60000,
      test_start=0,
      test_end=10000,
      nb_classes=NB_CLASSES,
      batch_size=BATCH_SIZE,
      learning_rate=LEARNING_RATE,
      nb_epochs=NB_EPOCHS,
      holdout=HOLDOUT,
      data_aug=DATA_AUG,
      nb_epochs_s=NB_EPOCHS_S,
      lmbda=LMBDA,
      aug_batch_size=AUG_BATCH_SIZE,
  ):
      """
      MNIST tutorial for the black-box attack from arxiv.org/abs/1602.02697
      :param train_start: index of first training set example
      :param train_end: index of last training set example
      :param test_start: index of first test set example
      :param test_end: index of last test set example
      :return: a dictionary with:
               * black-box model accuracy on test set
               * substitute model accuracy on test set
               * black-box model accuracy on adversarial examples transferred
                 from the substitute model
      """
  
      # Set logging level to see debug information
      set_log_level(logging.DEBUG)
  
      # Dictionary used to keep track and return key accuracies
      accuracies = {}
  
      # Perform tutorial setup
      assert setup_tutorial()
  
      # Create TF session
      sess = tf.Session()
  
      # Get MNIST data
      mnist = MNIST(
          train_start=train_start,
          train_end=train_end,
          test_start=test_start,
          test_end=test_end,
      )
      x_train, y_train = mnist.get_set("train")
      x_test, y_test = mnist.get_set("test")
  
      # Initialize substitute training set reserved for adversary
      x_sub = x_test[:holdout]
      y_sub = np.argmax(y_test[:holdout], axis=1)
  
      # Redefine test set as remaining samples unavailable to adversaries
      x_test = x_test[holdout:]
      y_test = y_test[holdout:]
  
      # Obtain Image parameters
      img_rows, img_cols, nchannels = x_train.shape[1:4]
      nb_classes = y_train.shape[1]
  
      # Define input TF placeholder
      x = tf.placeholder(
          tf.float32, shape=(None, img_rows, img_cols, nchannels)
      )
      y = tf.placeholder(tf.float32, shape=(None, nb_classes))
  
      # Seed random number generator so tutorial is reproducible
      rng = np.random.RandomState([2017, 8, 30])
  
      # Simulate the black-box model locally
      # You could replace this by a remote labeling API for instance
      print("Preparing the black-box model.")
      prep_bbox_out = prep_bbox(
          sess,
          x,
          y,
          x_train,
          y_train,
          x_test,
          y_test,
          nb_epochs,
          batch_size,
          learning_rate,
          rng,
          nb_classes,
          img_rows,
          img_cols,
          nchannels,
      )
      model, bbox_preds, accuracies["bbox"] = prep_bbox_out
  
      # Train substitute using method from https://arxiv.org/abs/1602.02697
      print("Training the substitute model.")
      train_sub_out = train_sub(
          sess,
          x,
          y,
          bbox_preds,
          x_sub,
          y_sub,
          nb_classes,
          nb_epochs_s,
          batch_size,
          learning_rate,
          data_aug,
          lmbda,
          aug_batch_size,
          rng,
          img_rows,
          img_cols,
          nchannels,
      )
      model_sub, preds_sub = train_sub_out
  
      # Evaluate the substitute model on clean test examples
      eval_params = {"batch_size": batch_size}
      acc = model_eval(
          sess, x, y, preds_sub, x_test, y_test, args=eval_params
      )
      accuracies["sub"] = acc
  
      # Initialize the Fast Gradient Sign Method (FGSM) attack object.
      fgsm_par = {
          "eps": 0.3,
          "ord": np.inf,
          "clip_min": 0.0,
          "clip_max": 1.0,
      }
      fgsm = FastGradientMethod(model_sub, sess=sess)
  
      # Craft adversarial examples using the substitute
      eval_params = {"batch_size": batch_size}
      x_adv_sub = fgsm.generate(x, **fgsm_par)
  
      # Evaluate the accuracy of the "black-box" model on adversarial examples
      accuracy = model_eval(
          sess,
          x,
          y,
          model.get_logits(x_adv_sub),
          x_test,
          y_test,
          args=eval_params,
      )
      print(
          "Test accuracy of oracle on adversarial examples generated "
          "using the substitute: " + str(accuracy)
      )
      accuracies["bbox_on_sub_adv_ex"] = accuracy
  
      return accuracies
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import functools
  import logging
  import numpy
  from six.moves import xrange
  import tensorflow
  from cleverhans.attacks import FastGradientMethod
  from cleverhans.utils_tf import jacobian_graph, jacobian_augmentation
  from cleverhans.compat import flags
  from cleverhans.dataset import MNIST
  from cleverhans.initializers import HeReLuNormalInitializer
  from cleverhans.loss import CrossEntropy
  from cleverhans.model import Model
  from cleverhans.train import train
  from cleverhans.utils import set_log_level
  from cleverhans.utils import TemporaryLogLevel
  from cleverhans.utils import to_categorical
  from cleverhans.utils_tf import model_eval, batch_eval
  from cleverhans.model_zoo.basic_cnn import ModelBasicCNN
label_desc: Use image node_id 4 for calling a global function with example usage: mnist_blackbox(train_start, train_end, test_start, test_end, nb_classes, batch_size, learning_rate, nb_epochs, holdout, data_aug, nb_epochs_s, lmbda, aug_batch_size) and returns: accuracies