code: def split_tensor_3d(
      tensor: Tensor, dim: int, parallel_mode: ParallelMode
  ) -> Tensor:
      r"""Splits 3D parallel tensor in specified dimension.
  
      Args:
          tensor (:class:`torch.tensor`): Input tensor.
          dim (int): Specified dimension in which to split.
          parallel_mode (:class:`colossalai.legacy.context.parallel_mode.ParallelMode`, optional): Parallel mode.
  
      Returns:
          :class:`torch.tensor`: The tensor has been split.
  
      Note:
          The parallel_mode should be concluded in ``ParallelMode``. More details about ``ParallelMode`` could be found
          in `parallel_mode <https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/context/parallel_mode.py>`_.
      """
      dim_size = tensor.size(dim)
      world_size = gpc.get_world_size(parallel_mode)
      assert dim_size % world_size == 0, (
          f"The dimension {dim} to split, size ({dim_size}) is not a multiple of world size ({world_size}), "
          f"cannot split tensor evenly"
      )
      if tensor.size(dim) <= 1:
          return tensor
      output = torch.chunk(
          tensor, gpc.get_world_size(parallel_mode), dim=dim
      )[gpc.get_local_rank(parallel_mode)].contiguous()
      return output
  
imports: from typing import Optional, Tuple
  import torch
  from torch import Tensor
  from torch.cuda.amp import custom_bwd, custom_fwd
  from colossalai.legacy.communication import all_gather, all_reduce, broadcast, reduce, reduce_scatter
  from colossalai.legacy.constants import INPUT_GROUP_3D, WEIGHT_GROUP_3D
  from colossalai.legacy.context.parallel_mode import ParallelMode
  from colossalai.legacy.core import global_context
  from ._utils import get_parallel_mode_from_env, push_async_grad
label_desc: Use image node_id 7 for calling a global function with example usage: split_tensor_3d(tensor, dim, parallel_mode) and returns: output, tensor