docstr: Reshapes the 2D array returned by `stack_samples` back into an array of shape
  `(n_timesteps, n_components, n_samples)`; this 'undoes' the reshaping of
  `stack_samples`. Either `n_components`, `n_samples`, or `series` must be specified.
  
  Parameters
  ----------
  vals
      `np.ndarray` of shape `(n_timesteps * n_samples, n_components)` to be 'unstacked'.
  n_timesteps
      Optionally, the number of timesteps in the array originally passed to `stack_samples`.
      Does *not* need to be provided if `series` is specified.
  n_samples
      Optionally, the number of samples in the array originally passed to `stack_samples`.
      Does *not* need to be provided if `series` is specified.
  series
      Optionally, the `TimeSeries` object used to create `vals`; `n_samples` is inferred
      from this.
  
  Returns
  -------
  unstacked
      `np.ndarray` of shape `(n_timesteps, n_components, n_samples)`.
docstr_tok: ["Reshapes","the","2D","array","returned","by","`","stack_samples","`","back","into","an","array","of","shape","`","(","n_timesteps",",","n_components",",","n_samples",")","`",";","this","'undoes","'","the","reshaping","of","`","stack_samples","`",".","Either","`","n_components","`",",","`","n_samples","`",",","or","`","series","`","must","be","specified",".","Parameters","--","--","--","--","--","vals","`","np.ndarray","`","of","shape","`","(","n_timesteps","*","n_samples",",","n_components",")","`","to","be","'unstacked","'",".","n_timesteps","Optionally",",","the","number","of","timesteps","in","the","array","originally","passed","to","`","stack_samples","`",".","Does","*","not","*","need","to","be","provided","if","`","series","`","is","specified",".","n_samples","Optionally",",","the","number","of","samples","in","the","array","originally","passed","to","`","stack_samples","`",".","Does","*","not","*","need","to","be","provided","if","`","series","`","is","specified",".","series","Optionally",",","the","`","TimeSeries","`","object","used","to","create","`","vals","`",";","`","n_samples","`","is","inferred","from","this",".","Returns","--","--","--","-","unstacked","`","np.ndarray","`","of","shape","`","(","n_timesteps",",","n_components",",","n_samples",")","`","."]
code: def unstack_samples(
      vals: np.ndarray,
      n_timesteps: Optional[int] = None,
      n_samples: Optional[int] = None,
      series: Optional[TimeSeries] = None,
  ) -> np.ndarray:
      """
      Reshapes the 2D array returned by `stack_samples` back into an array of shape
      `(n_timesteps, n_components, n_samples)`; this 'undoes' the reshaping of
      `stack_samples`. Either `n_components`, `n_samples`, or `series` must be specified.
  
      Parameters
      ----------
      vals
          `np.ndarray` of shape `(n_timesteps * n_samples, n_components)` to be 'unstacked'.
      n_timesteps
          Optionally, the number of timesteps in the array originally passed to `stack_samples`.
          Does *not* need to be provided if `series` is specified.
      n_samples
          Optionally, the number of samples in the array originally passed to `stack_samples`.
          Does *not* need to be provided if `series` is specified.
      series
          Optionally, the `TimeSeries` object used to create `vals`; `n_samples` is inferred
          from this.
  
      Returns
      -------
      unstacked
          `np.ndarray` of shape `(n_timesteps, n_components, n_samples)`.
  
      """
      if series is not None:
          n_samples = series.n_samples
      else:
          raise_if(
              all(x is None for x in [n_timesteps, n_samples]),
              "Must specify either `n_timesteps`, `n_samples`, or `series`.",
          )
      n_components = vals.shape[-1]
      if n_timesteps is not None:
          reshaped_vals = vals.reshape(n_timesteps, -1, n_components)
      else:
          reshaped_vals = vals.reshape(-1, n_samples, n_components)
      unstacked = np.swapaxes(reshaped_vals, 1, 2)
      return unstacked
  
imports: from abc import ABC, abstractmethod
  from typing import Any, Generator, List, Mapping, Optional, Sequence, Union
  import numpy
  import xarray
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not
  from darts.utils import _build_tqdm_iterator, _parallel_apply
label_desc: Use image node_id 11 for calling the BaseDataTransformer obj's underlying member method code with example usage: obj.unstack_samples(vals, n_timesteps, n_samples, series) and returns: unstacked