code: def rolling_window(a, window, axis=-1):
      """
      Make an ndarray with a rolling window along axis.
      This function is taken from https://github.com/numpy/numpy/pull/31
      but slightly modified to accept axis option.
      """
      a = numpy.swapaxes(a, axis, -1)
      shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)
      strides = a.strides + (a.strides[-1],)
      if isinstance(a, numpy.ndarray):
          rolling = numpy.lib.stride_tricks.as_strided(
              a, shape=shape, strides=strides
          )
      elif isinstance(a, cupy.ndarray):
          rolling = stride_tricks.as_strided(
              a, shape=shape, strides=strides
          )
      return rolling.swapaxes(-2, axis)
  
imports: import unittest
  import numpy
  import cupy
  from cupy import testing
  from cupy.lib import stride_tricks
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: rolling_window(a, window, axis) and returns: rolling