docstr: Parameters
  ----------
  vocabulary_size : int
      Number of tokens contained in of the vocabulary.
  max_seq_length : int
      Maximum sequence length.
  num_classes : int, default=2
      Number of output classes.
  out_channels : int, default=100
      Number of output channels.
  embed_dim : int, default=300
      Number of dimensions of a single embedding.
  padding_idx : int, default=0
      Padding index (passed to the embedding layer).
  kernel_heights : list of int, default=[3, 4, 5]
      Kernels heights for the convolutions.
  dropout : float, default=0.5
      Dropout Probability.
  embedding_matrix : torch.FloatTensor or torch.cuda.FloatTensor, default=None
      Embedding matrix in the shape (vocabulary_size, embed_dim).
  freeze_embedding_layer : bool, default=False
      Training adapts the embedding matrix if `True`, otherwise the embeddings are frozen.
docstr_tok: ["Parameters","--","--","--","--","--","vocabulary_size",":","int","Number","of","tokens","contained","in","of","the","vocabulary",".","max_seq_length",":","int","Maximum","sequence","length",".","num_classes",":","int",",","default=2","Number","of","output","classes",".","out_channels",":","int",",","default=100","Number","of","output","channels",".","embed_dim",":","int",",","default=300","Number","of","dimensions","of","a","single","embedding",".","padding_idx",":","int",",","default=0","Padding","index","(","passed","to","the","embedding","layer",")",".","kernel_heights",":","list","of","int",",","default=","[","3",",","4",",","5","]","Kernels","heights","for","the","convolutions",".","dropout",":","float",",","default=0.5","Dropout","Probability",".","embedding_matrix",":","torch.FloatTensor","or","torch.cuda.FloatTensor",",","default=None","Embedding","matrix","in","the","shape","(","vocabulary_size",",","embed_dim",")",".","freeze_embedding_layer",":","bool",",","default=False","Training","adapts","the","embedding","matrix","if","`","True","`",",","otherwise","the","embeddings","are","frozen","."]
code: def __init__(
      self,
      vocabulary_size,
      max_seq_length,
      num_classes=2,
      out_channels=100,
      embed_dim=300,
      padding_idx=0,
      kernel_heights=[3, 4, 5],
      dropout=0.5,
      embedding_matrix=None,
      freeze_embedding_layer=False,
  ):
      """
      Parameters
      ----------
      vocabulary_size : int
          Number of tokens contained in of the vocabulary.
      max_seq_length : int
          Maximum sequence length.
      num_classes : int, default=2
          Number of output classes.
      out_channels : int, default=100
          Number of output channels.
      embed_dim : int, default=300
          Number of dimensions of a single embedding.
      padding_idx : int, default=0
          Padding index (passed to the embedding layer).
      kernel_heights : list of int, default=[3, 4, 5]
          Kernels heights for the convolutions.
      dropout : float, default=0.5
          Dropout Probability.
      embedding_matrix : torch.FloatTensor or torch.cuda.FloatTensor, default=None
          Embedding matrix in the shape (vocabulary_size, embed_dim).
      freeze_embedding_layer : bool, default=False
          Training adapts the embedding matrix if `True`, otherwise the embeddings are frozen.
      """
      super().__init__()
  
      self.out_channels = out_channels
      self.in_channels = 1
      self.num_kernels = len(kernel_heights)
      self.pool_sizes = [
          (max_seq_length - k, 1) for k in kernel_heights
      ]
      self.max_seq_length = max_seq_length
      self.num_classes = num_classes
  
      # Assumes vocab size is same as embedding matrix size. Therefore should
      # contain special tokens e.g. <pad>
      self.embedding = nn.Embedding(
          vocabulary_size, embed_dim, padding_idx=padding_idx
      )
  
      if embedding_matrix is not None:
          # Load pre-trained weights. Should be torch FloatTensor
          self.embedding = self.embedding.from_pretrained(
              embedding_matrix.float(), padding_idx=padding_idx
          )
  
      self.embedding.weight.requires_grad = not freeze_embedding_layer
  
      self.convs = nn.ModuleList(
          [
              nn.Conv2d(
                  self.in_channels,
                  self.out_channels,
                  kernel_size=(k, embed_dim),
              )
              for k in kernel_heights
          ]
      )
      self.pools = nn.ModuleList(
          [
              nn.MaxPool2d(kernel_size=pool_size)
              for pool_size in self.pool_sizes
          ]
      )
  
      self.dropout = nn.Dropout(dropout)
      self.fc = nn.Linear(
          self.out_channels * self.num_kernels, self.num_classes
      )
  
imports: from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
label_desc: Use image node_id 1 to create a new KimCNN object from inherited base classes: nn with example: obj = KimCNN(vocabulary_size, max_seq_length, num_classes, out_channels, embed_dim, padding_idx, kernel_heights, dropout, embedding_matrix, freeze_embedding_layer)