class_docstr: ROIGather module for gather global information
  Args: 
      in_channels: prior feature channels
      num_priors: prior numbers we predefined
      sample_points: the number of sampled points when we extract feature from line
      fc_hidden_dim: the fc output channel
      refine_layers: the total number of layers to build refine
class_docstr_tok: ["ROIGather","module","for","gather","global","information","Args",":","in_channels",":","prior","feature","channels","num_priors",":","prior","numbers","we","predefined","sample_points",":","the","number","of","sampled","points","when","we","extract","feature","from","line","fc_hidden_dim",":","the","fc","output","channel","refine_layers",":","the","total","number","of","layers","to","build","refine"]
docstr: Args:
      roi_features: prior feature, shape: (Batch * num_priors, prior_feat_channel, sample_point, 1)
      x: feature map
      layer_index: currently on which layer to refine
  Return: 
      roi: prior features with gathered global information, shape: (Batch, num_priors, fc_hidden_dim)
docstr_tok: ["Args",":","roi_features",":","prior","feature",",","shape",":","(","Batch","*","num_priors",",","prior_feat_channel",",","sample_point",",","1",")","x",":","feature","map","layer_index",":","currently","on","which","layer","to","refine","Return",":","roi",":","prior","features","with","gathered","global","information",",","shape",":","(","Batch",",","num_priors",",","fc_hidden_dim",")"]
code: def forward(self, roi_features, x, layer_index):
      """
      Args:
          roi_features: prior feature, shape: (Batch * num_priors, prior_feat_channel, sample_point, 1)
          x: feature map
          layer_index: currently on which layer to refine
      Return:
          roi: prior features with gathered global information, shape: (Batch, num_priors, fc_hidden_dim)
      """
  
      roi = self.roi_fea(roi_features, layer_index)
      # return roi
      # print(roi.shape)
      # return roi
      bs = x.shape[0]
      # print(bs)
      # roi = roi.contiguous().view(bs * self.num_priors, -1)
      roi = roi.reshape([bs * self.num_priors, -1])
      # roi = paddle.randn([192,2304])
      # return roi
      # print(roi)
      # print(self.fc)
      # print(self.fc.weight)
      roi = self.fc(roi)
      roi = F.relu(self.fc_norm(roi))
      # return roi
      # roi = roi.view(bs, self.num_priors, -1)
      roi = roi.reshape([bs, self.num_priors, -1])
      query = roi
  
      value = self.resize(self.f_value(x))  # (B, C, N) global feature
      query = self.f_query(
          query
      )  # (B, N, 1) sample context feature from prior roi
      key = self.f_key(x)
      value = value.transpose(perm=[0, 2, 1])
      key = self.resize(key)  # (B, C, N) global feature
      sim_map = paddle.matmul(query, key)
      sim_map = (self.in_channels**-0.5) * sim_map
      sim_map = F.softmax(sim_map, axis=-1)
  
      context = paddle.matmul(sim_map, value)
      context = self.W(context)
  
      roi = roi + F.dropout(context, p=0.1, training=self.training)
  
      return roi
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.modeling.initializer import constant_
  from paddle.nn.initializer import KaimingNormal
  import paddle.nn
label_desc: Use image node_id 3 for calling the ROIGather obj's underlying member method code with example usage: obj.forward(roi_features, x, layer_index) and returns: roi