class_docstr: nlp 里为了保证输出的句长 = 输入的句长，一般使用奇数 kernel_size，如 [3, 5, 7, 9]
  当然也可以不等长输出，keep_length 设为 False
  此时，padding = k // 2
  stride 一般为 1
docstr: :param x: torch.Tensor [batch_size, seq_max_length, input_size], [B, L, H] 一般是经过embedding后的值
  :param mask: [batch_size, max_len], 句长部分为0，padding部分为1。不影响卷积运算，max-pool一定不会pool到pad为0的位置
  :return:
code: def forward(self, x, mask=None):
      """
      :param x: torch.Tensor [batch_size, seq_max_length, input_size], [B, L, H] 一般是经过embedding后的值
      :param mask: [batch_size, max_len], 句长部分为0，padding部分为1。不影响卷积运算，max-pool一定不会pool到pad为0的位置
      :return:
      """
      # [B, L, H] -> [B, H, L] （注释：将 H 维度当作输入 channel 维度)
      x = torch.transpose(x, 1, 2)
  
      # convolution + activation  [[B, H, L], ... ]
      act_fn = self.activations[self.activation]
  
      x = [act_fn(conv(x)) for conv in self.convs]
      x = torch.cat(x, dim=1)
  
      # mask
      if mask is not None:
          # [B, L] -> [B, 1, L]
          mask = mask.unsqueeze(1)
          x = x.masked_fill_(mask, 1e-12)
  
      # pooling
      # [[B, H, L], ... ] -> [[B, H], ... ]
      if self.pooling_strategy == "max":
          xp = F.max_pool1d(x, kernel_size=x.size(2)).squeeze(2)
          # 等价于 xp = torch.max(x, dim=2)[0]
  
      elif self.pooling_strategy == "avg":
          x_len = (
              mask.squeeze()
              .eq(0)
              .sum(-1)
              .unsqueeze(-1)
              .to(torch.float)
              .to(device=mask.device)
          )
          xp = torch.sum(x, dim=-1) / x_len
  
      else:
          # self.pooling_strategy == 'cls'
          xp = x[:, :, 0]
  
      x = x.transpose(1, 2)
      x = self.dropout(x)
      xp = self.dropout(xp)
  
      return x, xp
  
file_path: DeepKE/src/deepke/relation_extraction/standard/module/CNN.py
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the CNN obj's underlying member method code with example usage: obj.forward(x, mask) and returns: x,  xp