code: def apply_batches(
      function,
      inputs,
      batch_size,
      show_progressbar=False,
      show_output=False,
      average_outputs=False,
  ):
      """
      Splits inputs into mini-batches and passes them to the function.
      Function returns list of outputs or average loss in case
      if ``average_outputs=True``.
  
      Parameters
      ----------
      function : func
          Function that accepts one or more positional inputs.
          Each of them should be an array-like variable that
          have exactly the same number of rows.
  
      inputs : tuple, list
          The arguments that will be provided to the function specified
          in the ``function`` argument.
  
      batch_size : int
          Mini-batch size. Defines maximum number of samples that will be
          used as an input to the ``function``.
  
      show_progressbar : bool
          When ``True`` than progress bar will be shown in the terminal.
          Defaults to ``False``.
  
      show_output : bool
          Assumes that outputs from the function errors. The ``True`` value
          will show information in the progressbar. Error will be related to
          the last epoch. Defaults to ``False``.
  
      average_outputs : bool
          Output from each batch will be combined into single average. This
          option assumes that loss per batch was calculated from.
          Defaults to ``False``.
  
      Returns
      -------
      list
          List of function outputs.
      """
      n_samples = count_samples(inputs)
      batch_size = n_samples if batch_size is None else batch_size
  
      n_batches = count_minibatches(inputs, batch_size)
      bar = progressbar.NullBar()
  
      if show_progressbar and n_batches >= 2:
          bar = make_progressbar(n_batches, show_output)
          bar.update(0)  # triggers empty progressbar
  
      outputs = []
      iterator = minibatches(inputs, batch_size, shuffle=False)
  
      for i, sliced_inputs in enumerate(iterator):
          output = function(*as_tuple(sliced_inputs))
          outputs.append(output)
  
          kwargs = dict(loss=output) if show_output else {}
          bar.update(i, **kwargs)
  
      # Clean progressbar from the screen
      bar.fd.write("\r" + " " * bar.term_width + "\r")
  
      if average_outputs:
          # When loss calculated per batch separately it might be
          # necessary to combine error into single value
          return average_batch_errors(outputs, n_samples, batch_size)
  
      return outputs
  
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 7 for calling a global function with example usage: apply_batches(function, inputs, batch_size, show_progressbar, show_output, average_outputs) and returns: outputs, average_batch_errors