class_docstr: Character-level CNN encoder to generate word representations, as input to
  transformer encoder.
code: def __init__(
      self,
      args,
      dictionary,
      embed_tokens,
      num_chars=50,
      embed_dim=32,
      char_cnn_params="[(128, 3), (128, 5)]",
      char_cnn_nonlinear_fn="tanh",
      char_cnn_num_highway_layers=0,
      char_cnn_output_dim=-1,
      use_pretrained_weights=False,
      finetune_pretrained_weights=False,
      weights_file=None,
  ):
      super().__init__(dictionary)
  
      convolutions_params = literal_eval(char_cnn_params)
      self.char_cnn_encoder = char_encoder.CharCNNModel(
          dictionary,
          num_chars,
          embed_dim,
          convolutions_params,
          char_cnn_nonlinear_fn,
          char_cnn_num_highway_layers,
          char_cnn_output_dim,
          use_pretrained_weights,
          finetune_pretrained_weights,
          weights_file,
      )
  
      self.embed_tokens = embed_tokens
      token_embed_dim = embed_tokens.embedding_dim
      self.word_layer_norm = nn.LayerNorm(token_embed_dim)
  
      char_embed_dim = (
          char_cnn_output_dim
          if char_cnn_output_dim != -1
          else sum(out_dim for (out_dim, _) in convolutions_params)
      )
      self.char_layer_norm = nn.LayerNorm(char_embed_dim)
      self.word_dim = char_embed_dim + token_embed_dim
      self.char_scale = math.sqrt(char_embed_dim / self.word_dim)
      self.word_scale = math.sqrt(token_embed_dim / self.word_dim)
      if self.word_dim != args.encoder_embed_dim:
          self.word_to_transformer_embed = fairseq_transformer.Linear(
              self.word_dim, args.encoder_embed_dim
          )
  
      self.dropout = args.dropout
  
      self.padding_idx = dictionary.pad()
      self.embed_positions = fairseq_transformer.PositionalEmbedding(
          1024,
          args.encoder_embed_dim,
          self.padding_idx,
          learned=args.encoder_learned_pos,
      )
  
      self.transformer_encoder_given_embeddings = (
          TransformerEncoderGivenEmbeddings(
              args=args, proj_to_decoder=True
          )
      )
  
      # Variable tracker
      self.tracker = VariableTracker()
      # Initialize adversarial mode
      self.set_gradient_tracking_mode(False)
      self.set_embed_noising_mode(False)
  
      # disables sorting and word-length thresholding if True
      # (enables ONNX tracing of length-sorted input with batch_size = 1)
      self.onnx_export_model = False
  
imports: import logging
  import math
  from ast import literal_eval
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq.models import FairseqEncoder, register_model, register_model_architecture, transformer
  from fairseq.modules import SinusoidalPositionalEmbedding
  from pytorch_translate import char_encoder, transformer, utils, vocab_constants
  from pytorch_translate.char_source_model import verify_pretrain_params
  from pytorch_translate.common_layers import TransformerEncoderGivenEmbeddings, VariableTracker
  from pytorch_translate.data.dictionary import TAGS
label_desc: Use image node_id 1 to create a new CharCNNEncoder object from inherited base classes: FairseqEncoder with example: obj = CharCNNEncoder(args, dictionary, embed_tokens, num_chars, embed_dim, char_cnn_params, char_cnn_nonlinear_fn, char_cnn_num_highway_layers, char_cnn_output_dim, use_pretrained_weights, finetune_pretrained_weights, weights_file)