code: def arrays2others(
      iter,
      feature_cols,
      label_cols,
      shard_size=None,
      generate_func=None,
  ):
      def init_result_lists(first_row, cols):
          if shard_size:
              # pre allocate numpy array when shard_size is provided
              if isinstance(first_row, np.ndarray):
                  return [
                      np.empty(
                          (shard_size,) + first_row.shape,
                          first_row.dtype,
                      )
                  ]
              if isinstance(first_row, dict):
                  res = dict()
                  for k, _ in first_row.items():
                      res[k] = np.empty(
                          (shard_size,) + first_row[k].shape,
                          first_row[k].dtype,
                      )
                  return res
              else:
                  return [
                      np.empty((shard_size,) + r.shape, r.dtype)
                      for r in first_row
                  ]
          else:
              return [[] for r in cols]
  
      def add_row(data, results, current):
          if not isinstance(data, (list, tuple, dict)):
              arrays = [data]
          else:
              arrays = data
  
          iter = (
              arrays.items()
              if isinstance(arrays, dict)
              else enumerate(arrays)
          )
          for i, arr in iter:
              if shard_size:
                  current = current % shard_size
                  results[i][current] = arr
              else:
                  results[i].append(arr)
  
      feature_lists = None
      label_lists = None
      counter = 0
  
      for row in iter:
          if feature_lists is None:
              feature_lists = init_result_lists(row[0], feature_cols)
          add_row(row[0], feature_lists, counter)
          if label_cols is not None:
              if label_lists is None:
                  label_lists = init_result_lists(row[1], label_cols)
              add_row(row[1], label_lists, counter)
          counter += 1
  
          if shard_size and counter % shard_size == 0:
              # output put a shard when current shard is full
              yield generate_func(
                  feature_lists, label_lists, feature_cols, label_cols
              )
              feature_lists = None
              label_lists = None
  
      if feature_lists is not None:
          if shard_size:
              # remove empty part of the ndarray in the last shard
              rest_size = counter % shard_size
              if isinstance(feature_lists, dict):
                  feature_lists = {
                      k: v[0:rest_size]
                      for k, v in feature_lists.items()
                  }
              else:
                  feature_lists = [
                      feature[0:rest_size] for feature in feature_lists
                  ]
              if label_cols is not None:
                  if isinstance(label_lists, dict):
                      label_lists = {
                          k: v[0:rest_size]
                          for k, v in label_lists.items()
                      }
                  else:
                      label_lists = [
                          label[0:rest_size] for label in label_lists
                      ]
          # output last shard
          yield generate_func(
              feature_lists, label_lists, feature_cols, label_cols
          )
  
imports: from contextlib import closing
  import socket
  import sys
  import tempfile
  import shutil
  from bigdl.dllib.utils import log4Error
  from bigdl.dllib.utils.common import callBigDlFunc
  from bigdl.dllib.utils.file_utils import get_file_list, is_local_path
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.utils import get_size
  from bigdl.orca.data.file import put_local_dir_tree_to_remote, put_local_file_to_remote, get_remote_file_to_local, get_remote_dir_to_local
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from functools import partial
  import numpy
  from bigdl.orca.common import SafePickle
  import os
  import subprocess
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 14 for calling a global function with example usage: arrays2others(iter, feature_cols, label_cols, shard_size, generate_func) and returns: unknown, list, res, unknown