code: def average_batch_errors(errors, n_samples, batch_size):
      """
      Computes average error per sample. Function assumes that error from
      each batch was just an average loss of each individual sample.
  
      Parameters
      ----------
      errors : list
          List of average errors calculated per batch.
  
      n_samples : int
          Number of input samples..
  
      batch_size : int
          Mini-batch size.
  
      Returns
      -------
      float
          Average error per sample.
      """
      errors = np.atleast_1d(errors)
      batches = np.ones_like(errors) * batch_size
  
      if len(errors) == 1:
          return errors.item(0)
  
      if n_samples % batch_size != 0:
          # Last batch can be smaller than the usual one, because we
          # won't have enough samples for the full one.
          batches[-1] = n_samples % batch_size
  
      return np.dot(errors, batches) / n_samples
  
file_path: neupy/neupy/utils/iters.py
imports: from __future__ import division
  import math
  import numpy
  import progressbar
  from neupy.utils.misc import as_tuple
label_desc: Use image node_id 5 for calling a global function with example usage: average_batch_errors(errors, n_samples, batch_size) and returns: unknown, errors