docstr: Args:
      token2id: dictionary of token->idx mapping
      max_length: max length of sentence, used for postion embedding
      hidden_size: hidden size
      word_size: size of word embedding
      position_size: size of position embedding
      blank_padding: padding for CNN
      word2vec: pretrained word2vec numpy
      kernel_size: kernel_size size for CNN
      padding_size: padding_size for CNN
docstr_tok: ["Args",":","token2id",":","dictionary","of","token-",">","idx","mapping","max_length",":","max","length","of","sentence",",","used","for","postion","embedding","hidden_size",":","hidden","size","word_size",":","size","of","word","embedding","position_size",":","size","of","position","embedding","blank_padding",":","padding","for","CNN","word2vec",":","pretrained","word2vec","numpy","kernel_size",":","kernel_size","size","for","CNN","padding_size",":","padding_size","for","CNN"]
code: def __init__(
      self,
      token2id,
      max_length=128,
      hidden_size=230,
      word_size=50,
      position_size=5,
      blank_padding=True,
      word2vec=None,
      kernel_size=3,
      padding_size=1,
      dropout=0.0,
      activation_function=F.relu,
      mask_entity=False,
  ):
      """
      Args:
          token2id: dictionary of token->idx mapping
          max_length: max length of sentence, used for postion embedding
          hidden_size: hidden size
          word_size: size of word embedding
          position_size: size of position embedding
          blank_padding: padding for CNN
          word2vec: pretrained word2vec numpy
          kernel_size: kernel_size size for CNN
          padding_size: padding_size for CNN
      """
      # hyperparameters
      super().__init__(
          token2id,
          max_length,
          hidden_size,
          word_size,
          position_size,
          blank_padding,
          word2vec,
          mask_entity=mask_entity,
      )
      self.drop = nn.Dropout(dropout)
      self.kernel_size = kernel_size
      self.padding_size = padding_size
      self.act = activation_function
  
      self.conv = nn.Conv1d(
          self.input_size,
          self.hidden_size,
          self.kernel_size,
          padding=self.padding_size,
      )
      self.pool = nn.MaxPool1d(self.max_length)
      self.mask_embedding = nn.Embedding(4, 3)
      self.mask_embedding.weight.data.copy_(
          torch.FloatTensor(
              [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]
          )
      )
      self.mask_embedding.weight.requires_grad = False
      self._minus = -100
  
      self.hidden_size *= 3
  
file_path: OpenNRE/opennre/encoder/pcnn_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
  from nltk import word_tokenize
label_desc: Use image node_id 1 to create a new PCNNEncoder object from inherited base classes: BaseEncoder with example: obj = PCNNEncoder(token2id, max_length, hidden_size, word_size, position_size, blank_padding, word2vec, kernel_size, padding_size, dropout, activation_function, mask_entity)