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:
            if all(x is None for x in [n_timesteps, n_samples]):
                raise_log(
                    ValueError(
                        "Must specify either `n_timesteps`, `n_samples`, or `series`."
                    ),
                    logger=logger,
                )
        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

        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)`.

        
darts/dataprocessing/transformers/base_data_transformer.py