code: def test_builder_get_input_features(bert_example_builder):
      hyp = "a s t r o n o m e r s _ d i d i e _ s o m o n _ a n d _ t r i s t i a n _ g l l o"
      ref = "d i d i e r _ s a u m o n;a s t r o n o m i e;t r i s t a n _ g u i l l o t;t r i s t e s s e;m o n a d e;c h r i s t i a n;a s t r o n o m e r;s o l o m o n;d i d i d i d i d i;m e r c y"
      targets = [1, 3]
      span_info_parts = ["CUSTOM 12 23", "CUSTOM 28 41"]
  
      gold_tags = [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          0,
          0,
          0,
          0,
          0,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
      ]
      gold_input_ids = [
          101,
          1037,
          1055,
          1056,
          1054,
          1051,
          1050,
          1051,
          1049,
          1041,
          1054,
          1055,
          1035,
          1040,
          1045,
          1040,
          1045,
          1041,
          1035,
          1055,
          1051,
          1049,
          1051,
          1050,
          1035,
          1037,
          1050,
          1040,
          1035,
          1056,
          1054,
          1045,
          1055,
          1056,
          1045,
          1037,
          1050,
          1035,
          1043,
          1048,
          1048,
          1051,
          102,
          1040,
          1045,
          1040,
          1045,
          1041,
          1054,
          1035,
          1055,
          1037,
          1057,
          1049,
          1051,
          1050,
          102,
          1037,
          1055,
          1056,
          1054,
          1051,
          1050,
          1051,
          1049,
          1045,
          1041,
          102,
          1056,
          1054,
          1045,
          1055,
          1056,
          1037,
          1050,
          1035,
          1043,
          1057,
          1045,
          1048,
          1048,
          1051,
          1056,
          102,
          1056,
          1054,
          1045,
          1055,
          1056,
          1041,
          1055,
          1055,
          1041,
          102,
          1049,
          1051,
          1050,
          1037,
          1040,
          1041,
          102,
          1039,
          1044,
          1054,
          1045,
          1055,
          1056,
          1045,
          1037,
          1050,
          102,
          1037,
          1055,
          1056,
          1054,
          1051,
          1050,
          1051,
          1049,
          1041,
          1054,
          102,
          1055,
          1051,
          1048,
          1051,
          1049,
          1051,
          1050,
          102,
          1040,
          1045,
          1040,
          1045,
          1040,
          1045,
          1040,
          1045,
          1040,
          1045,
          102,
          1049,
          1041,
          1054,
          1039,
          1061,
          102,
      ]
      gold_input_mask = [
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
      ]
      gold_segment_ids = [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          3,
          4,
          4,
          4,
          4,
          4,
          4,
          4,
          4,
          4,
          4,
          5,
          5,
          5,
          5,
          5,
          5,
          5,
          6,
          6,
          6,
          6,
          6,
          6,
          6,
          6,
          6,
          6,
          7,
          7,
          7,
          7,
          7,
          7,
          7,
          7,
          7,
          7,
          7,
          8,
          8,
          8,
          8,
          8,
          8,
          8,
          8,
          9,
          9,
          9,
          9,
          9,
          9,
          9,
          9,
          9,
          9,
          9,
          10,
          10,
          10,
          10,
          10,
          10,
      ]
      gold_labels_mask = [
          0,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
      ]
      gold_input_ids_for_subwords = [
          101,
          26357,
          2106,
          2666,
          2061,
          8202,
          1998,
          13012,
          16643,
          2319,
          1043,
          7174,
          102,
          2106,
          3771,
          7842,
          2819,
          2239,
          102,
          28625,
          3630,
          9856,
          102,
          9822,
          26458,
          7174,
          2102,
          102,
          13012,
          13473,
          11393,
          102,
          13813,
          3207,
          102,
          3017,
          102,
          15211,
          102,
          9168,
          102,
          2106,
          28173,
          4305,
          4305,
          102,
          8673,
          102,
      ]
      gold_input_mask_for_subwords = [
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
      ]
      gold_segment_ids_for_subwords = [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          1,
          1,
          1,
          1,
          1,
          1,
          2,
          2,
          2,
          2,
          3,
          3,
          3,
          3,
          3,
          4,
          4,
          4,
          4,
          5,
          5,
          5,
          6,
          6,
          7,
          7,
          8,
          8,
          9,
          9,
          9,
          9,
          9,
          10,
          10,
      ]
      gold_character_pos_to_subword_pos = [
          0,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          2,
          2,
          2,
          3,
          3,
          3,
          4,
          4,
          5,
          5,
          5,
          5,
          6,
          6,
          6,
          6,
          7,
          7,
          7,
          8,
          8,
          8,
          9,
          9,
          9,
          10,
          11,
          11,
          11,
          12,
          13,
          13,
          13,
          14,
          14,
          14,
          14,
          15,
          15,
          16,
          16,
          17,
          17,
          18,
          19,
          19,
          19,
          19,
          19,
          20,
          20,
          21,
          21,
          21,
          22,
          23,
          23,
          23,
          23,
          23,
          23,
          23,
          23,
          24,
          24,
          24,
          25,
          25,
          25,
          26,
          27,
          28,
          28,
          28,
          29,
          29,
          29,
          30,
          30,
          30,
          31,
          32,
          32,
          32,
          32,
          33,
          33,
          34,
          35,
          35,
          35,
          35,
          35,
          35,
          35,
          35,
          35,
          36,
          37,
          37,
          37,
          37,
          37,
          37,
          37,
          37,
          37,
          37,
          38,
          39,
          39,
          39,
          39,
          39,
          39,
          39,
          40,
          41,
          41,
          41,
          42,
          42,
          42,
          43,
          43,
          44,
          44,
          45,
          46,
          46,
          46,
          46,
          46,
          47,
      ]
  
      tags = [0 for _ in hyp.split()]
      for p, t in zip(span_info_parts, targets):
          c, start, end = p.split(" ")
          start = int(start)
          end = int(end)
          tags[start:end] = [t for i in range(end - start)]
  
      # get input features for characters
      (
          input_ids,
          input_mask,
          segment_ids,
          labels_mask,
          labels,
          _,
          _,
      ) = bert_example_builder._get_input_features(
          hyp=hyp, ref=ref, tags=tags
      )
  
      # get input features for words
      hyp_with_words = hyp.replace(" ", "").replace("_", " ")
      ref_with_words = ref.replace(" ", "").replace("_", " ")
      (
          input_ids_for_subwords,
          input_mask_for_subwords,
          segment_ids_for_subwords,
          _,
          _,
          _,
          _,
      ) = bert_example_builder._get_input_features(
          hyp=hyp_with_words, ref=ref_with_words, tags=None
      )
  
      character_pos_to_subword_pos = (
          bert_example_builder._map_characters_to_subwords(
              input_ids, input_ids_for_subwords
          )
      )
  
      assert tags == gold_tags
      assert input_ids == gold_input_ids
      assert input_mask == gold_input_mask
      assert segment_ids == gold_segment_ids
      assert labels_mask == gold_labels_mask
      assert input_ids_for_subwords == gold_input_ids_for_subwords
      assert input_mask_for_subwords == gold_input_mask_for_subwords
      assert segment_ids_for_subwords == gold_segment_ids_for_subwords
      assert (
          character_pos_to_subword_pos
          == gold_character_pos_to_subword_pos
      )
  
file_path: NeMo/tests/collections/nlp/test_spellchecking_asr_customization.py
imports: import pytest
  from transformers import AutoTokenizer
  from nemo.collections.nlp.data.spellchecking_asr_customization.bert_example import BertExampleBuilder
  from nemo.collections.nlp.data.spellchecking_asr_customization.utils import apply_replacements_to_text, substitute_replacements_in_text
label_desc: Use image node_id 7 for calling a global function with example usage: test_builder_get_input_features(bert_example_builder) without return types