code: def ref_deformable_convolution_2d(
      x,
      w,
      offset,
      mask,
      b,
      base_axis,
      pad,
      stride,
      dilation,
      group,
      deformable_group,
      channel_last,
  ):
      if channel_last:
          assert (
              False
          ), "channel_last=True is not supported in ref_deformable_convolution_2d."
  
      assert (
          x.shape[0:base_axis] == offset.shape[0:base_axis]
      ), "Batch sizes do not match."
  
      # Compute deformable convolution for each batch.
      y = []
      # Flatten the batch dimensions to pass it the reference function.
      ext_x = x.reshape((-1,) + x.shape[base_axis:])
      ext_offset = offset.reshape((-1,) + offset.shape[base_axis:])
      if mask is None:
          mask_shape = (
              x.shape[0:base_axis]
              + (deformable_group * w.shape[2] * w.shape[3],)
              + x.shape[base_axis + 1 :]
          )
          mask = np.ones(mask_shape).astype(np.float32)
      ext_mask = mask.reshape((-1,) + mask.shape[base_axis:])
      for xx, oo, mm in zip(ext_x, ext_offset, ext_mask):
          y += [
              refs.deformable_convolution_2d(
                  xx,
                  w,
                  oo,
                  mm,
                  b,
                  pad,
                  stride,
                  dilation,
                  group,
                  deformable_group,
                  channel_last,
              )[np.newaxis]
          ]
      y = np.vstack(y)
      return y.reshape(x.shape[:base_axis] + y.shape[1:])
  
file_path: nnabla/python/test/function/test_deformable_convolution.py
imports: from __future__ import division
  import pytest
  import copy
  import numpy
  import nnabla
  import nnabla.functions
  import nnabla.parametric_functions
  import refs
  from nbla_test_utils import list_context
  from nbla_test_utils import function_tester
label_desc: Use image node_id 1 for calling a global function with example usage: ref_deformable_convolution_2d(x, w, offset, mask, b, base_axis, pad, stride, dilation, group, deformable_group, channel_last) and returns: y