code: def run_function_in_batches(
      func,
      input_data_list,
      learning_phase=None,
      batch_size=10,
      progress_update=1000,
      multimodal_output=False,
  ):
      # func has a return value such that the first index is the
      # batch. This function will run func in batches on the inputData
      # and will extend the result into one big list.
      # if multimodal_output=True, func has a return value such that first
      # index is the mode and second index is the batch
      assert isinstance(
          input_data_list, list
      ), "input_data_list must be a list"
      # input_datas is an array of the different input_data modes.
      to_return = []
      i = 0
      while i < len(input_data_list[0]):
          if progress_update is not None:
              if i % progress_update == 0:
                  print("Done", i)
          func_output = func(
              (
                  [x[i : i + batch_size] for x in input_data_list]
                  + ([] if learning_phase is None else [learning_phase])
              )
          )
          if multimodal_output:
              assert isinstance(
                  func_output, list
              ), "multimodal_output=True yet function return value is not a list"
              if len(to_return) == 0:
                  to_return = [[] for x in func_output]
              for to_extend, batch_results in zip(
                  to_return, func_output
              ):
                  to_extend.extend(batch_results)
          else:
              to_return.extend(func_output)
          i += batch_size
      return to_return
  
imports: from __future__ import division
  from __future__ import print_function
  from __future__ import absolute_import
  import sys
  import os
  import os.path
  import numpy
  from collections import namedtuple
  from collections import OrderedDict
  import json
  import deeplift
  import tensorflow
label_desc: Use image node_id 9 for calling a global function with example usage: run_function_in_batches(func, input_data_list, learning_phase, batch_size, progress_update, multimodal_output) and returns: to_return