class_docstr: The character CNN + highway encoder from
  [Kim et al "Character aware neural language models"](https://arxiv.org/abs/1508.06615)
  with an optional projection.
  
  Registered as a `Seq2VecEncoder` with name "cnn-highway".
  
  # Parameters
  
  embedding_dim : `int`, required
      The dimension of the initial character embedding.
  filters : `Sequence[Sequence[int]]`, required
      A sequence of pairs (filter_width, num_filters).
  num_highway : `int`, required
      The number of highway layers.
  projection_dim : `int`, required
      The output dimension of the projection layer.
  activation : `str`, optional (default = `'relu'`)
      The activation function for the convolutional layers.
  projection_location : `str`, optional (default = `'after_highway'`)
      Where to apply the projection layer. Valid values are
      'after_highway', 'after_cnn', and None.
class_docstr_tok: ["The","character","CNN","+","highway","encoder","from","[","Kim","et","al","``","Character","aware","neural","language","models","''","]","(","https",":","\/\/arxiv.org\/abs\/1508.06615",")","with","an","optional","projection",".","Registered","as","a","`","Seq2VecEncoder","`","with","name","``","cnn-highway","''",".","#","Parameters","embedding_dim",":","`","int","`",",","required","The","dimension","of","the","initial","character","embedding",".","filters",":","`","Sequence","[","Sequence","[","int","]","]","`",",","required","A","sequence","of","pairs","(","filter_width",",","num_filters",")",".","num_highway",":","`","int","`",",","required","The","number","of","highway","layers",".","projection_dim",":","`","int","`",",","required","The","output","dimension","of","the","projection","layer",".","activation",":","`","str","`",",","optional","(","default","=","`","'relu","'","`",")","The","activation","function","for","the","convolutional","layers",".","projection_location",":","`","str","`",",","optional","(","default","=","`","'after_highway","'","`",")","Where","to","apply","the","projection","layer",".","Valid","values","are","'after_highway","'",",","'after_cnn","'",",","and","None","."]
docstr: Compute context insensitive token embeddings for ELMo representations.
  
  # Parameters
  
  inputs: `torch.Tensor`
      Shape `(batch_size, num_characters, embedding_dim)`
      Character embeddings representing the current batch.
  mask: `torch.BoolTensor`
      Shape `(batch_size, num_characters)`
      Currently unused. The mask for characters is implicit. See TokenCharactersEncoder.forward.
  
  # Returns
  
  `encoding`:
      Shape `(batch_size, projection_dim)` tensor with context-insensitive token representations.
docstr_tok: ["Compute","context","insensitive","token","embeddings","for","ELMo","representations",".","#","Parameters","inputs",":","`","torch.Tensor","`","Shape","`","(","batch_size",",","num_characters",",","embedding_dim",")","`","Character","embeddings","representing","the","current","batch",".","mask",":","`","torch.BoolTensor","`","Shape","`","(","batch_size",",","num_characters",")","`","Currently","unused",".","The","mask","for","characters","is","implicit",".","See","TokenCharactersEncoder.forward",".","#","Returns","`","encoding","`",":","Shape","`","(","batch_size",",","projection_dim",")","`","tensor","with","context-insensitive","token","representations","."]
code: def forward(
      self, inputs: torch.Tensor, mask: torch.BoolTensor
  ) -> Dict[str, torch.Tensor]:
      """
      Compute context insensitive token embeddings for ELMo representations.
  
      # Parameters
  
      inputs: `torch.Tensor`
          Shape `(batch_size, num_characters, embedding_dim)`
          Character embeddings representing the current batch.
      mask: `torch.BoolTensor`
          Shape `(batch_size, num_characters)`
          Currently unused. The mask for characters is implicit. See TokenCharactersEncoder.forward.
  
      # Returns
  
      `encoding`:
          Shape `(batch_size, projection_dim)` tensor with context-insensitive token representations.
      """
      # convolutions want (batch_size, embedding_dim, num_characters)
      inputs = inputs.transpose(1, 2)
  
      convolutions = []
      for i in range(len(self._convolutions)):
          char_conv_i = getattr(self, f"char_conv_{i}")
          convolved = char_conv_i(inputs)
  
          # (batch_size, n_filters for this width)
          convolved, _ = torch.max(convolved, dim=-1)
          convolved = self._activation(convolved)
          convolutions.append(convolved)
  
      # (batch_size, n_filters)
      token_embedding = torch.cat(convolutions, dim=-1)
  
      if self._projection_location == "after_cnn":
          token_embedding = self._projection(token_embedding)
  
      # apply the highway layers (batch_size, highway_dim)
      token_embedding = self._highways(token_embedding)
  
      if self._projection_location == "after_highway":
          # final projection  (batch_size, projection_dim)
          token_embedding = self._projection(token_embedding)
  
      # Apply layer norm if appropriate
      token_embedding = self._layer_norm(token_embedding)
  
      return token_embedding
  
file_path: allennlp/allennlp/modules/seq2vec_encoders/cnn_highway_encoder.py
imports: from typing import Sequence, Dict, List, Callable
  import torch
  import numpy
  from allennlp.common.checks import ConfigurationError
  from allennlp.modules.layer_norm import LayerNorm
  from allennlp.modules.highway import Highway
  from allennlp.modules.seq2vec_encoders.seq2vec_encoder import Seq2VecEncoder
label_desc: Use image node_id 2 for calling the CnnHighwayEncoder obj's underlying member method code with example usage: obj.forward(inputs, mask) and returns: token_embedding