code: def cmp_operate(lhs: DataFrame, rhs, op) -> "DataFrame":
      data_manager = lhs.data_manager
      block_indexes = data_manager.infer_operable_blocks()
      column_names = data_manager.infer_operable_field_names()
  
      if isinstance(
          rhs,
          (
              bool,
              int,
              float,
              np.int32,
              np.float32,
              np.int64,
              np.float64,
              np.bool_,
          ),
      ):
          block_table = binary_operate(
              lhs.block_table, rhs, op, block_indexes
          )
  
      elif isinstance(rhs, (np.ndarray, list, pd.Series)):
          if isinstance(rhs, pd.Series):
              rhs = series_to_ndarray(rhs, column_names)
          if isinstance(rhs, list):
              rhs = np.array(rhs)
          if len(rhs.shape) > 2:
              raise ValueError("NdArray's Dimension should <= 2")
          if len(column_names) != rhs.size:
              raise ValueError(
                  f"Size of List/NDArray/Series should = {len(lhs.schema.columns)}"
              )
          rhs = rhs.reshape(-1)
          field_indexes = [
              data_manager.get_field_offset(name)
              for name in column_names
          ]
          field_indexes_mappings = dict(
              zip(field_indexes, range(len(field_indexes)))
          )
          rhs_blocks = [
              np.array([]) for _ in range(data_manager.block_num)
          ]
          for bid in block_indexes:
              indexer = [
                  field_indexes_mappings[field]
                  for field in data_manager.get_block(bid).field_indexes
              ]
              if BlockType.is_tensor(
                  data_manager.get_block(bid).block_type
              ):
                  rhs_blocks[bid] = torch.Tensor(rhs[indexer])
              else:
                  rhs_blocks[bid] = rhs[indexer]
  
          block_table = binary_operate(
              lhs.block_table, rhs_blocks, op, block_indexes
          )
  
      elif isinstance(rhs, DataFrame):
          other_data_manager = rhs.data_manager
          other_column_names = (
              other_data_manager.infer_operable_field_names()
          )
          if set(column_names) != set(other_column_names):
              raise ValueError(
                  "Comparison of two DataFrame should be identically-labeled"
              )
          lhs_block_loc = [
              data_manager.loc_block(name) for name in column_names
          ]
          rhs_block_loc = [
              other_data_manager.loc_block(name)
              for name in column_names
          ]
          field_indexes = [
              data_manager.get_field_offset(name)
              for name in column_names
          ]
          field_indexes_mappings = dict(
              zip(field_indexes, range(len(field_indexes)))
          )
          indexers = [
              [
                  field_indexes_mappings[field]
                  for field in data_manager.get_block(bid).field_indexes
              ]
              for bid in block_indexes
          ]
  
          block_table = _cmp_dfs(
              lhs.block_table,
              rhs.block_table,
              op,
              lhs_block_loc,
              rhs_block_loc,
              block_indexes,
              indexers,
          )
      else:
          raise ValueError(
              f"Not implement comparison of rhs type={type(rhs)}"
          )
  
      block_table, data_manager = _merge_bool_blocks(
          block_table, data_manager, block_indexes
      )
      return type(lhs)(
          lhs._ctx,
          block_table,
          lhs.partition_order_mappings,
          data_manager,
      )
  
file_path: FATE/python/fate/arch/dataframe/ops/_cmp.py
imports: import numpy
  import pandas
  import torch
  from .._dataframe import DataFrame
  from .._dataframe import DataManager
  from ..manager import BlockType
  from .utils.operators import binary_operate
  from .utils.series_align import series_to_ndarray
  from ._compress_block import compress_blocks
label_desc: Use image node_id 1 for calling a global function with example usage: cmp_operate(lhs, rhs, op) and returns: type