code: def test_forward_backward_2d(
      inshape,
      kernel,
      out_channels,
      pad,
      stride,
      dilation,
      group,
      deformable_group,
      with_mask,
      channel_last,
      with_bias,
      base_axis,
      seed,
      ctx,
      func_name,
  ):
      if channel_last:
          pytest.skip(
              "channel_last=True is not supported in any backends so far."
          )
  
      import platform
  
      if platform.machine().startswith("arm"):
          pytest.skip("Skip the arm platform temporarily.")
  
      rng = np.random.RandomState(seed)
  
      # Create arguments
      func_args = [
          base_axis,
          pad,
          stride,
          dilation,
          group,
          deformable_group,
          channel_last,
      ]
  
      # Compute shapes
      in_channels = inshape[base_axis]
      kshape = (out_channels, in_channels // group) + kernel
      offset_channels = 2 * deformable_group * kernel[0] * kernel[1]
      offset_shape = (
          inshape[0:base_axis]
          + (offset_channels,)
          + inshape[base_axis + 1 :]
      )
      mask_shape = (
          inshape[0:base_axis]
          + (deformable_group * kernel[0] * kernel[1],)
          + inshape[base_axis + 1 :]
      )
      if channel_last:
          t = refs.ChannelLastToFirstTranspose(
              len(inshape), len(kernel)
          )
          inshape = tuple(inshape[i] for i in t.inv_axes)
          t = refs.ChannelLastToFirstTranspose(
              len(offset_shape), len(kernel)
          )
          offset_shape = tuple(offset_shape[i] for i in t.inv_axes)
          t = refs.ChannelLastToFirstTranspose(len(kshape), len(kernel))
          kshape = tuple(kshape[i] for i in t.inv_axes)
  
      # Create inputs
      x = rng.randn(*inshape).astype(np.float32)
      w = rng.randn(*kshape).astype(np.float32)
      b = (
          rng.randn(out_channels).astype(np.float32)
          if with_bias
          else None
      )
  
      # Because numerical gradient cannot be calculated correctly
      # near the input boundary, offsets are generated to avoid this case.
      # 1. Generate offsets in [-1.9, 1.9].
      offsets = (3.8 * rng.rand(*offset_shape).astype(np.float32)) - 1.9
      # 2. Adhoc remove the values dstep-neighborhood of {-1, 0, 1}; selecting bad
      #    values as 0.1-neighborhood (large enough dstep-neighborhood) and shifting
      #    them +0.5 (must larger than 2 * dstep).
      offsets += (
          np.logical_or(
              np.abs(offsets - np.floor(offsets)) < 0.1,
              np.abs(offsets - np.ceil(offsets)) < 0.1,
          ).astype(int)
          * 0.5
      )
  
      mask = (
          rng.rand(*mask_shape).astype(np.float32)
          if with_mask
          else None
      )
  
      inputs = [x, w, offsets, mask, b]
  
      # Test
      atol_half = 1.0 if in_channels > 64 else 1.5e-1
      function_tester(
          rng,
          F.deformable_convolution,
          ref_deformable_convolution_2d,
          inputs,
          func_args,
          atol_f=1e-4,
          atol_b=1e-2,
          atol_accum=1e-5,
          dstep=1e-2,
          ctx=ctx,
          func_name=func_name,
          atol_half=atol_half,
      )
  
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 2 for calling a global function with example usage: test_forward_backward_2d(inshape, kernel, out_channels, pad, stride, dilation, group, deformable_group, with_mask, channel_last, with_bias, base_axis, seed, ctx, func_name) without return types