code: def var(df: "DataFrame", ddof=1) -> "pd.Series":
      data_manager = df.data_manager
      operable_blocks = data_manager.infer_operable_blocks()
      n = df.shape[0]
  
      def _mapper(blocks, op_bids):
          ret = []
          for bid in op_bids:
              block = blocks[bid]
              if isinstance(block, torch.Tensor):
                  ret.append(
                      (
                          torch.sum(
                              torch.square(block), dim=0, keepdim=True
                          ),
                          torch.sum(block, dim=0, keepdim=True),
                      )
                  )
              else:
                  ret.append(
                      (
                          np.sum(np.square(block), axis=0),
                          np.sum(block, axis=0),
                      )
                  )
  
          return ret
  
      def _reducer(blocks1, block2):
          ret = []
          for block1, block2 in zip(blocks1, block2):
              if isinstance(block1, torch.Tensor):
                  ret.append(
                      (
                          torch.add(block1[0], block2[0]),
                          torch.add(block1[1], block2[1]),
                      )
                  )
              else:
                  ret.append(
                      (
                          np.add(block1[0], block2[0]),
                          np.add(block1[1], block2[1]),
                      )
                  )
  
          return ret
  
      mapper_func = functools.partial(_mapper, op_bids=operable_blocks)
      reduce_ret = df.block_table.mapValues(mapper_func).reduce(
          _reducer
      )
  
      ret_blocks = []
      for lhs, rhs in reduce_ret:
          if isinstance(lhs, torch.Tensor):
              rhs = torch.mul(torch.square(torch.div(rhs, n)), n)
              ret_blocks.append(
                  torch.div(torch.sub(lhs, rhs), n - ddof)
              )
          else:
              rhs = np.mul(np.square(np.div(rhs, n)), n)
              ret_blocks.append(np.div(np.sub(lhs, rhs), n - ddof))
  
      return _post_process(ret_blocks, operable_blocks, data_manager)
  
file_path: FATE/python/fate/arch/dataframe/ops/_stat.py
imports: import functools
  import numpy
  import pandas
  import torch
  from .._dataframe import DataFrame
  from ..manager import DataManager
label_desc: Use image node_id 5 for calling a global function with example usage: var(df, ddof) and returns: _post_process, ret, ret