code: def test_text_encoder(tmpdir):
      from speechbrain.dataio.encoder import TextEncoder
  
      encoder = TextEncoder()
      encoding_file = tmpdir / "text_encoding.txt"
      encoder.add_bos_eos()
      encoder.update_from_iterable(
          [["hello", "world"], ["how", "are", "you", "world"]],
          sequence_input=True,
      )
      encoder.expect_len(7)
      encoded = encoder.encode_sequence(
          encoder.prepend_bos_label(["are", "you", "world"])
      )
      assert encoded[0] == 0
      encoded = encoder.append_eos_index(
          encoder.encode_sequence(["are", "you", "world"])
      )
      assert (
          encoded[-1] == 1
      )  # By default uses just one sentence_boundary marker
      encoder.save(encoding_file)
      encoder = TextEncoder()
      encoder.expect_len(7)
      assert encoder.load_if_possible(encoding_file)
      encoded = encoder.encode_sequence(
          encoder.append_eos_label(["are", "you", "world"])
      )
      assert encoded[-1] == 1
      encoded = encoder.prepend_bos_index(
          encoder.encode_sequence(["are", "you", "world"])
      )
      assert encoded[0] == 0
  
imports: import pytest
label_desc: Use image node_id 5 for calling a global function with example usage: test_text_encoder(tmpdir) without return types