Compute the accuracy of a TF model on some data
  :param sess: TF session to use when training the graph
  :param model: cleverhans.model.Model instance
  :param x: numpy array containing input examples (e.g. MNIST().x_test )
  :param y: numpy array containing example labels (e.g. MNIST().y_test )
  :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: a float with the accuracy value

def accuracy(sess, model, x, y, batch_size=None, devices=None, feed=None,
             attack=None, attack_params=None):
  """
  Compute the accuracy of a TF model on some data
  :param sess: TF session to use when training the graph
  :param model: cleverhans.model.Model instance
  :param x: numpy array containing input examples (e.g. MNIST().x_test )
  :param y: numpy array containing example labels (e.g. MNIST().y_test )
  :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: a float with the accuracy value
  """

  _check_x(x)
  _check_y(y)
  if x.shape[0] != y.shape[0]:
    raise ValueError("Number of input examples and labels do not match.")

  factory = _CorrectFactory(model, attack, attack_params)

  correct, = batch_eval_multi_worker(sess, factory, [x, y],
                                     batch_size=batch_size, devices=devices,
                                     feed=feed)

  return correct.mean()