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","."]
docstr: Function to load the weights associated with the pretrained CNN filters.
  For this to work correctly, the cnn params specified in the input arguments
  should match up with the pretrained architecture.
docstr_tok: ["Function","to","load","the","weights","associated","with","the","pretrained","CNN","filters",".","For","this","to","work","correctly",",","the","cnn","params","specified","in","the","input","arguments","should","match","up","with","the","pretrained","architecture","."]
code: def _load_cnn_weights(self):
      """
      Function to load the weights associated with the pretrained CNN filters.
      For this to work correctly, the cnn params specified in the input arguments
      should match up with the pretrained architecture.
      """
      convolutions = []
      for i, (num_filters, kernel_size) in enumerate(
          self.convolutions_params
      ):
          conv = torch.nn.Conv1d(
              in_channels=self.char_embed_dim,
              out_channels=num_filters,
              kernel_size=kernel_size,
              padding=kernel_size,
              bias=True,
          )
  
          weight = self.npz_weights["W_cnn_{}".format(i)]
          bias = self.npz_weights["b_cnn_{}".format(i)]
  
          w_reshaped = np.transpose(
              weight.squeeze(axis=0), axes=(2, 1, 0)
          )
          if w_reshaped.shape != tuple(conv.weight.data.shape):
              raise ValueError("Invalid weight file")
  
          # Load the pretrained weights and bias. In order to ensure the
          # norm of the weights match up with the rest of the model, we need
          # to normalize the pretrained weights. Here we divide by kernel_size
          conv.weight.data.copy_(
              torch.div(
                  torch.FloatTensor(w_reshaped), (kernel_size * 1.0)
              )
          )
          conv.bias.data.copy_(
              torch.div(torch.FloatTensor(bias), (kernel_size * 1.0))
          )
  
          conv.weight.requires_grad = self._finetune_pretrained_weights
          conv.bias.requires_grad = self._finetune_pretrained_weights
  
          convolutions.append(nn.Sequential(conv))
      self.convolutions = nn.ModuleList(convolutions)
  
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 4 for calling the CharCNNModel obj's underlying member method code with example usage: obj._load_cnn_weights() without return types