code: def slow_ms_deform_attn(
      value, value_spatial_shapes, sampling_locations, attention_weights
  ):
      b, _, num_heads, depth = value.shape
      (
          _,
          n_queries,
          _,
          num_levels,
          num_points,
          _,
      ) = sampling_locations.shape
      value_list = value.split(
          [h * w for h, w in value_spatial_shapes], axis=1
      )
      # Normalize [0, 1] -> [-1, 1]
      sampling_grids = 2 * sampling_locations - 1
      sampling_value_list = []
      # Iterate along levels
      for i, (h, w) in enumerate(value_spatial_shapes):
          value_l_ = (
              value_list[i]
              .flatten(2)
              .transpose((0, 2, 1))
              .reshape((b * num_heads, depth, h, w))
          )
          sampling_grid_l_ = (
              sampling_grids[:, :, :, i]
              .transpose((0, 2, 1, 3, 4))
              .flatten(0, 1)
          )
          sampling_value_l_ = F.grid_sample(
              value_l_,
              sampling_grid_l_,
              mode="bilinear",
              padding_mode="zeros",
              align_corners=False,
          )
          sampling_value_list.append(sampling_value_l_)
      # (b, n_queries, num_heads, num_levels*num_points) -> (b, num_heads, n_queries, num_levels*num_points) -> (b, num_heads, 1, n_queries, num_levels*num_points)
      attention_weights = attention_weights.transpose(
          (0, 2, 1, 3, 4)
      ).reshape((b * num_heads, 1, n_queries, num_levels * num_points))
      output = (
          (
              paddle.stack(sampling_value_list, axis=-2).flatten(-2)
              * attention_weights
          )
          .sum(-1)
          .reshape((b, num_heads * depth, n_queries))
      )
      return output.transpose((0, 2, 1))
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import math
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddleseg.cvlibs import param_init
  from paddlepanseg.models.param_init import THLinearInitMixin
  from paddlepanseg.utils import use_custom_op
label_desc: Use image node_id 1 for calling a global function with example usage: slow_ms_deform_attn(value, value_spatial_shapes, sampling_locations, attention_weights) and returns: output