class_docstr: ID-CNN (iterated dilated) tagging model (based on Strubell et al 2017) with word character
  embedding (using CNN feature extractors)
  
  Args:
      word_vocab_size (int): word vocabulary size
      num_labels (int): number of labels (classifier)
      word_embedding_dims (int, optional): word embedding dims
      shape_vocab_size (int, optional): shape vocabulary size
      shape_embedding_dims (int, optional): shape embedding dims
      char_embedding_dims (int, optional): character embedding dims
      char_cnn_filters (int, optional): character CNN kernel size
      char_cnn_kernel_size (int, optional): character CNN number of filters
      cnn_kernel_size (int, optional): CNN embedder kernel size
      cnn_num_filters (int, optional): CNN embedder number of filters
      input_dropout (float, optional): input layer (embedding) dropout rate
      middle_dropout (float, optional): middle layer dropout rate
      hidden_dropout (float, optional): hidden layer dropout rate
      blocks (int, optinal): number of blocks
      dilations (List, optinal): List of dilations per CNN layer
      embedding_pad_idx (int, optional): padding number for embedding layers
      use_chars (bool, optional): whether to use char embedding, defaults to False
      drop_penalty (float, optional): penalty for dropout regularization
class_docstr_tok: ["ID-CNN","(","iterated","dilated",")","tagging","model","(","based","on","Strubell","et","al","2017",")","with","word","character","embedding","(","using","CNN","feature","extractors",")","Args",":","word_vocab_size","(","int",")",":","word","vocabulary","size","num_labels","(","int",")",":","number","of","labels","(","classifier",")","word_embedding_dims","(","int",",","optional",")",":","word","embedding","dims","shape_vocab_size","(","int",",","optional",")",":","shape","vocabulary","size","shape_embedding_dims","(","int",",","optional",")",":","shape","embedding","dims","char_embedding_dims","(","int",",","optional",")",":","character","embedding","dims","char_cnn_filters","(","int",",","optional",")",":","character","CNN","kernel","size","char_cnn_kernel_size","(","int",",","optional",")",":","character","CNN","number","of","filters","cnn_kernel_size","(","int",",","optional",")",":","CNN","embedder","kernel","size","cnn_num_filters","(","int",",","optional",")",":","CNN","embedder","number","of","filters","input_dropout","(","float",",","optional",")",":","input","layer","(","embedding",")","dropout","rate","middle_dropout","(","float",",","optional",")",":","middle","layer","dropout","rate","hidden_dropout","(","float",",","optional",")",":","hidden","layer","dropout","rate","blocks","(","int",",","optinal",")",":","number","of","blocks","dilations","(","List",",","optinal",")",":","List","of","dilations","per","CNN","layer","embedding_pad_idx","(","int",",","optional",")",":","padding","number","for","embedding","layers","use_chars","(","bool",",","optional",")",":","whether","to","use","char","embedding",",","defaults","to","False","drop_penalty","(","float",",","optional",")",":","penalty","for","dropout","regularization"]
code: def __init__(
      self,
      word_vocab_size: int,
      num_labels: int,
      word_embedding_dims: int = 100,
      shape_vocab_size: int = 4,
      shape_embedding_dims: int = 5,
      char_embedding_dims: int = 16,
      char_cnn_filters: int = 128,
      char_cnn_kernel_size: int = 3,
      cnn_kernel_size: int = 3,
      cnn_num_filters: int = 128,
      input_dropout: float = 0.35,
      middle_dropout: float = 0,
      hidden_dropout: float = 0.15,
      blocks: int = 1,
      dilations: List = None,
      embedding_pad_idx: int = 0,
      use_chars: bool = False,
      drop_penalty: float = 1e-4,
  ):
      super(IDCNN, self).__init__()
      if dilations is None:
          dilations = [1, 2, 1]
      self.num_blocks = blocks
      self.dilation = dilations
      self.use_chars = use_chars
      self.drop_penalty = drop_penalty
      self.num_labels = num_labels
      self.padding_idx = embedding_pad_idx
      self.word_embedding_dim = word_embedding_dims
      self.word_embeddings = nn.Embedding(
          word_vocab_size,
          self.word_embedding_dim,
          padding_idx=self.padding_idx,
      )
      self.shape_embeddings = nn.Embedding(
          shape_vocab_size + 1,
          shape_embedding_dims,
          padding_idx=self.padding_idx,
      )
      padding_word = int(cnn_kernel_size / 2)
      self.char_filters = char_cnn_filters if use_chars else 0
      self.conv0 = nn.Conv1d(
          in_channels=word_embedding_dims
          + shape_embedding_dims
          + self.char_filters,
          out_channels=cnn_num_filters,
          kernel_size=cnn_kernel_size,
          padding=padding_word,
      )
      self.cnv_layers = []
      for i in range(len(self.dilation)):
          self.cnv_layers.append(
              nn.Conv1d(
                  in_channels=cnn_num_filters,
                  out_channels=cnn_num_filters,
                  kernel_size=cnn_kernel_size,
                  padding=padding_word * self.dilation[i],
                  dilation=self.dilation[i],
              )
          )
      self.cnv_layers = nn.ModuleList(self.cnv_layers)
      self.dense = nn.Linear(
          in_features=(cnn_num_filters * self.num_blocks),
          out_features=num_labels,
      )
  
      if use_chars:
          padding_char = int(char_cnn_kernel_size / 2)
          self.char_embeddings = nn.Embedding(
              n_letters + 1,
              char_embedding_dims,
              padding_idx=self.padding_idx,
          )
          self.char_conv = nn.Conv1d(
              in_channels=char_embedding_dims,
              out_channels=self.char_filters,
              kernel_size=char_cnn_kernel_size,
              padding=padding_char,
          )
      self.i_drop = nn.Dropout(input_dropout)
      self.m_drop = nn.Dropout(middle_dropout)
      self.h_drop = nn.Dropout(hidden_dropout)
  
file_path: nlp-architect/nlp_architect/nn/torch/modules/embedders.py
imports: import os
  from typing import List
  import torch
  from torch import nn
  import torch.nn.functional
  from nlp_architect.utils.io import load_json_file
  from nlp_architect.utils.text import n_letters
label_desc: Use image node_id 1 to create a new IDCNN object from inherited base classes: nn with example: obj = IDCNN(word_vocab_size, num_labels, word_embedding_dims, shape_vocab_size, shape_embedding_dims, char_embedding_dims, char_cnn_filters, char_cnn_kernel_size, cnn_kernel_size, cnn_num_filters, input_dropout, middle_dropout, hidden_dropout, blocks, dilations, embedding_pad_idx, use_chars, drop_penalty)