docstr: Args:
      token: (B, L), index of tokens
      pos1: (B, L), relative position to head entity
      pos2: (B, L), relative position to tail entity
  Return:
      (B, EMBED), representations for sentences
docstr_tok: ["Args",":","token",":","(","B",",","L",")",",","index","of","tokens","pos1",":","(","B",",","L",")",",","relative","position","to","head","entity","pos2",":","(","B",",","L",")",",","relative","position","to","tail","entity","Return",":","(","B",",","EMBED",")",",","representations","for","sentences"]
code: def forward(self, token, pos1, pos2):
      """
      Args:
          token: (B, L), index of tokens
          pos1: (B, L), relative position to head entity
          pos2: (B, L), relative position to tail entity
      Return:
          (B, EMBED), representations for sentences
      """
      # Check size of tensors
      if (
          len(token.size()) != 2
          or token.size() != pos1.size()
          or token.size() != pos2.size()
      ):
          raise Exception(
              "Size of token, pos1 ans pos2 should be (B, L)"
          )
      x = torch.cat(
          [
              self.word_embedding(token),
              self.pos1_embedding(pos1),
              self.pos2_embedding(pos2),
          ],
          2,
      )  # (B, L, EMBED)
      x = x.transpose(1, 2)  # (B, EMBED, L)
      x = self.act(self.conv(x))  # (B, H, L)
      x = self.pool(x).squeeze(-1)
      x = self.drop(x)
      return x
  
file_path: OpenNRE/opennre/encoder/cnn_encoder.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ..module.nn import CNN
  from ..module.pool import MaxPool
  from .base_encoder import BaseEncoder
label_desc: Use image node_id 2 for calling the CNNEncoder obj's underlying member method code with example usage: obj.forward(token, pos1, pos2) and returns: x