code: def prepare_data(rows, config):
      # Columns order:
      # item_hist_seq, item, label, category, category_hist_seq, user, item_hist_seq_len
      lengths_x = [row[6] for row in rows]
      seqs_mid = [row[0] for row in rows]
      seqs_cat = [row[4] for row in rows]
  
      n_samples = len(seqs_mid)
      maxlen_x = np.max(lengths_x)
      maxlen_padding = config["exact_maxlen"] != 0
      if maxlen_padding:
          maxlen_x = max(config["history_maxlen"], maxlen_x)
  
      mid_his = np.zeros((n_samples, maxlen_x)).astype("int64")
      cat_his = np.zeros((n_samples, maxlen_x)).astype("int64")
      dtype = config["data_type"]
      if dtype == "fp32" or dtype == "bfloat16" or dtype == "int8":
          data_type = "float32"
      elif dtype == "fp16":
          data_type = "float16"
      else:
          invalidInputError(
              False, "Invalid model data type: %s" % dtype
          )
      mid_mask = np.zeros((n_samples, maxlen_x)).astype(data_type)
      for idx, [s_x, s_y] in enumerate(zip(seqs_mid, seqs_cat)):
          mid_mask[idx, : lengths_x[idx]] = 1.0
          mid_his[idx, : lengths_x[idx]] = s_x
          cat_his[idx, : lengths_x[idx]] = s_y
  
      uids = np.array([row[5] for row in rows])
      mids = np.array([row[1] for row in rows])
      cats = np.array([row[3] for row in rows])
      target = np.array([row[2] for row in rows])
      sl = np.array(lengths_x)
      feed_data = [
          uids,
          mids,
          cats,
          mid_his,
          cat_his,
          mid_mask,
          target,
          sl,
      ]
      return feed_data
  
file_path: BigDL/python/friesian/example/dien/e2e_infer.py
imports: import os
  import time
  import yaml
  from bigdl.friesian.utils import SafePickle
  import random
  import numpy
  from argparse import ArgumentParser
  from bigdl.orca import init_orca_context, stop_orca_context
  from bigdl.friesian.feature import FeatureTable, StringIndex
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_data(rows, config) and returns: feed_data