code: def word_emb_pipeline(
      txt,
      grapheme_encoded,
      grapheme_encoded_len,
      grapheme_encoder=None,
      word_emb=None,
      use_word_emb=None,
  ):
      """Applies word embeddings, if applicable. This function is meant
      to be used as part of the encoding pipeline
  
      Arguments
      ---------
      txt: str
          the raw text
      grapheme_encoded: torch.tensor
          the encoded graphemes
      grapheme_encoded_len: torch.tensor
          encoded grapheme lengths
      grapheme_encoder: speechbrain.dataio.encoder.TextEncoder
          the text encoder used for graphemes
      word_emb: callable
          the model that produces word embeddings
      use_word_emb: bool
          a flag indicated if word embeddings are to be applied
  
      Returns
      -------
      char_word_emb: torch.tensor
          Word embeddings, expanded to the character dimension
      """
      char_word_emb = None
  
      if use_word_emb:
          raw_word_emb = word_emb().embeddings(txt)
          word_separator_idx = grapheme_encoder.lab2ind[" "]
          char_word_emb = expand_to_chars(
              emb=raw_word_emb.unsqueeze(0),
              seq=grapheme_encoded.unsqueeze(0),
              seq_len=grapheme_encoded_len.unsqueeze(0),
              word_separator=word_separator_idx,
          ).squeeze(0)
  
      return char_word_emb
  
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 23 for calling a global function with example usage: word_emb_pipeline(txt, grapheme_encoded, grapheme_encoded_len, grapheme_encoder, word_emb, use_word_emb) and returns: char_word_emb