code: def test_ctc_encoder(tmpdir):
      from speechbrain.dataio.encoder import CTCTextEncoder
  
      encoder = CTCTextEncoder()
      encoder.expect_len(9)  # "abcdef" + bos + eos + blank
      encoder.insert_bos_eos(
          bos_label="<s>", bos_index=0, eos_label="</s>", eos_index=1
      )
      encoder.insert_blank(blank_label="_", index=2)
      encoding_file = tmpdir / "ctc_encoding.txt"
      encoder.update_from_iterable(
          ["abcd", "bcdef"], sequence_input=True
      )
      encoded = encoder.encode_sequence(
          encoder.prepend_bos_label(["a", "b"])
      )
      assert encoded[0] == 0
      encoder.save(encoding_file)
      encoder = CTCTextEncoder()
      encoder.expect_len(9)
      assert encoder.load_if_possible(encoding_file)
      assert (
          "".join(
              encoder.collapse_labels("_bb_aaa___bbbbb_b_eeee_____")
          )
          == "babbe"
      )
      assert "".join(encoder.collapse_labels("babe")) == "babe"
      assert (
          "".join(
              encoder.collapse_labels(
                  "_bb_aaa___bbbbb_b_eeee_____", merge_repeats=False
              )
          )
          == "bbaaabbbbbbeeee"
      )
      assert encoder.decode_ndim(
          (
              encoder.collapse_indices_ndim(
                  [
                      [
                          0,
                          2,
                          4,
                          4,
                          2,
                          3,
                          3,
                          3,
                          2,
                          2,
                          2,
                          4,
                          2,
                          4,
                          2,
                          7,
                          2,
                          1,
                      ],
                      [[0, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]],
                  ]
              )
          )
      ) == [
          ["<s>", "b", "a", "b", "b", "e", "</s>"],
          [["<s>", "a", "b", "c", "d", "c", "b", "a", "</s>"]],
      ]
  
imports: import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_ctc_encoder(tmpdir) without return types