code: def convert_predict_xshards_to_dataframe(df, pred_shards):
      def flatten(data):
          data = data["prediction"]
          is_list = isinstance(data, list)
          is_tuple = isinstance(data, tuple)
          if is_list or is_tuple:
              length = data[0].shape[0]
              ls_data = data
          else:
              length = data.shape[0]
              ls_data = [data]
  
          for i in range(length):
              row = [elem[i] for elem in ls_data]
              if is_list:
                  yield row
              elif is_tuple:
                  yield tuple(row)
              else:
                  yield row[0]
  
      pred_rdd = pred_shards.rdd.flatMap(flatten)
      result = convert_predict_rdd_to_dataframe(df, pred_rdd)
      return result
  
file_path: analytics-zoo/pyzoo/zoo/orca/learn/utils.py
imports: from zoo.common.utils import get_file_list
  from zoo.orca.data import SparkXShards
  from zoo.orca.data.utils import get_size
  from zoo.util.utils import convert_row_to_numpy
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: convert_predict_xshards_to_dataframe(df, pred_shards) and returns: result