code: def transform_to_pandas_dataframe(block_table, data_manager):
      fields_loc = data_manager.get_fields_loc()
  
      def _flatten(blocks):
          flatten_ret = []
          lines = len(blocks[0])
  
          for lid in range(lines):
              row = [[] for i in range(len(fields_loc))]
              for field_id, (bid, offset) in enumerate(fields_loc):
                  if isinstance(blocks[bid], np.ndarray):
                      row[field_id] = blocks[bid][lid][offset]
                  elif isinstance(blocks[bid], torch.Tensor):
                      row[field_id] = blocks[bid][lid][offset].item()
                  else:
                      row[field_id] = blocks[bid][lid]
  
              flatten_ret.append(row)
  
          return flatten_ret
  
      flatten_table = block_table.mapValues(_flatten)
  
      flatten_obj = []
      for k, v in flatten_table.collect():
          if not flatten_obj:
              flatten_obj = v
          else:
              flatten_obj.extend(v)
  
      fields = [
          data_manager.get_field_name(idx)
          for idx in range(len(fields_loc))
      ]
      pd_df = pd.DataFrame(flatten_obj, columns=fields, dtype=object)
      pd_df.set_index(data_manager.schema.sample_id_name)
  
      for name in fields[1:]:
          dtype = data_manager.get_field_type_by_name(name)
          if dtype in ["int32", "float32", "int64", "float64"]:
              pd_df[name] = pd_df[name].astype(dtype)
  
      return pd_df
  
file_path: FATE/python/fate/arch/dataframe/ops/_transformer.py
imports: import functools
  import pandas
  from typing import List, Tuple
  import torch
  from fate.arch import tensor
  import numpy
  from ..manager.data_manager import DataManager
label_desc: Use image node_id 6 for calling a global function with example usage: transform_to_pandas_dataframe(block_table, data_manager) and returns: pd_df, flatten_ret