class_docstr: This object contains a DeepSpeed configuration dictionary and can be quickly queried for things like zero stage.
  
  A ``weakref`` of this object is stored in the module's globals to be able to access the config from areas where
  things like the Trainer object is not available (e.g. ``from_pretrained`` and ``_get_resized_embeddings``).
  Therefore it's important that this object remains alive while the program is still running.
  
  :class:`~transformers.Trainer` uses the ``HfTrainerDeepSpeedConfig`` subclass instead. That subclass has logic to
  sync the configuration with values of :class:`~transformers.TrainingArguments` by replacing special placeholder
  values: ``"auto"``. Without this special logic the DeepSpeed configuration is not modified in any way.
  
  Args:
      config_file_or_dict (:obj:`Union[str, Dict]`): path to DeepSpeed config file or dict.
class_docstr_tok: ["This","object","contains","a","DeepSpeed","configuration","dictionary","and","can","be","quickly","queried","for","things","like","zero","stage",".","A","``","weakref","``","of","this","object","is","stored","in","the","module","'s","globals","to","be","able","to","access","the","config","from","areas","where","things","like","the","Trainer","object","is","not","available","(","e.g",".","``","from_pretrained","``","and","``","_get_resized_embeddings","``",")",".","Therefore","it","'s","important","that","this","object","remains","alive","while","the","program","is","still","running",".",":","class",":","`","~transformers.Trainer","`","uses","the","``","HfTrainerDeepSpeedConfig","``","subclass","instead",".","That","subclass","has","logic","to","sync","the","configuration","with","values","of",":","class",":","`","~transformers.TrainingArguments","`","by","replacing","special","placeholder","values",":","``","``","auto","''","``",".","Without","this","special","logic","the","DeepSpeed","configuration","is","not","modified","in","any","way",".","Args",":","config_file_or_dict","(",":","obj",":","`","Union","[","str",",","Dict","]","`",")",":","path","to","DeepSpeed","config","file","or","dict","."]
code: def __init__(self, config_file_or_dict):
      # set global weakref object
      set_hf_deepspeed_config(self)
  
      require_version("deepspeed>=0.5.3")
  
      if isinstance(config_file_or_dict, dict):
          # Don't modify user's data should they want to reuse it (e.g. in tests), because once we
          # modified it, it will not be accepted here again, since `auto` values would have been overridden
          config = deepcopy(config_file_or_dict)
      elif isinstance(config_file_or_dict, str):
          with io.open(config_file_or_dict, "r", encoding="utf-8") as f:
              config = json.load(f)
      else:
          raise ValueError(
              "expecting either a path to a DeepSpeed config file or a pre-populated dict"
          )
      self.config = config
  
      # zero stage - this is done as early as possible, before model is created, to allow
      # ``is_deepspeed_zero3_enabled`` query and getting to the early deepspeed config object
      # during ``zero.Init()`` which needs whether fp16 is enabled, dtype, etc.
      self._stage = self.get_value("zero_optimization.stage", -1)
  
      # offload
      self._offload = False
      if self.is_zero2() or self.is_zero3():
          offload_devices_valid = set(["cpu", "nvme"])
          offload_devices = set(
              [
                  self.get_value(
                      "zero_optimization.offload_optimizer.device"
                  ),
                  self.get_value(
                      "zero_optimization.offload_param.device"
                  ),
              ]
          )
          if len(offload_devices & offload_devices_valid) > 0:
              self._offload = True
  
imports: import importlib.util
  import io
  import json
  import weakref
  from copy import deepcopy
  from functools import partialmethod
  from .utils.versions import require_version
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 to create a new HfDeepSpeedConfig object  with example: obj = HfDeepSpeedConfig(config_file_or_dict)