code: def _train(
      data_train,
      Nminibatch,
      order,
      C,
      rng,
      lr_train,
      debug,
      maxiter,
      maxtime,
      init,
      dftol_stop,
      freltol_stop,
      dn_log,
      accum_steps,
      path_save,
      shuffle,
      device=constants.Device.CPU,
      verbose=1,
      prev_checkpoint=None,
      groups=None,
      soft_groups=None,
  ):
      """
      Main training loop.
      """
  
      t_init = time.time()
  
      x0 = get_init(data_train, init, rng)
      if (
          isinstance(init, str)
          and init == constants.Initialization.ZERO
      ):
          ninitfeats = -1
      else:
          ninitfeats = np.where(x0.detach().numpy() > 0)[0].size
  
      S = Solver(
          data_train,
          order,
          Nminibatch=Nminibatch,
          x0=x0,
          C=C,
          ftransform=lambda x: torch.sigmoid(2 * x),
          get_train_opt=lambda p: torch.optim.Adam(p, lr_train),
          rng=rng,
          accum_steps=accum_steps,
          shuffle=shuffle,
          groups=groups,
          soft_groups=soft_groups,
          device=device,
          verbose=verbose,
      )
      S = S.to(device)
  
      S.ninitfeats = ninitfeats
      S.x0 = x0
  
      if prev_checkpoint:
          S.load_state_dict(prev_checkpoint[constants.Checkpoint.MODEL])
          S.opt_train.load_state_dict(
              prev_checkpoint[constants.Checkpoint.OPT]
          )
          torch.set_rng_state(prev_checkpoint[constants.Checkpoint.RNG])
  
      minibatch = S.Ntrain != S.Nminibatch
  
      f_stop, stop_conds = get_optim_f_stop(
          maxiter,
          maxtime,
          dftol_stop,
          freltol_stop,
          minibatch=minibatch,
      )
  
      if debug:
          pass
      else:
          f_callback = None
      stop_conds["t"][-1] = time.time() - t_init
  
      S.train(f_stop=f_stop, f_callback=f_callback)
  
      return get_checkpoint(S, stop_conds, rng), S
  
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 4 for calling a global function with example usage: _train(data_train, Nminibatch, order, C, rng, lr_train, debug, maxiter, maxtime, init, dftol_stop, freltol_stop, dn_log, accum_steps, path_save, shuffle, device, verbose, prev_checkpoint, groups, soft_groups) and returns: get_checkpoint,  S