def character_cnn(char_ids, num_chars=char_utils.NUM_CHARS, emb_size=32,
                  kernel_width=5, num_filters=100):
  """A character-level convolutional neural network with max-pooling.

  Args:
    char_ids: tensor<int32> [batch_size, ..., max_word_length]
    num_chars: The maximum number of character ids.
    emb_size: An integer indicating the size of each character embedding.
    kernel_width: An integer indicating the size of the kernel for the
        convolution filters.
    num_filters: An integer indicating the number of filters to use.

  Returns:
    pooled_emb: A tf.float32 Tensor of shape
        [batch_size, ..., num_filters] representing the filters
        after max-pooling over the positions in each word.
  """
  char_ids, flatten = tensor_utils.flatten(char_ids)
  embeddings = tf.get_variable(
      "char_emb", [num_chars, emb_size],
      initializer=tf.truncated_normal_initializer(stddev=0.1))
  char_emb = tf.nn.embedding_lookup(embeddings, char_ids)
  conv_emb = tf.layers.conv1d(char_emb, num_filters, kernel_width)
  pooled_emb = tf.reduce_max(conv_emb, -2)
  pooled_emb = flatten(pooled_emb)
  return pooled_emb
A character-level convolutional neural network with max-pooling.

  Args:
    char_ids: tensor<int32> [batch_size, ..., max_word_length]
    num_chars: The maximum number of character ids.
    emb_size: An integer indicating the size of each character embedding.
    kernel_width: An integer indicating the size of the kernel for the
        convolution filters.
    num_filters: An integer indicating the number of filters to use.

  Returns:
    pooled_emb: A tf.float32 Tensor of shape
        [batch_size, ..., num_filters] representing the filters
        after max-pooling over the positions in each word.
  
language/common/layers/common_layers.py