class_docstr: Sharding spec describes how to shard a tensor with dim_size dimensions. The sharding sequence looks like
  [R, R, S0, S1], which means
  
  Argument:
      dim_partition_dict(Dict[int, List[int]], optional): The key is the dimension of tensor to be sharded,
          and the value of the key describe which logical axis will be sharded in that dimension.
      sharding_sequence(List[DimSpec], optional): A straight view of ShardingSpec looks like [R, R, S0, S1].
class_docstr_tok: ["Sharding","spec","describes","how","to","shard","a","tensor","with","dim_size","dimensions",".","The","sharding","sequence","looks","like","[","R",",","R",",","S0",",","S1","]",",","which","means","Argument",":","dim_partition_dict","(","Dict","[","int",",","List","[","int","]","]",",","optional",")",":","The","key","is","the","dimension","of","tensor","to","be","sharded",",","and","the","value","of","the","key","describe","which","logical","axis","will","be","sharded","in","that","dimension",".","sharding_sequence","(","List","[","DimSpec","]",",","optional",")",":","A","straight","view","of","ShardingSpec","looks","like","[","R",",","R",",","S0",",","S1","]","."]
code: def __init__(
      self,
      dim_size: int,
      dim_partition_dict: Dict[int, List[int]] = None,
      sharding_sequence: List[DimSpec] = None,
  ):
      self.dims = dim_size
      self.dim_partition_dict = dim_partition_dict
      self.sharding_sequence = sharding_sequence
      if self.sharding_sequence is None:
          assert (
              self.dim_partition_dict is not None
          ), f"dim_partition_dict should not be None, if sharding_sequence is NoneType object."
          self.dim_partition_dict = merge_same_dim_mesh_list(
              dim_size=self.dims,
              dim_partition_dict=self.dim_partition_dict,
          )
          self.sharding_sequence = self.convert_dict_to_shard_sequence()
  
      elif self.dim_partition_dict is None:
          assert (
              self.sharding_sequence is not None
          ), f"sharding_sequence should not be None, if dim_partition_dict is NoneType object."
          self.dim_partition_dict = (
              self.convert_shard_sequence_to_dict()
          )
  
      self._sanity_check()
  
file_path: ColossalAI/colossalai/tensor/d_tensor/sharding_spec.py
imports: from copy import deepcopy
  from typing import Dict, List
  from ..utils import merge_same_dim_mesh_list
  from .misc import ShardingOutOfIndexError
label_desc: Use image node_id 1 to create a new ShardingSpec object  with example: obj = ShardingSpec(dim_size, dim_partition_dict, sharding_sequence)