code: def get_channel_map(self, sequence_output, entity_as):
      # sequence_output = sequence_output.to('cpu')
      # attention = attention.to('cpu')
      bs, _, d = sequence_output.size()
      # ne = max([len(x) for x in entity_as])  # 本次bs中的最大实体数
      ne = self.min_height
  
      index_pair = []
      for i in range(ne):
          tmp = torch.cat(
              (
                  torch.ones((ne, 1), dtype=int) * i,
                  torch.arange(0, ne).unsqueeze(1),
              ),
              dim=-1,
          )
          index_pair.append(tmp)
      index_pair = (
          torch.stack(index_pair, dim=0)
          .reshape(-1, 2)
          .to(sequence_output.device)
      )
      map_rss = []
      for b in range(bs):
          entity_atts = entity_as[b]
          h_att = torch.index_select(entity_atts, 0, index_pair[:, 0])
          t_att = torch.index_select(entity_atts, 0, index_pair[:, 1])
          ht_att = (h_att * t_att).mean(1)
          ht_att = ht_att / (ht_att.sum(1, keepdim=True) + 1e-5)
          rs = contract("ld,rl->rd", sequence_output[b], ht_att)
          map_rss.append(rs)
      map_rss = torch.cat(map_rss, dim=0).reshape(bs, ne, ne, d)
      return map_rss
  
file_path: DeepKE/src/deepke/relation_extraction/document/model.py
imports: import torch
  import torch.nn
  from opt_einsum import contract
  from .losses import ATLoss
  import torch.nn.functional
  from .module import AttentionUNet
  from .prepro import process_long_input
label_desc: Use image node_id 6 for calling the DocREModel obj's underlying member method code with example usage: obj.get_channel_map(sequence_output, entity_as) and returns: map_rss