code: def ref_convolution(
      x, w, b, base_axis, pad, stride, dilation, group, channel_last
  ):
      if channel_last:
          t = refs.ChannelLastToFirstTranspose(x.ndim, len(pad))
          x = t(x)
          tw = refs.ChannelLastToFirstTranspose(w.ndim, len(pad))
          w = tw(w)
          y = ref_convolution(
              x, w, b, base_axis, pad, stride, dilation, group, False
          )
          return t.inv(y)
      y = []
      for xx in x.reshape((-1,) + x.shape[base_axis:]):
          y += [
              refs.convolution_nd(
                  xx, w, b, pad, stride, dilation, group
              )[np.newaxis]
          ]
      y = np.vstack(y)
      return y.reshape(x.shape[:base_axis] + y.shape[1:])
  
file_path: nnabla/python/test/function/test_convolution.py
imports: from __future__ import division
  import pytest
  import numpy
  import nnabla.functions
  import refs
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: ref_convolution(x, w, b, base_axis, pad, stride, dilation, group, channel_last) and returns: y, t