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"]
docstr: IDCNN forward step
  
  Args:
      words (torch.tensor): words
      word_chars (torch.tensor): word character tensors
      shapes (torch.tensor): words shapes
  
  Returns:
      torch.tensor: logits of model
docstr_tok: ["IDCNN","forward","step","Args",":","words","(","torch.tensor",")",":","words","word_chars","(","torch.tensor",")",":","word","character","tensors","shapes","(","torch.tensor",")",":","words","shapes","Returns",":","torch.tensor",":","logits","of","model"]
code: def forward(
      self, words, word_chars, shapes, no_dropout=False, **kwargs
  ):
      """
      IDCNN forward step
  
      Args:
          words (torch.tensor): words
          word_chars (torch.tensor): word character tensors
          shapes (torch.tensor): words shapes
  
      Returns:
          torch.tensor: logits of model
      """
      block_scores = []
      input_features = []
      word_embeds = self.word_embeddings(words)
      shape_embeds = self.shape_embeddings(shapes)
      input_features.extend([word_embeds, shape_embeds])
  
      if self.use_chars:
          char_embeds = self.char_embeddings(word_chars)
          saved_char_size = char_embeds.size()[:2]
          char_embeds = char_embeds.permute(0, 1, 3, 2)
          input_size = char_embeds.size()
          squashed_shape = [-1] + list(input_size[2:])
          char_embeds_reshape = char_embeds.contiguous().view(
              *squashed_shape
          )
          char_embeds = self.char_conv(char_embeds_reshape)
          char_embeds = char_embeds.permute(0, 2, 1)
          char_embeds = F.relu(char_embeds)
          char_embeds, _ = torch.max(
              char_embeds, 1
          )  # global max pooling
          new_size = saved_char_size + char_embeds.size()[1:]
          char_features = char_embeds.contiguous().view(new_size)
          input_features.append(char_features)
  
      features = torch.cat(input_features, 2)
      if not no_dropout:
          features = self.i_drop(features)
  
      features = features.permute(0, 2, 1)
      conv0 = self.conv0(features)
      conv0 = F.relu(conv0)
      conv_layer = conv0
      for _ in range(self.num_blocks):
          conv_outputs = []
          for j in range(len(self.cnv_layers)):
              conv_layer = self.cnv_layers[j](conv_layer)
              conv_layer = F.relu(conv_layer)
              if (
                  j == len(self.cnv_layers) - 1
              ):  # currently use only last layer
                  conv_outputs.append(conv_layer)
          layers_concat = torch.cat(conv_outputs, 1)
          if not no_dropout:
              conv_layer = self.m_drop(
                  layers_concat
              )  # for next block iteration
          else:
              conv_layer = layers_concat
  
          layers_concat = layers_concat.squeeze(2).permute(
              0, 2, 1
          )  # for final block scores
          if not no_dropout:
              block_output = self.h_drop(layers_concat)
          else:
              block_output = layers_concat
          scores = self.dense(block_output)
          block_scores.append(scores)
          logits = block_scores[-1]  # currently use only last block
  
      return logits
  
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 2 for calling the IDCNN obj's underlying member method code with example usage: obj.forward(words, word_chars, shapes, no_dropout) and returns: logits