def METHOD_NAME(self, vocab, max_char_len):
    word_to_char = torch.LongTensor(len(vocab), max_char_len)
    truncated = 0
    for i in range(len(vocab)):
        if i < vocab.nspecial:
            char_idxs = [0] * max_char_len
        else:
            chars = vocab[i].encode()
            # +1 for padding
            char_idxs = [c + 1 for c in chars] + [0] * (max_char_len - len(chars))
        if len(char_idxs) > max_char_len:
            truncated += 1
            char_idxs = char_idxs[:max_char_len]
        word_to_char[i] = torch.LongTensor(char_idxs)
    if truncated > 0:
        logger.info(
            "truncated {} words longer than {} characters".format(
                truncated, max_char_len
            )
        )
    self.vocab = vocab
    self.word_to_char = word_to_char