code: def forward(
      self, chars, chars_mask, word_orig_idx, sentlens, wordlens
  ):
      embs = self.dropout(self.char_emb(chars))
      batch_size = embs.size(0)
      embs = pack_padded_sequence(embs, wordlens, batch_first=True)
      output = self.charlstm(
          embs,
          wordlens,
          hx=(
              self.charlstm_h_init.expand(
                  self.num_dir * self.args["char_num_layers"],
                  batch_size,
                  self.args["char_hidden_dim"],
              ).contiguous(),
              self.charlstm_c_init.expand(
                  self.num_dir * self.args["char_num_layers"],
                  batch_size,
                  self.args["char_hidden_dim"],
              ).contiguous(),
          ),
      )
  
      # apply attention, otherwise take final states
      if self.attn:
          char_reps = output[0]
          weights = torch.sigmoid(
              self.char_attn(self.dropout(char_reps.data))
          )
          char_reps = PackedSequence(
              char_reps.data * weights, char_reps.batch_sizes
          )
          char_reps, _ = pad_packed_sequence(
              char_reps, batch_first=True
          )
          res = char_reps.sum(1)
      else:
          h, c = output[1]
          res = h[-2:].transpose(0, 1).contiguous().view(batch_size, -1)
  
      # recover character order and word separation
      res = tensor_unsort(res, word_orig_idx)
      res = pack_sequence(res.split(sentlens))
      if self.pad:
          res = pad_packed_sequence(res, batch_first=True)[0]
  
      return res
  
imports: from collections import Counter
  from operator import itemgetter
  import os
  import torch
  import torch.nn
  from torch.nn.utils.rnn import pack_sequence, pad_packed_sequence, pack_padded_sequence, PackedSequence
  from stanza.models.common.data import get_long_tensor
  from stanza.models.common.packed_lstm import PackedLSTM
  from stanza.models.common.utils import open_read_text, tensor_unsort, unsort
  from stanza.models.common.dropout import SequenceUnitDropout
  from stanza.models.common.vocab import UNK_ID, CharVocab
label_desc: Use image node_id 2 for calling the CharacterModel obj's underlying member method code with example usage: obj.forward(chars, chars_mask, word_orig_idx, sentlens, wordlens) and returns: res