code: def strided_moving_window(
      x: np.ndarray,
      window_len: int,
      stride: int = 1,
      axis: int = 0,
      check_inputs: bool = True,
  ) -> np.ndarray:
      """
      Extracts moving window views of an `x` array along a specified `axis`, where each window is of length `window_len`
      and consecutive windows are separated by `stride` indices. The total number of extracted windows equals
      `num_windows = (x.shape[axis] - window_len)//stride + 1`.
  
      Notes
      -----
      This function is similar to `sliding_window_view` in `np.lib.stride_tricks`, except that:
          1. `strided_moving_window` allows for consecutive windows to be separated by a specified `stride`,
          whilst `sliding_window_view` does not.
          2. `strided_moving_window` can only operate along a single axis, whereas `sliding_window_view` can
          operate along multiple axes.
      Additionally, unlike `sliding_window_view`, using `strided_moving_window` doesn't require `numpy >= 1.20.0`.
  
      Parameters
      ----------
      x
          The array from which to extract moving windows.
      window_len
          The size of the extracted moving windows.
      stride
          Optionally, the separation between consecutive windows.
      axis
          Optionally, the axis along which the moving windows should be extracted.
      check_inputs
          Optionally, specifies whether inputs should be checked for validity. Should be set
          to `False` if inputs have already been checked for validity (e.g. inside the `__init__`
          of a class), otherwise should be set to `True`. See [1]_ for further details.
  
      Returns
      -------
      windows
          The moving windows extracted from `x`. The extracted windows are stacked along the last axis, and the
          `axis` along which the windows were extracted is 'trimmed' such that its length equals the number of
          extracted windows. More specifically, `windows.shape = x_trimmed_shape + (window_len,)`, where
          `x_trimmed_shape` equals `x.shape`, except that `x_trimmed_shape[axis] = num_windows`.
  
      Raises
      ------
      ValueError
          If `check_inputs = True` and `window_len` is not positive.
      ValueError
          If `check_inputs = True` and `stride` is not positive.
      ValueError
          If `check_inputs = True` and `axis` is greater than `x.ndim`.
      ValueError
          If `check_inputs = True` and `window_len` is larger than `x.shape[axis]`.
  
      References
      ----------
      .. [1] https://numpy.org/doc/stable/reference/generated/numpy.lib.stride_tricks.as_strided.html
      """
      if check_inputs:
          raise_if(
              not isinstance(stride, int) or stride < 1,
              "`stride` must be a positive `int`.",
          )
          raise_if(
              not isinstance(window_len, int) or window_len < 1,
              "`window_len` must be a positive `int`.",
          )
          raise_if(
              not isinstance(axis, int)
              or axis > x.ndim - 1
              or axis < -x.ndim,
              "`axis` must be an `int` that is less than `x.ndim`.",
          )
          raise_if(
              window_len > x.shape[axis],
              "`window_len` must be less than or equal to x.shape[axis].",
          )
      num_windows = (x.shape[axis] - window_len) // stride + 1
      new_shape = list(x.shape)
      new_shape[axis] = num_windows
      new_shape = tuple(new_shape) + (window_len,)
      out_strides = list(x.strides) + [x.strides[axis]]
      out_strides[axis] = stride * out_strides[axis]
      out_strides = tuple(out_strides)
      return as_strided(x, shape=new_shape, strides=out_strides)
  
imports: import warnings
  from functools import reduce
  from math import inf
  from typing import Dict, List, Optional, Sequence, Tuple, Union
  from itertools import chain
  import numpy
  import pandas
  from numpy.lib.stride_tricks import as_strided
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from darts.timeseries import TimeSeries
  from darts.utils.utils import get_single_series, series2seq
label_desc: Use image node_id 12 for calling a global function with example usage: strided_moving_window(x, window_len, stride, axis, check_inputs) and returns: as_strided