code: def shard_param(p: ColoParameter) -> None:
      pg = p.get_process_group()
      p._redistribute(distspec.ShardSpec([0], [pg.tp_world_size()]))
      p.grad = (
          p.grad.chunk(pg.tp_world_size(), 0)[pg.tp_local_rank()]
          .clone()
          .detach()
      )
  
file_path: colossalai/tests/test_legacy/test_utils/test_norm_gradient_clipping.py
imports: import pytest
  import torch
  from torch.nn.parameter import Parameter
  from torch.nn.utils import clip_grad_norm_
  import colossalai
  from colossalai.legacy.tensor import ColoTensorSpec, ProcessGroup, distspec
  from colossalai.legacy.utils.common import clip_grad_norm
  from colossalai.logging import disable_existing_loggers
  from colossalai.tensor.colo_parameter import ColoParameter
  from colossalai.testing import parameterize, rerun_if_address_is_in_use, spawn
  from colossalai.utils import get_current_device
label_desc: Use image node_id 2 for calling a global function with example usage: shard_param(p) without return types