code: def _update_result(
      args,
      index,
      result,
      values,
      output_index,
      type_end_names,
      output_image,
  ):
      outputs = []
      for o, type_and_name in zip(values, type_end_names):
          for data_index, d in enumerate(o):
              if len(result.dims) <= output_index:
                  result = _set_initial_values(result, type_and_name, d)
              if len(outputs) <= data_index:
                  outputs.append([])
              name = result.names[output_index]
              vtype = result.types[output_index]
              dim = result.dims[output_index]
  
              # Output data
              if vtype == "col" or not output_image:
                  # Vector type output
                  if "numpy.ndarray" != type(d):
                      tmp = np.array([d])
                      outputs[data_index].extend(
                          np.ndarray.flatten(tmp)
                      )
                  else:
                      outputs[data_index].extend(np.ndarray.flatten(d))
              else:
                  for dim_index in range(dim):
                      file_index = index + data_index
                      file_name = (
                          "{}_{:04d}".format(
                              output_index, file_index // 1000
                          )
                          + os.path.sep
                      )
                      if dim > 1:
                          file_name += str(dim_index) + "_"
                      file_name += "{}{}".format(file_index, vtype)
                      full_path = os.path.join(
                          args.outdir, args.result_outdir, file_name
                      )
                      directory = os.path.dirname(full_path)
                      try:
                          os.makedirs(directory)
                      except OSError:
                          pass  # python2 does not support exists_ok arg
                      if vtype in [
                          ".bmp",
                          ".jpeg",
                          ".jpg",
                          ".png",
                          ".gif",
                          ".tif",
                      ]:
                          x = np.array(d, dtype=np.float32) * 255.0
                          while len(x.shape) == 4:
                              x = x[0]
                          if x.shape[0] > 3 or x.shape[0] == 2:
                              x = x[dim_index]
                          elif x.shape[0] == 3:
                              x = x.transpose(1, 2, 0)
                          else:
                              x = x.reshape(x.shape[1], x.shape[2])
                          x = x.clip(0, 255).astype(np.uint8)
                          imsave(full_path, x)
                      else:
                          # CSV type
                          with open(full_path, "w") as f:
                              writer = csv.writer(
                                  f, lineterminator="\n"
                              )
                              x = np.array(d)
                              writer.writerows(x)
                      outputs[data_index].append(
                          os.path.join(
                              ".", args.result_outdir, file_name
                          )
                      )
          output_index += 1
  
      return result, outputs
  
imports: import csv
  import os
  import nnabla.utils.callback
  import nnabla.utils.load
  import numpy
  from nnabla.logger import logger
  from nnabla.utils.cli.utility import let_data_to_variable, is_float, compute_full_path
  from nnabla.utils.data_iterator import data_iterator_cache
  from nnabla.utils.data_iterator import data_iterator_csv_dataset
  from nnabla.utils.data_source_loader import FileReader
  from nnabla.utils.image_utils import imsave
  from nnabla.utils.progress import configure_progress, progress
  from six.moves import map
label_desc: Use image node_id 2 for calling a global function with example usage: _update_result(args, index, result, values, output_index, type_end_names, output_image) and returns: result,  outputs