code: def shard_simulator(target_pair, legal_sharding_dims):
      """
      Simulating shard operation, analyze the communication cost(always ZERO)
      and simulate the influence of the DimSpec.
  
      We don't allow uncontiguous layout, such as shard(S0)->S02 is NOT allowed.
      In addition, We BANNED all representations which shard_list in decreasing order,
      such as S10, so shard(S0) -> S10 is NOT allowed.
      Therefore, for the R dimension, we could just append any legal sharding dim on it.
      e.g.:
          shard(R) -> S0
      For the S dimension, we need to make sure the shard_list after sharding still keep rising order.
      e.g:
          shard(S0) -> S01
  
      Argument:
          target_pair(Tuple[int, List[int]]): The first element is the dimension of tensor to be sharded,
          and the second element describes which logical axis will be sharded in that dimension.
      """
      _, shard_list = target_pair
      shard_list_list = []
      for dim in legal_sharding_dims:
          if len(shard_list) != 0 and dim <= shard_list[-1]:
              continue
          new_shard_list = shard_list + [dim]
          shard_list_list.append(new_shard_list)
  
      return shard_list_list
  
file_path: ColossalAI/colossalai/tensor/utils.py
imports: from typing import Dict, Iterator, List, Tuple, Union
  import torch
  import torch.nn
  from colossalai.tensor.colo_tensor import ColoTensor
label_desc: Use image node_id 3 for calling a global function with example usage: shard_simulator(target_pair, legal_sharding_dims) and returns: shard_list_list