code: def add_cnn_char_repr(self, nchars=101, dim=25, nfilters=25, pad=2):
      self._char_cnn_added = True
  
      with tf.compat.v1.device("/gpu:{}".format(self.use_gpu_device)):
          with tf.compat.v1.variable_scope("char_repr_cnn"):
              # 1. Lookup for character embeddings
              char_range = math.sqrt(3 / dim)
              embeddings = tf.compat.v1.get_variable(
                  name="char_embeddings",
                  dtype=tf.float32,
                  shape=[nchars, dim],
                  initializer=tf.compat.v1.random_uniform_initializer(
                      -char_range, char_range
                  ),
                  use_resource=False,
              )
  
              # shape = (batch, sentence, word_len, embeddings dim)
              char_embeddings = tf.nn.embedding_lookup(
                  params=embeddings, ids=self.char_ids
              )
              # char_embeddings = tf.nn.dropout(char_embeddings, self.dropout)
              s = tf.shape(input=char_embeddings)
  
              # shape = (batch x sentence, word_len, embeddings dim)
              char_embeddings = tf.reshape(
                  char_embeddings, shape=[-1, s[-2], dim]
              )
  
              # batch x sentence, word_len, nfilters
              conv1d = tf.keras.layers.Conv1D(
                  filters=nfilters,
                  kernel_size=[3],
                  padding="same",
                  activation=tf.nn.relu,
              )(char_embeddings)
  
              # Max across each filter, shape = (batch x sentence, nfilters)
              char_repr = tf.reduce_max(
                  input_tensor=conv1d, axis=1, keepdims=True
              )
              char_repr = tf.squeeze(char_repr, axis=[1])
  
              # (batch, sentence, nfilters)
              char_repr = tf.reshape(
                  char_repr, shape=[s[0], s[1], nfilters]
              )
  
              if self.word_repr is not None:
                  self.word_repr = tf.concat(
                      [self.word_repr, char_repr], axis=-1
                  )
              else:
                  self.word_repr = char_repr
  
imports: import math
  import random
  import sys
  import numpy
  import tensorflow
  from .sentence_grouper import SentenceGrouper
  from ..tf2contrib import *
label_desc: Use image node_id 3 for calling the NerModel obj's underlying member method code with example usage: obj.add_cnn_char_repr(nchars, dim, nfilters, pad) without return types