code: def seed(parallel_mode: ParallelMode):
      """A context for seed switch
  
      Examples:
  
          >>> with seed(ParallelMode.DATA):
          >>>     output = F.dropout(input)
  
      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>`_.
      """
      try:
          # set to new mode
          current_mode = _SEED_MANAGER.current_mode
          yield _SEED_MANAGER.set_mode(parallel_mode)
      finally:
          # recover
          _SEED_MANAGER.set_mode(current_mode)
  
file_path: colossalai/colossalai/legacy/context/random/_helper.py
imports: import functools
  from contextlib import contextmanager
  import torch.cuda
  from torch import Tensor
  from ..parallel_mode import ParallelMode
  from .seed_manager import SeedManager
label_desc: Use image node_id 8 for calling a global function with example usage: seed(parallel_mode) without return types