class_docstr: A naive implementation which shard each tensor evenly over all ranks
class_docstr_tok: ["A","naive","implementation","which","shard","each","tensor","evenly","over","all","ranks"]
docstr: Shard tensor among processes.
  
  Args:
      t (ShardedTensor): a tensor to be sharded.
      process_group (Optional[dist.ProcessGroup], optional): the process group among which tensor shards.
      Defaults to None.
docstr_tok: ["Shard","tensor","among","processes",".","Args",":","t","(","ShardedTensor",")",":","a","tensor","to","be","sharded",".","process_group","(","Optional","[","dist.ProcessGroup","]",",","optional",")",":","the","process","group","among","which","tensor","shards",".","Defaults","to","None","."]
code: def _shard_tensor(
      self,
      t: ShardedTensor,
      process_group: Optional[dist.ProcessGroup] = None,
  ):
      """Shard tensor among processes.
  
      Args:
          t (ShardedTensor): a tensor to be sharded.
          process_group (Optional[dist.ProcessGroup], optional): the process group among which tensor shards.
          Defaults to None.
      """
      if t.is_sharded:
          return
      if t.payload.device.type == "cuda":
          assert t.payload.device == get_current_device(), (
              f"shard tensor on cuda device index {t.payload.device.index},"
              f" but current cuda device is {get_current_device()}"
          )
      sharded_payload, _ = get_shard(
          t.payload,
          dist.get_rank(process_group),
          dist.get_world_size(process_group),
      )
      t.payload_reset(sharded_payload)
      t.is_sharded = True
  
file_path: ColossalAI/colossalai/legacy/zero/shard_utils/tensor_shard_strategy.py
imports: from typing import List, Optional
  import torch
  import torch.distributed
  from colossalai.legacy.zero.gemini.tensor_utils import colo_model_data_tensor_move_inline
  from colossalai.legacy.zero.shard_utils import BaseShardStrategy
  from colossalai.legacy.zero.shard_utils.commons import get_shard
  from colossalai.legacy.zero.sharded_param.sharded_tensor import ShardedTensor
  from colossalai.utils import get_current_device
label_desc: Use image node_id 3 for calling the TensorShardStrategy obj's underlying member method code with example usage: obj._shard_tensor(t, process_group) without return types