code: def get_checkpoint(S, stop_conds, rng=None, get_state=True):
      """
      Save the necessary information into a dictionary
      """
  
      m = {}
      m["ninitfeats"] = S.ninitfeats
      m["x0"] = S.x0
      x = S.x.clone().cpu().detach()
      m["feats"] = np.where(x.numpy() >= 0)[0]
      m.update({k: v[0] for k, v in stop_conds.items()})
      if get_state:
          m.update(
              {
                  constants.Checkpoint.MODEL: S.state_dict(),
                  constants.Checkpoint.OPT: S.opt_train.state_dict(),
                  constants.Checkpoint.RNG: torch.get_rng_state(),
              }
          )
      if rng:
          m.update({"rng_state": rng.get_state()})
  
      return m
  
file_path: nni/nni/algorithms/feature_engineering/gradient_selector/fgtrain.py
imports: import time
  import numpy
  import torch
  from sklearn.feature_selection import SelectKBest, f_classif, mutual_info_classif, f_regression, mutual_info_regression
  from .None import constants
  from .None import syssettings
  from .learnability import Solver
  from .utils import EMA
label_desc: Use image node_id 3 for calling a global function with example usage: get_checkpoint(S, stop_conds, rng, get_state) and returns: m