code: def to_blocks(
      kvs, dm: DataManager = None, partition_mappings: dict = None
  ):
      ret_blocks = [[] for _ in range(dm.block_num)]
  
      block_id = None
      for lid, (sample_id, value) in enumerate(kvs):
          if block_id is None:
              block_id = partition_mappings[sample_id]["start_block_id"]
          ret_blocks[0].append(sample_id)
          for bid, buf in enumerate(value):
              ret_blocks[bid + 1].append(buf)
  
          if (lid + 1) % dm.block_row_size == 0:
              yield block_id, dm.convert_to_blocks(ret_blocks)
              ret_blocks = [[] for _ in range(dm.block_num)]
              block_id += 1
  
      if ret_blocks[0]:
          yield block_id, dm.convert_to_blocks(ret_blocks)
  
imports: import copy
  import functools
  from typing import List, Union
  import torch
  from sklearn.utils import resample
  from .._dataframe import DataFrame
  from ..manager.data_manager import DataManager
  from ..manager.block_manager import Block
  from ._compress_block import compress_blocks
  from ._indexer import get_partition_order_by_raw_table, get_partition_order_mappings_by_block_table
  from ._promote_types import promote_partial_block_types
  from ._set_item import set_item
  from fate.arch.tensor import DTensor
label_desc: Use image node_id 10 for calling a global function with example usage: to_blocks(kvs, dm, partition_mappings) without return types