This function displays two images: the original and the adversarial sample
  :param original: the original input
  :param adversarial: the input after perturbations have been applied
  :param figure: if we've already displayed images, use the same plot
  :return: the matplot figure to reuse for future samples

def pair_visual(original, adversarial, figure=None):
  """
  This function displays two images: the original and the adversarial sample
  :param original: the original input
  :param adversarial: the input after perturbations have been applied
  :param figure: if we've already displayed images, use the same plot
  :return: the matplot figure to reuse for future samples
  """
  import matplotlib.pyplot as plt

  # Squeeze the image to remove single-dimensional entries from array shape
  original = np.squeeze(original)
  adversarial = np.squeeze(adversarial)

  # Ensure our inputs are of proper shape
  assert(len(original.shape) == 2 or len(original.shape) == 3)

  # To avoid creating figures per input sample, reuse the sample plot
  if figure is None:
    plt.ion()
    figure = plt.figure()
    figure.canvas.set_window_title('Cleverhans: Pair Visualization')

  # Add the images to the plot
  perturbations = adversarial - original
  for index, image in enumerate((original, perturbations, adversarial)):
    figure.add_subplot(1, 3, index + 1)
    plt.axis('off')

    # If the image is 2D, then we have 1 color channel
    if len(image.shape) == 2:
      plt.imshow(image, cmap='gray')
    else:
      plt.imshow(image)

    # Give the plot some time to update
    plt.pause(0.01)

  # Draw the plot and return
  plt.show()
  return figure