code: def process_batch(
      processor,
      files,
      output_dir=None,
      output_suffix=None,
      strip_ext=True,
      num_workers=mp.cpu_count(),
      shuffle=False,
      **kwargs,
  ):
      """
      Process a list of files with the given Processor in batch mode.
  
      Parameters
      ----------
      processor : :class:`Processor` instance
          Processor to be processed.
      files : list
          Input file(s) (handles).
      output_dir : str, optional
          Output directory.
      output_suffix : str, optional
          Output suffix (e.g. '.txt' including the dot).
      strip_ext : bool, optional
          Strip off the extension from the input files.
      num_workers : int, optional
          Number of parallel working threads.
      shuffle : bool, optional
          Shuffle the `files` before distributing them to the working threads
  
      Notes
      -----
      Either `output_dir` and/or `output_suffix` must be set. If `strip_ext` is
      True, the extension of the input file names is stripped off before the
      `output_suffix` is appended to the input file names.
  
      Use `shuffle` if you experience out of memory errors (can occur for certain
      methods with high memory consumptions if consecutive files are rather
      long).
  
      """
      # pylint: disable=unused-argument
      # either output_dir or output_suffix must be given
      if output_dir is None and output_suffix is None:
          raise ValueError(
              "either output directory or suffix must be given"
          )
      # make sure the directory exists
      if output_dir is not None:
          try:
              # create output directory
              os.mkdir(output_dir)
          except OSError:
              # directory exists already
              pass
  
      # create task queue
      tasks = mp.JoinableQueue()
      # create working threads
      processes = [_ParallelProcess(tasks) for _ in range(num_workers)]
      for p in processes:
          p.daemon = True
          p.start()
  
      # shuffle files?
      if shuffle:
          from random import shuffle
  
          shuffle(files)
  
      # process all the files
      for input_file in files:
          # set the output file name
          if output_dir is not None:
              output_file = "%s/%s" % (
                  output_dir,
                  os.path.basename(input_file),
              )
          else:
              output_file = input_file
          # strip off the extension
          if strip_ext:
              output_file = os.path.splitext(output_file)[0]
          # append the suffix if needed
          if output_suffix is not None:
              output_file += output_suffix
          # put processing tasks in the queue
          tasks.put((processor, input_file, output_file, kwargs))
      # wait for all processing tasks to finish
      tasks.join()
  
imports: from __future__ import absolute_import, division, print_function
  import argparse
  import itertools
  import multiprocessing
  import os
  import sys
  from collections.abc import MutableSequence
  import numpy
  from .utils import integer_types
label_desc: Use image node_id 3 for calling a global function with example usage: process_batch(processor, files, output_dir, output_suffix, strip_ext, num_workers, shuffle) without return types