class_docstr: OutputGenerator is a generic class to generate strategies for Output Node.
docstr: Generate replica strategy for output node.
docstr_tok: ["Generate","replica","strategy","for","output","node","."]
code: def replica_strategy(self) -> List[ShardingStrategy]:
      """
      Generate replica strategy for output node.
      """
      dim_partition_dict_mapping = {}
      dim_partition_dict_for_output = []
      for index, _ in enumerate(self.predecessor_nodes):
          mapping_name = f"input_{index}"
          if isinstance(self.op_data[mapping_name].data, (tuple, list)):
              dim_partition_dict_for_input = [
                  {}
                  for _ in range(len(self.op_data[mapping_name].data))
              ]
          else:
              dim_partition_dict_for_input = {}
          dim_partition_dict_mapping[
              mapping_name
          ] = dim_partition_dict_for_input
          dim_partition_dict_for_output.append(
              dim_partition_dict_for_input
          )
  
      if len(dim_partition_dict_for_output) == 1:
          dim_partition_dict_for_output = dim_partition_dict_for_output[
              0
          ]
      else:
          dim_partition_dict_for_output = tuple(
              dim_partition_dict_for_output
          )
  
      dim_partition_dict_mapping[
          "output"
      ] = dim_partition_dict_for_output
  
      communication_action_mapping = {}
      sharding_spec_mapping = self.to_sharding_spec_mapping(
          dim_partition_dict_mapping
      )
  
      name = "Replica Output"
  
      strategy = self.get_sharding_strategy(
          name=name,
          sharding_spec_mapping=sharding_spec_mapping,
          communication_action_mapping=communication_action_mapping,
      )
      return strategy
  
file_path: colossalai/colossalai/auto_parallel/tensor_shard/node_handler/strategy/output_generator.py
imports: from typing import Dict, List
  from torch.fx import Node
  from colossalai.auto_parallel.tensor_shard.sharding_strategy import MemoryCost, OperationData, ShardingStrategy, TrainCycleItem
  from colossalai.device.device_mesh import DeviceMesh
  from .strategy_generator import OutputStrategyGenerator
label_desc: Use image node_id 5 for calling the OutputGenerator obj's underlying member method code with example usage: obj.replica_strategy() and returns: strategy