code: def split_X_lengths(X, lengths):
      if lengths is None:
          return [X]
      else:
          cs = np.cumsum(lengths)
          n_samples = len(X)
          if cs[-1] != n_samples:
              raise ValueError(
                  f"lengths array {lengths} doesn't sum to {n_samples} samples"
              )
          return np.split(X, cs)[:-1]
  
imports: import warnings
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: split_X_lengths(X, lengths) and returns: list, np