code: def _grp_converter(groups, n_features):
      if isinstance(groups, int):
          grp_size = groups
          if n_features % grp_size != 0:
              raise ValueError(
                  "n_features (%d) is not a multiple of the desired"
                  " group size (%d)" % (n_features, grp_size)
              )
          n_groups = n_features // grp_size
          grp_ptr = grp_size * np.arange(n_groups + 1)
          grp_indices = np.arange(n_features)
      elif isinstance(groups, list) and isinstance(groups[0], int):
          grp_indices = np.arange(n_features).astype(np.int32)
          grp_ptr = np.cumsum(np.hstack([[0], groups]))
      elif isinstance(groups, list) and isinstance(groups[0], list):
          grp_sizes = np.array([len(ls) for ls in groups])
          grp_ptr = np.cumsum(np.hstack([[0], grp_sizes]))
          grp_indices = np.array([idx for grp in groups for idx in grp])
      else:
          raise ValueError("Unsupported group format.")
      return grp_ptr.astype(np.int32), grp_indices.astype(np.int32)
  
file_path: celer/celer/homotopy.py
imports: import numpy
  from scipy import sparse
  from numpy.linalg import norm
  from sklearn.utils import check_array
  from sklearn.linear_model._base import _preprocess_data
  from .lasso_fast import celer
  from .group_fast import celer_grp, dnorm_grp
  from .cython_utils import compute_norms_X_col, compute_Xw
  from .cython_utils import dnorm_enet
  from .multitask_fast import celer_mtl
  from .PN_logreg import newton_celer
label_desc: Use image node_id 6 for calling a global function with example usage: _grp_converter(groups, n_features) and returns: grp_ptr,  grp_indices