class_docstr: Base class representing sharding specifications.
class_docstr_tok: ["Base","class","representing","sharding","specifications","."]
docstr: Given a global tensor on src_rank, shard this tensor
  across ranks within the process group, return a ShardedTensor.
  Args:
      tensor (:class:`torch.Tensor`): Tensor needs to be sharded.
  Keyword args:
      src_rank (int, optional): The source rank which is used as the ground truth of
          the data for the parameter that would be sharded and scattered
          across the rest of the ranks.
          Default: 0.
      process_group (ProcessGroup, optional): The process group to work on. If None,
          the default process group will be used.
  Returns:
      A :class:`ShardedTensor` sharded from the given tensor.
docstr_tok: ["Given","a","global","tensor","on","src_rank",",","shard","this","tensor","across","ranks","within","the","process","group",",","return","a","ShardedTensor",".","Args",":","tensor","(",":","class",":","`","torch.Tensor","`",")",":","Tensor","needs","to","be","sharded",".","Keyword","args",":","src_rank","(","int",",","optional",")",":","The","source","rank","which","is","used","as","the","ground","truth","of","the","data","for","the","parameter","that","would","be","sharded","and","scattered","across","the","rest","of","the","ranks",".","Default",":","0.","process_group","(","ProcessGroup",",","optional",")",":","The","process","group","to","work","on",".","If","None",",","the","default","process","group","will","be","used",".","Returns",":","A",":","class",":","`","ShardedTensor","`","sharded","from","the","given","tensor","."]
code: def shard(
      self, tensor: torch.Tensor, src_rank: int = 0, process_group=None
  ) -> "ShardedTensor":
      """
      Given a global tensor on src_rank, shard this tensor
      across ranks within the process group, return a ShardedTensor.
      Args:
          tensor (:class:`torch.Tensor`): Tensor needs to be sharded.
      Keyword args:
          src_rank (int, optional): The source rank which is used as the ground truth of
              the data for the parameter that would be sharded and scattered
              across the rest of the ranks.
              Default: 0.
          process_group (ProcessGroup, optional): The process group to work on. If None,
              the default process group will be used.
      Returns:
          A :class:`ShardedTensor` sharded from the given tensor.
      """
  
imports: from abc import ABC, abstractmethod
  from dataclasses import dataclass
  import functools
  from typing import Callable, Dict, List, TYPE_CHECKING
  import torch
  from ._internals import check_tensor, get_chunked_dim_size, get_split_size, validate_non_overlapping_shards_metadata
  from torch.distributed._shard.metadata import ShardMetadata
  import torch.distributed._shard.sharded_tensor.metadata
  from torch.distributed._shard.op_registry_utils import _decorator_func
label_desc: Use image node_id 2 for calling the ShardingSpec obj's underlying member method code with example usage: obj.shard(tensor, src_rank, process_group) without return types