Slicing overlapping sets of features from 2D numpy array into 3D numpy array

I am confronted with the following problem:

I have a 2D numpy array of shape (total_samples, n_features). Think of total_samples as time series i.e. features recorded at every time step. I would like to reshape this 2D array into a 3D array of shape (n_batch, n_samples, n_features) to be used as input for a “many to one” long short term memory (LSTM) neural network (NN). I would like to be able to specify n_samples and percentage_overlap between batches as inputs to a python function that figures out how many batches or strides are possible from the available 2D array given the desired percentage_overlap and n_samples.

def create_chunks((total_samples, n_features), n_samples, overlap=.5)
    return (n_batch, n_samples, n_features)

Numerically, let’s say for a single feature and 4 samples:

[[1], [2], [3], [4]]

using n_samples=2 and percentage_overlap=.5 should output

[[[1], [2]], [[2], [3]], [[3], [4]]].