code: def flatten_data(
      df: DataFrame, key_type="block_id", with_sample_id=True
  ):
      """
      key_type="block_id":
          key=(block_id, block_offset), value=data_row
      key_type="sample_id":
          key=sample_id, value=data_row
      """
      sample_id_index = (
          df.data_manager.loc_block(
              df.data_manager.schema.sample_id_name, with_offset=False
          )
          if (with_sample_id or key_type == "sample_id")
          else None
      )
  
      def _flatten(kvs):
          for block_id, blocks in kvs:
              flat_blocks = [
                  Block.transform_block_to_list(block)
                  for block in blocks
              ]
              block_num = len(flat_blocks)
              if key_type == "block_id":
                  for row_id in range(len(blocks[0])):
                      if with_sample_id:
                          yield (block_id, row_id), (
                              flat_blocks[sample_id_index][row_id],
                              [
                                  flat_blocks[i][row_id]
                                  for i in range(block_num)
                              ],
                          )
                      else:
                          yield (block_id, row_id), [
                              flat_blocks[i][row_id]
                              for i in range(block_num)
                          ]
              else:
                  for row_id in range(len(blocks[0])):
                      yield flat_blocks[sample_id_index][row_id], [
                          flat_blocks[i][row_id]
                          for i in range(block_num)
                      ]
  
      if key_type in ["block_id", "sample_id"]:
          return df.block_table.mapPartitions(
              _flatten, use_previous_behavior=False
          )
      else:
          raise ValueError(
              f"Not Implement key_type={key_type} of flatten_data."
          )
  
file_path: FATE/python/fate/arch/dataframe/ops/_indexer.py
imports: import functools
  import uuid
  from ..manager import Block, DataManager
  from .._dataframe import DataFrame
label_desc: Use image node_id 6 for calling a global function with example usage: flatten_data(df, key_type, with_sample_id) and returns: df