class_docstr: A decoder that is similar to the HybridRNNDecoder but has a character
  CNN encoder to get the representation for each generated previous token.
  The decoder is similar to https://arxiv.org/pdf/1809.02223.pdf.
class_docstr_tok: ["A","decoder","that","is","similar","to","the","HybridRNNDecoder","but","has","a","character","CNN","encoder","to","get","the","representation","for","each","generated","previous","token",".","The","decoder","is","similar","to","https",":","\/\/arxiv.org\/pdf\/1809.02223.pdf","."]
docstr: Extracts character
  For special words except pad, we put eos, because we actually
  do not need their character sequences.
docstr_tok: ["Extracts","character","For","special","words","except","pad",",","we","put","eos",",","because","we","actually","do","not","need","their","character","sequences","."]
code: def _char_list_for_word(
      self, word_index: int, word: str, char_dict, embed_bytes=False
  ) -> List[int]:
      """
      Extracts character
      For special words except pad, we put eos, because we actually
      do not need their character sequences.
      """
      if word_index == self.dictionary.pad_index:
          char_inds = [char_dict.pad_index]
      elif word_index < self.dictionary.nspecial:
          char_inds = [char_dict.eos_index]
      else:
          if embed_bytes:
              # The byte_id needs to be incremented by 1 to account for the
              # padding id (0) in the embedding table
              char_inds = (
                  [
                      vocab_constants.NUM_BYTE_INDICES
                      + TAGS.index(word)
                      + 1
                  ]
                  if word in TAGS
                  else [
                      byte_id + 1
                      for byte_id in word.encode("utf8", "ignore")
                  ]
              )
          else:
              chars = [word] if word in TAGS else list(word)
              char_inds = [char_dict.index(c) for c in chars]
      return char_inds
  
imports: import math
  from ast import literal_eval
  from typing import List
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq.models import register_model, register_model_architecture
  from pytorch_translate import char_encoder, char_source_hybrid, char_source_model, hybrid_transformer_rnn, transformer, vocab_constants
  from pytorch_translate.data.dictionary import TAGS
  from pytorch_translate.utils import maybe_cuda
label_desc: Use image node_id 8 for calling the CharAwareHybridRNNDecoder obj's underlying member method code with example usage: obj._char_list_for_word(word_index, word, char_dict, embed_bytes) and returns: char_inds