code: def _get_encoder_output_anchors(
      self, memory, spatial_shapes, memory_mask=None, grid_size=0.05
  ):
      output_anchors = []
      idx = 0
      for lvl, (h, w) in enumerate(spatial_shapes):
          if memory_mask is not None:
              mask_ = memory_mask[:, idx : idx + h * w].reshape(
                  [-1, h, w]
              )
              valid_H = paddle.sum(mask_[:, :, 0], 1)
              valid_W = paddle.sum(mask_[:, 0, :], 1)
          else:
              valid_H, valid_W = h, w
  
          grid_y, grid_x = paddle.meshgrid(
              paddle.arange(end=h, dtype=memory.dtype),
              paddle.arange(end=w, dtype=memory.dtype),
          )
          grid_xy = paddle.stack([grid_x, grid_y], -1)
  
          valid_WH = (
              paddle.stack([valid_W, valid_H], -1)
              .reshape([-1, 1, 1, 2])
              .astype(grid_xy.dtype)
          )
          grid_xy = (grid_xy.unsqueeze(0) + 0.5) / valid_WH
          wh = paddle.ones_like(grid_xy) * grid_size * (2.0**lvl)
          output_anchors.append(
              paddle.concat([grid_xy, wh], -1).reshape([-1, h * w, 4])
          )
          idx += h * w
  
      output_anchors = paddle.concat(output_anchors, 1)
      valid_mask = (
          (output_anchors > self.eps) * (output_anchors < 1 - self.eps)
      ).all(-1, keepdim=True)
      output_anchors = paddle.log(output_anchors / (1 - output_anchors))
      if memory_mask is not None:
          valid_mask = (
              valid_mask * (memory_mask.unsqueeze(-1) > 0)
          ) > 0
      output_anchors = paddle.where(
          valid_mask, output_anchors, paddle.to_tensor(float("inf"))
      )
  
      memory = paddle.where(valid_mask, memory, paddle.to_tensor(0.0))
      if self.dual_queries:
          output_memory = [
              self.enc_output[g_id](memory)
              for g_id in range(self.dual_groups + 1)
          ]
      else:
          output_memory = self.enc_output[0](memory)
      return output_memory, output_anchors
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle import ParamAttr
  from paddle.regularizer import L2Decay
  from ppdet.core.workspace import register
  from ..layers import MultiHeadAttention
  from .position_encoding import PositionEmbedding
  from ..heads.detr_head import MLP
  from .deformable_transformer import MSDeformableAttention
  from ..initializer import linear_init_, constant_, xavier_uniform_, normal_, bias_init_with_prob
  from .utils import _get_clones, get_valid_ratio, get_contrastive_denoising_training_group, get_sine_pos_embed, inverse_sigmoid
label_desc: Use image node_id 7 for calling the GroupDINOTransformer obj's underlying member method code with example usage: obj._get_encoder_output_anchors(memory, spatial_shapes, memory_mask, grid_size) and returns: output_memory,  output_anchors