code: def im2col_nd_gpu(img, ksize, stride, pad, cover_all=False, dilate=1):
      n, c = img.shape[0:2]  # (n, c, d_1, d_2, ..., d_N)
      dims = img.shape[2:]
      ndim = len(dims)
      dilate = as_tuple(dilate, ndim)
      assert ndim == len(ksize) == len(stride) == len(pad)
      outs = tuple(
          get_conv_outsize(d, k, s, p, cover_all, di)
          for (d, k, s, p, di) in zip(dims, ksize, stride, pad, dilate)
      )
      assert all(
          out > 0 for out in outs
      ), "Output sizes should be positive."
  
      # col_shape: (n, c, k_1, k_2, ..., k_N, out_1, out_2, ..., out_N)
      shape = (n, c) + ksize + outs
      col = cuda.cupy.empty(shape, dtype=img.dtype)
  
      (
          in_params,
          out_params,
          operation,
          name,
      ) = conv_nd_kernel.Im2colNDKernel.generate(ndim)
  
      cuda.elementwise(in_params, out_params, operation, name)(
          img.reduced_view(),
          *(dims + outs + ksize + stride + pad + dilate + (col,)),
      )
  
      return col
  
file_path: chainer/chainer/utils/conv_nd.py
imports: import itertools
  import numpy
  import six
  from chainer.backends import cuda
  from chainer.utils.conv import get_conv_outsize
  from chainer.utils import conv_nd_kernel
label_desc: Use image node_id 3 for calling a global function with example usage: im2col_nd_gpu(img, ksize, stride, pad, cover_all, dilate) and returns: col