code: def test_pad_and_numericalize(self):
      char_field = CharFeatureField(
          pad_token=VocabMeta.PAD_TOKEN,
          unk_token=VocabMeta.UNK_TOKEN,
          batch_first=True,
          max_word_length=4,
      )
      utterances = [
          [
              ["A", "l", "l", "l"],
              ["u", "r", pad, pad],
              ["b", "@", "$", "s"],
              ["b", "2", pad, pad],
              ["u", "s", pad, pad],
          ],
          [["p", "l", "a", "y", pad], ["m", "u", "s", "i", "c"]],
      ]
      # The padded chars should be sorted by descending length. The commented
      # indices are meant to help relate to the expected_stitch_index.
      expected_padded_chars = [
          [
              ["A", "l", "l", "l"],
              ["u", "r", pad, pad],
              ["b", "@", "$", "s"],
              ["b", "2", pad, pad],
              ["u", "s", pad, pad],
          ],
          [
              ["p", "l", "a", "y"],
              ["m", "u", "s", "i"],
              [pad, pad, pad, pad],
              [pad, pad, pad, pad],
              [pad, pad, pad, pad],
          ],
      ]
  
      minibatch = [char_field.preprocess(x) for x in utterances]
      char_field.build_vocab(minibatch)
  
      # Begin tests for pad().
      padded_minibatch = char_field.pad(minibatch)
      self.assertEqual(padded_minibatch, expected_padded_chars)
  
      # Begin tests for numericalize().
      expected_numericalized_chars = [
          [
              [char_field.vocab.stoi[char] for char in word]
              for word in sent
          ]
          for sent in expected_padded_chars
      ]
      numericalized_minibatch = char_field.numericalize(
          padded_minibatch, device="cpu"
      )
      self.assertEqual(
          numericalized_minibatch.numpy().tolist(),
          expected_numericalized_chars,
      )
  
      precision.FP16_ENABLED = True
      padded_minibatch = char_field.pad(minibatch)
      self.assertTrue(len(padded_minibatch[0]) % 8 == 0)
      precision.FP16_ENABLED = False
  
file_path: pytext/pytext/fields/test/char_field_test.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import unittest
  from collections import Counter
  from pytext.common.constants import VocabMeta
  from pytext.fields.char_field import CharFeatureField
  from pytext.utils import precision
label_desc: Use image node_id 2 for calling the CharFieldTest obj's underlying member method code with example usage: obj.test_pad_and_numericalize() without return types