code: def evaluate_accuracy(predict, x_test, s1_test, s2_test):
      n_grids = x_test.shape[0]
      state_batch_size = s1_test.shape[1]
  
      total = n_grids * state_batch_size
      correct = 0
      differences = 0
      n_failed_cases = 0
  
      data = tqdm(
          zip(x_test, s1_test, s2_test),
          total=n_grids,
          desc="Evaluating accuracy",
      )
  
      for grid, x_coords, y_coords in data:
          finish = get_target_coords(grid)
  
          for start in zip(x_coords, y_coords):
              len_shortest = shortest_path_length(
                  grid[:, :, 0], start, finish
              )
  
              max_iter = 2 * len_shortest
              trajectory = detect_trajectory(
                  predict,
                  grid,
                  start,
                  max_iter,
                  return_none_if_failed=True,
              )
  
              if trajectory is not None:
                  # Trajectory includes starting position and -1 will make
                  # sure that we do not count it when we measure length of
                  # the trajectory
                  len_predicted = len(trajectory) - 1
              else:
                  len_predicted = max_iter
                  n_failed_cases += 1
  
              differences += len_predicted - len_shortest
  
              if len_predicted == len_shortest:
                  correct += 1
  
      accuracy = correct / total
      loss = differences / total
  
      print("Number of failed cases: {:,}".format(n_failed_cases))
      print("Success rate: {:.2%}".format(accuracy))
      print("Prediction loss: {:.4f}".format(loss))
  
file_path: neupy/examples/reinforcement_learning/vin/evaluation.py
imports: from __future__ import division
  import numpy
  from tqdm import tqdm
  from neupy.utils import asfloat
label_desc: Use image node_id 6 for calling a global function with example usage: evaluate_accuracy(predict, x_test, s1_test, s2_test) without return types