code: def oneflow_seed_everything(
      seed: int = None, add_global_rank_to_seed: bool = True
  ) -> int:
      r"""
      为 **oneflow**、**numpy**、**python.random** 伪随机数生成器设置种子。
  
      :param seed: 全局随机状态的整数值种子。如果为 ``None`` 则会根据时间戳生成一个种子。
      :param add_global_rank_to_seed: 在分布式训练中，是否在不同 **rank** 中使用不同的随机数。
          当设置为 ``True`` 时，**fastNLP** 会将种子加上当前的 ``global_rank``。
      """
      max_seed_value = np.iinfo(np.uint32).max
      min_seed_value = np.iinfo(np.uint32).min
  
      if seed is None:
          if os.getenv(FASTNLP_BACKEND_LAUNCH) == "1":
              seed = 42
          else:
              seed = get_global_seed()
          logger.info(
              f"'FASTNLP_GLOBAL_SEED' is set to {seed} automatically."
          )
      if not isinstance(seed, int):
          seed = int(seed)
  
      if not (min_seed_value <= seed <= max_seed_value):
          logger.rank_zero_warning(
              "Your seed value is too big or too small for numpy, we will choose a random seed for you."
          )
          seed %= max_seed_value
  
      os.environ[FASTNLP_GLOBAL_SEED] = f"{seed}"
      if add_global_rank_to_seed:
          seed += get_global_rank()
  
      random.seed(seed)
      np.random.seed(seed)
      oneflow.manual_seed(seed)
      oneflow.cuda.manual_seed_all(seed)
      return seed
  
imports: import os
  from typing import Any, Dict, Optional
  from enum import IntEnum
  import contextlib
  import random
  import numpy
  import inspect
  from fastNLP.envs.imports import _NEED_IMPORT_ONEFLOW
  from fastNLP.envs.utils import get_global_seed
  from fastNLP.envs import get_global_rank, FASTNLP_BACKEND_LAUNCH, FASTNLP_GLOBAL_SEED
  from fastNLP.core.samplers import ReproducibleBatchSampler
  from fastNLP.core.utils import auto_param_call
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 for calling a global function with example usage: oneflow_seed_everything(seed, add_global_rank_to_seed) and returns: seed