class_docstr: An BinaryBcastOpHandler is a node handler which deals with operations which have two
  operands and broadcasting occurs such as torch.add.
class_docstr_tok: ["An","BinaryBcastOpHandler","is","a","node","handler","which","deals","with","operations","which","have","two","operands","and","broadcasting","occurs","such","as","torch.add","."]
code: def post_process(
      self, strategy: ShardingStrategy
  ) -> Union[ShardingStrategy, List[ShardingStrategy]]:
      # convert bias from its logical sharding spec to its physical sharding spec
      op_data_mapping = self.get_operation_data_mapping()
  
      for op_name, op_data in op_data_mapping.items():
          if op_data in self.non_tensor_list:
              # remove the sharding spec if the op_data is not a tensor, e.g. torch.pow(tensor, 2)
              strategy.sharding_specs.pop(op_data)
  
          else:
              # convert the logical sharding spec to physical sharding spec if broadcast
              # e.g. torch.rand(4, 4) + torch.rand(4)
              physical_shape = op_data.data.shape
              logical_shape = op_data.logical_shape
              sharding_spec = strategy.get_sharding_spec_by_name(
                  op_data.name
              )
              (
                  sharding_spec,
                  removed_dims,
              ) = recover_sharding_spec_for_broadcast_shape(
                  sharding_spec, logical_shape, physical_shape
              )
  
              strategy.sharding_specs[op_data] = sharding_spec
              if len(removed_dims) > 0:
                  comm_action = comm_actions_for_oprands(
                      node=self.node,
                      removed_dims=removed_dims,
                      op_data=op_data,
                      sharding_spec=sharding_spec,
                  )
                  strategy.communication_actions[op_data] = comm_action
  
      return strategy
  
file_path: ColossalAI/colossalai/auto_parallel/tensor_shard/node_handler/binary_elementwise_handler.py
imports: from typing import Dict, List, Union
  import torch
  from torch.fx.node import Node
  from colossalai.auto_parallel.tensor_shard.sharding_strategy import OperationData, OperationDataType, ShardingStrategy
  from ..constants import BCAST_FUNC_OP
  from ..utils import comm_actions_for_oprands, recover_sharding_spec_for_broadcast_shape
  from .node_handler import MetaInfoNodeHandler
  from .registry import operator_registry
  from .strategy import BinaryElementwiseStrategyGenerator, StrategyGenerator
label_desc: Use image node_id 3 for calling the BinaryElementwiseHandler obj's underlying member method code with example usage: obj.post_process(strategy) and returns: strategy