code: def select_single(
      self, distance, gt_instance, gt_kernel_instance, training_mask
  ):
      with paddle.no_grad():
          # paddle 2.3.1, paddle.slice not support:
          # distance[:, self.coord[:, 1], self.coord[:, 0]]
          select_distance_list = []
          for i in range(2):
              tmp1 = distance[i, :]
              tmp2 = tmp1[self.coord[:, 1], self.coord[:, 0]]
              select_distance_list.append(tmp2.unsqueeze(0))
          select_distance = paddle.concat(select_distance_list, axis=0)
  
          off_points = paddle.cast(
              self.coord, "float32"
          ) + 10 * select_distance.transpose((1, 0))
  
          off_points = paddle.cast(off_points, "int64")
          off_points = paddle.clip(
              off_points, 0, distance.shape[-1] - 1
          )
  
          selected_mask = (
              gt_instance[self.coord[:, 1], self.coord[:, 0]]
              != gt_kernel_instance[off_points[:, 1], off_points[:, 0]]
          )
          selected_mask = paddle.cast(
              selected_mask.reshape((1, -1, distance.shape[-1])),
              "int64",
          )
          selected_training_mask = selected_mask * training_mask
  
          return selected_training_mask
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import nn
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 3 for calling the SmoothL1Loss obj's underlying member method code with example usage: obj.select_single(distance, gt_instance, gt_kernel_instance, training_mask) and returns: selected_training_mask