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 _sanity_check(self):
      if len(self.sharding_sequence) > self.dims:
          raise ShardingOutOfIndexError(
              f"sharding_sequence should have {self.dims} elements, but got index {len(self.sharding_sequence)}."
          )
  
      if (
          list(self.dim_partition_dict.keys())
          and max(list(self.dim_partition_dict.keys())) >= self.dims
      ):
          raise ShardingOutOfIndexError(
              f"the key of dim_partition_dict should be less than {self.dims}, but got {max(list(self.dim_partition_dict.keys()))}."
          )
  
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 2 for calling the ShardingSpec obj's underlying member method code with example usage: obj._sanity_check() without return types