code: def roi_average_align_2d(
      x, rois, roi_indices, outsize, spatial_scale, sampling_ratio=None
  ):
      """Spatial Region of Interest (ROI) average align function.
  
      This function acts similarly to
      :func:`~chainer.functions.roi_average_pooling_2d`, but it computes average
      of input spatial patch with bilinear interpolation for each channel with
      the region of interest.
  
      Args:
          x (~chainer.Variable): Input variable. The shape is expected to be
              4 dimensional: ``(n: batch, c: channel, h, height, w: width)``.
          rois (~chainer.Variable): Input roi variable. The shape is expected to
              be ``(n: data size, 4)``, and each datum is set as below:
              ``(y_min, x_min, y_max, x_max)``.
          roi_indices (~chainer.Variable): Input roi variable. The shape is
              expected to be ``(n: data size, )``.
          outsize ((int, int) or int): Expected output size after pooled
              (height, width). ``outsize=o`` and ``outsize=(o, o)``
              are equivalent.
          spatial_scale (float): Scale of the roi is resized.
          sampling_ratio ((int, int) or int): Sampling step for the alignment.
              It must be an integer over :math:`1` or :obj:`None`, and the value
              is automatically decided when :obj:`None` is passed.  Use of
              different ratio in height and width axis is also supported by
              passing tuple of int as ``(sampling_ratio_h, sampling_ratio_w)``.
              ``sampling_ratio=s`` and ``sampling_ratio=(s, s)`` are equivalent.
  
      Returns:
          ~chainer.Variable: Output variable.
  
      See the original paper proposing ROIAlign:
      `Mask R-CNN <https://arxiv.org/abs/1703.06870>`_.
  
      """
      return ROIAverageAlign2D(outsize, spatial_scale, sampling_ratio)(
          x, rois, roi_indices
      )
  
imports: import numbers
  import numpy
  import six
  import chainer
  from chainer.backends import cuda
  from chainer import function
  from chainer import utils
  from chainer.utils import type_check
label_desc: Use image node_id 4 for calling a global function with example usage: roi_average_align_2d(x, rois, roi_indices, outsize, spatial_scale, sampling_ratio) and returns: ROIAverageAlign2D