code: def get_denoising_training_group(
      targets,
      num_classes,
      num_queries,
      class_embed,
      num_denoising=100,
      label_noise_ratio=0.5,
      box_noise_scale=1.0,
  ):
      if num_denoising <= 0:
          return None, None, None, None
      num_gts = [len(t) for t in targets["gt_class"]]
      max_gt_num = max(num_gts)
      if max_gt_num == 0:
          return None, None, None, None
  
      num_group = num_denoising // max_gt_num
      num_group = 1 if num_group == 0 else num_group
      # pad gt to max_num of a batch
      bs = len(targets["gt_class"])
      input_query_class = paddle.full(
          [bs, max_gt_num], num_classes, dtype="int32"
      )
      input_query_bbox = paddle.zeros([bs, max_gt_num, 4])
      pad_gt_mask = paddle.zeros([bs, max_gt_num])
      for i in range(bs):
          num_gt = num_gts[i]
          if num_gt > 0:
              input_query_class[i, :num_gt] = targets["gt_class"][
                  i
              ].squeeze(-1)
              input_query_bbox[i, :num_gt] = targets["gt_bbox"][i]
              pad_gt_mask[i, :num_gt] = 1
  
      input_query_class = input_query_class.tile([1, num_group])
      input_query_bbox = input_query_bbox.tile([1, num_group, 1])
      pad_gt_mask = pad_gt_mask.tile([1, num_group])
  
      dn_positive_idx = paddle.nonzero(pad_gt_mask)[:, 1]
      dn_positive_idx = paddle.split(
          dn_positive_idx, [n * num_group for n in num_gts]
      )
      # total denoising queries
      num_denoising = int(max_gt_num * num_group)
  
      if label_noise_ratio > 0:
          input_query_class = input_query_class.flatten()
          pad_gt_mask = pad_gt_mask.flatten()
          # half of bbox prob
          mask = paddle.rand(input_query_class.shape) < (
              label_noise_ratio * 0.5
          )
          chosen_idx = paddle.nonzero(mask * pad_gt_mask).squeeze(-1)
          # randomly put a new one here
          new_label = paddle.randint_like(
              chosen_idx, 0, num_classes, dtype=input_query_class.dtype
          )
          input_query_class.scatter_(chosen_idx, new_label)
          input_query_class.reshape_([bs, num_denoising])
          pad_gt_mask.reshape_([bs, num_denoising])
  
      if box_noise_scale > 0:
          diff = (
              paddle.concat(
                  [
                      input_query_bbox[..., 2:] * 0.5,
                      input_query_bbox[..., 2:],
                  ],
                  axis=-1,
              )
              * box_noise_scale
          )
          diff *= paddle.rand(input_query_bbox.shape) * 2.0 - 1.0
          input_query_bbox += diff
          input_query_bbox = inverse_sigmoid(input_query_bbox)
  
      class_embed = paddle.concat(
          [class_embed, paddle.zeros([1, class_embed.shape[-1]])]
      )
      input_query_class = paddle.gather(
          class_embed, input_query_class.flatten(), axis=0
      ).reshape([bs, num_denoising, -1])
  
      tgt_size = num_denoising + num_queries
      attn_mask = paddle.ones([tgt_size, tgt_size]) < 0
      # match query cannot see the reconstruction
      attn_mask[num_denoising:, :num_denoising] = True
      # reconstruct cannot see each other
      for i in range(num_group):
          if i == 0:
              attn_mask[
                  max_gt_num * i : max_gt_num * (i + 1),
                  max_gt_num * (i + 1) : num_denoising,
              ] = True
          if i == num_group - 1:
              attn_mask[
                  max_gt_num * i : max_gt_num * (i + 1),
                  : max_gt_num * i,
              ] = True
          else:
              attn_mask[
                  max_gt_num * i : max_gt_num * (i + 1),
                  max_gt_num * (i + 1) : num_denoising,
              ] = True
              attn_mask[
                  max_gt_num * i : max_gt_num * (i + 1),
                  : max_gt_num * i,
              ] = True
      attn_mask = ~attn_mask
      dn_meta = {
          "dn_positive_idx": dn_positive_idx,
          "dn_num_group": num_group,
          "dn_num_split": [num_denoising, num_queries],
      }
  
      return input_query_class, input_query_bbox, attn_mask, dn_meta
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import math
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ..bbox_utils import bbox_overlaps
label_desc: Use image node_id 8 for calling a global function with example usage: get_denoising_training_group(targets, num_classes, num_queries, class_embed, num_denoising, label_noise_ratio, box_noise_scale) and returns: input_query_class,  input_query_bbox,  attn_mask,  dn_meta, None,  None,  None,  None, None,  None,  None,  None