code: def flatten_xy(allow_tuple=True, allow_list=True):
      """
      :param allow_tuple: boolean, if the model accepts a tuple as input. Default: True
      :param allow_list: boolean, if the model accepts a list as input. Default: True
      :return:
      """
  
      def _flatten_xy(data):
          data = check_type_and_convert(data, allow_tuple, allow_list)
          features = data["x"]
  
          has_label = "y" in data
          labels = data["y"] if has_label else None
          length = features[0].shape[0]
  
          for i in range(length):
              fs = [feat[i] for feat in features]
              if has_label:
                  ls = [l[i] for l in labels]
                  yield (fs, ls)
              else:
                  yield (fs,)
  
      return _flatten_xy
  
imports: from bigdl.dllib.utils.file_utils import get_file_list, callZooFunc
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from bigdl.dllib.utils.common import *
  from bigdl.dllib.utils.log4Error import *
  import pyspark.sql.functions
  from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union
  from numpy import float32, int32
label_desc: Use image node_id 5 for calling a global function with example usage: flatten_xy(allow_tuple, allow_list) and returns: _flatten_xy