code: def enable_eos_bos(tokens, encoder, bos_index, eos_index):
      """
      Initializs the phoneme encoder with EOS/BOS sequences
  
      Arguments
      ---------
      tokens: list
          a list of tokens
      encoder: speechbrain.dataio.encoder.TextEncoder.
          a text encoder instance. If none is provided, a new one
          will be instantiated
      bos_index: int
          the position corresponding to the Beginning-of-Sentence
          token
      eos_index: int
          the position corresponding to the End-of-Sentence
  
      Returns
      -------
      encoder: speechbrain.dataio.encoder.TextEncoder
          an encoder
  
      """
      if encoder is None:
          encoder = sb.dataio.encoder.TextEncoder()
      if bos_index == eos_index:
          if "<eos-bos>" not in encoder.lab2ind:
              encoder.insert_bos_eos(
                  bos_label="<eos-bos>",
                  eos_label="<eos-bos>",
                  bos_index=bos_index,
              )
      else:
          if "<bos>" not in encoder.lab2ind:
              encoder.insert_bos_eos(
                  bos_label="<bos>",
                  eos_label="<eos>",
                  bos_index=bos_index,
                  eos_index=eos_index,
              )
      if "<unk>" not in encoder.lab2ind:
          encoder.add_unk()
      encoder.update_from_iterable(tokens, sequence_input=False)
      return encoder
  
imports: from functools import reduce
  from speechbrain.wordemb.util import expand_to_chars
  import speechbrain
  import torch
  import re
label_desc: Use image node_id 7 for calling a global function with example usage: enable_eos_bos(tokens, encoder, bos_index, eos_index) and returns: encoder