class_docstr: A Conv network to generate word embedding from character embeddings, from
  Character-Aware Neural Language Models, https://arxiv.org/abs/1508.06615.
  
  Components include convolutional filters, pooling, and
  optional highway network. We also have the ability to use pretrained ELMo
  which corresponds to the byte embeddings, CNN weights and the highway layer.
class_docstr_tok: ["A","Conv","network","to","generate","word","embedding","from","character","embeddings",",","from","Character-Aware","Neural","Language","Models",",","https",":","\/\/arxiv.org\/abs\/1508.06615",".","Components","include","convolutional","filters",",","pooling",",","and","optional","highway","network",".","We","also","have","the","ability","to","use","pretrained","ELMo","which","corresponds","to","the","byte","embeddings",",","CNN","weights","and","the","highway","layer","."]
code: def forward(self, char_inds_flat):
      x = self.embed_chars(char_inds_flat)
      encoder_padding_mask = char_inds_flat.eq(self.padding_idx)
      char_lengths = torch.sum(~encoder_padding_mask, dim=0)
      if not encoder_padding_mask.any():
          encoder_padding_mask = None
  
      kernel_outputs = []
      for conv in self.convolutions:
          if encoder_padding_mask is not None:
              x = x.masked_fill(encoder_padding_mask.unsqueeze(-1), 0)
          # conv input: [total_words, char_emb_dim, seq_len]
          # conv output: [total_words, in_channel_dim, seq_len]
          conv_output = conv(x.permute(1, 2, 0))
          kernel_outputs.append(conv_output)
      # Pooling over the entire seq
      pools = [
          self.pooling(conv, char_lengths, dim=2)
          for conv in kernel_outputs
      ]
      # [total_words, sum(output_channel_dim)]
      encoder_output = torch.cat([p for p in pools], 1)
  
      for highway_layer in self.highway_layers:
          encoder_output = highway_layer(encoder_output)
  
      if self.char_cnn_output_dim != -1:
          encoder_output = self.projection(encoder_output)
  
      # (total_words, output_dim)
      return encoder_output
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from pytorch_translate import common_layers, rnn, utils
  from pytorch_translate.data.dictionary import TAGS
  from torch.nn.utils.rnn import pack_padded_sequence
label_desc: Use image node_id 7 for calling the CharCNNModel obj's underlying member method code with example usage: obj.forward(char_inds_flat) and returns: encoder_output