code: def subsample_array(x, step, pad=False, mode='reflect'):
      
  
      if np.any(np.greater_equal(step, x.shape)):
          raise ValueError('Step size must be less than array size on each axis')
      sbsz, dvmd = np.divmod(x.shape, step)
      if pad and np.any(dvmd):
          sbsz += np.clip(dvmd, 0, 1)
          psz = np.subtract(np.multiply(sbsz, step), x.shape)
          pdt = [(0, p) for p in psz]
          x = np.pad(x, pdt, mode=mode)
      outsz = step + tuple(sbsz)
      outstrd = x.strides + tuple(np.multiply(step, x.strides))
      return np.lib.stride_tricks.as_strided(x, outsz, outstrd)
docs: Use :func:`numpy.lib.stride_tricks.as_strided` to construct a view
      of the input array that represents a subsampling of the array by the
      specified step, with different offsets of the subsampling as
      additional axes of the array. If the input array shape is not evenly
      divisible by the subsampling step, it is padded before the view
      is constructed. For example, if ``x`` is 6 x 6 array, the output of
      ``y = subsample_array(x, (2, 2))`` is a 2 x 2 x 3 x 3 array, with
      the first subsampling offset indexed as ``y[0, 0]``.
  
      Parameters
      ----------
      x : ndarray
        Input array
      step : tuple
        Subsampling step size
      pad : bool, optional (default False)
        Flag indicating whether the input array should be padded
        when its size is not integer divisible by the step size
      mode : string, optional (default 'reflect')
        A pad mode specification for :func:`numpy.pad`
  
      Returns
      -------
      xs : ndarray
        An array representing different subsampling offsets in the input
        array