code: def _set_old_item(df: "DataFrame", keys, items):
      def _replace_single(
          blocks,
          item=None,
          narrow_loc=None,
          dst_bids=None,
          dm: DataManager = None,
      ):
          ret_blocks = [block for block in blocks]
          for i in range(len(ret_blocks), dm.block_num):
              ret_blocks.append([])
  
          for bid, offsets in narrow_loc:
              ret_blocks[bid] = ret_blocks[bid][:, offsets]
  
          lines = len(blocks[0])
          for dst_bid in dst_bids:
              ret_blocks[dst_bid] = dm.blocks[dst_bid].convert_block(
                  [[item] for idx in range(lines)]
              )
  
          return ret_blocks
  
      def _replace_multi(
          blocks,
          item_list=None,
          narrow_loc=None,
          dst_bids=None,
          dm: DataManager = None,
      ):
          ret_blocks = [block for block in blocks]
          for i in range(len(ret_blocks), dm.block_num):
              ret_blocks.append([])
  
          for bid, offsets in narrow_loc:
              ret_blocks[bid] = ret_blocks[bid][:, offsets]
  
          lines = len(blocks[0])
          for dst_bid, item in zip(dst_bids, item_list):
              ret_blocks[dst_bid] = dm.blocks[dst_bid].convert_block(
                  [[item] for idx in range(lines)]
              )
  
          return ret_blocks
  
      def _replace_df(
          l_blocks,
          r_blocks,
          narrow_loc=None,
          dst_bids=None,
          r_blocks_loc=None,
          dm: DataManager = None,
      ):
          ret_blocks = [block for block in l_blocks]
          for i in range(len(ret_blocks), dm.block_num):
              ret_blocks.append([])
  
          for bid, offsets in narrow_loc:
              ret_blocks[bid] = ret_blocks[bid][:, offsets]
  
          for dst_bid, (r_bid, offset) in zip(dst_bids, r_blocks_loc):
              ret_blocks[dst_bid] = r_blocks[r_bid][:, [offset]]
  
          return ret_blocks
  
      def _replace_tensor(
          blocks,
          r_tensor,
          narrow_loc=None,
          dst_bids=None,
          dm: DataManager = None,
      ):
          ret_blocks = [block for block in blocks]
          for i in range(len(ret_blocks), dm.block_num):
              ret_blocks.append([])
  
          for bid, offsets in narrow_loc:
              ret_blocks[bid] = ret_blocks[bid][:, offsets]
  
          for offset, dst_bid in enumerate(dst_bids):
              ret_blocks[dst_bid] = dm.blocks[dst_bid].convert_block(
                  r_tensor[:, offset : offset + 1]
              )
  
          return ret_blocks
  
      data_manager = df.data_manager.duplicate()
      if isinstance(
          items,
          (
              bool,
              int,
              float,
              str,
              np.int32,
              np.float32,
              np.int64,
              np.float64,
              np.bool_,
          ),
      ):
          narrow_blocks, dst_blocks = data_manager.split_columns(
              keys, BlockType.get_block_type(items)
          )
          replace_func = functools.partial(
              _replace_single,
              item=items,
              narrow_loc=narrow_blocks,
              dst_bids=dst_blocks,
              dm=data_manager,
          )
          block_table = df.block_table.mapValues(replace_func)
      elif isinstance(items, list):
          if len(keys) != len(items):
              if len(keys) > 1:
                  raise ValueError(
                      "Must have equal len keys and value when setting with an iterable"
                  )
              narrow_blocks, dst_blocks = data_manager.split_columns(
                  keys, BlockType.get_block_type("object")
              )
              replace_func = functools.partial(
                  _replace_single,
                  item=items[0],
                  narrow_loc=narrow_blocks,
                  dst_bids=dst_blocks,
                  dm=data_manager,
              )
          else:
              narrow_blocks, dst_blocks = data_manager.split_columns(
                  keys,
                  [BlockType.get_block_type(item) for item in items],
              )
              replace_func = functools.partial(
                  _replace_multi,
                  item_list=items,
                  narrow_loc=narrow_blocks,
                  dst_bids=dst_blocks,
                  dm=data_manager,
              )
  
          block_table = df.block_table.mapValues(replace_func)
      elif isinstance(items, DataFrame):
          other_dm = items.data_manager
          operable_fields = other_dm.infer_operable_field_names()
          operable_blocks_loc = other_dm.loc_block(operable_fields)
          block_types = [
              other_dm.blocks[bid].block_type
              for bid, _ in operable_blocks_loc
          ]
          if len(keys) != len(operable_fields):
              raise ValueError(
                  "Setitem with rhs=DataFrame must have equal len keys"
              )
          narrow_blocks, dst_blocks = data_manager.split_columns(
              keys, block_types
          )
          replace_func = functools.partial(
              _replace_df,
              narrow_loc=narrow_blocks,
              dst_bids=dst_blocks,
              r_blocks_loc=operable_blocks_loc,
              dm=data_manager,
          )
          block_table = df.block_table.join(
              items.block_table, replace_func
          )
      elif isinstance(items, DTensor):
          if len(keys) != items.shape[1]:
              raise ValueError(
                  "Setitem with rhs=DTensor must have equal len keys"
              )
          block_type = BlockType.get_block_type(items.dtype)
          narrow_blocks, dst_blocks = data_manager.split_columns(
              keys, block_type
          )
          replace_func = functools.partial(
              _replace_tensor,
              narrow_loc=narrow_blocks,
              dst_bids=dst_blocks,
              dm=data_manager,
          )
          block_table = df.block_table.join(
              items.shardings._data, replace_func
          )
  
      else:
          raise ValueError(
              f"Seiitem with rhs_type={type(items)} is not supported"
          )
  
      df.block_table = block_table
      df.data_manager = data_manager
  
file_path: FATE/python/fate/arch/dataframe/ops/_set_item.py
imports: import functools
  import numpy
  from .._dataframe import DataFrame
  from ..manager.block_manager import BlockType
  from ..manager.data_manager import DataManager
  from fate.arch.tensor import DTensor
  from fate.arch.tensor.phe._tensor import PHETensor
label_desc: Use image node_id 4 for calling a global function with example usage: _set_old_item(df, keys, items) and returns: ret_blocks, ret_blocks, ret_blocks, ret_blocks