code: def grapheme_pipeline(char, grapheme_encoder=None, uppercase=True):
      """Encodes a grapheme sequence
  
      Arguments
      ---------
      graphemes: list
          a list of available graphemes
      grapheme_encoder: speechbrain.dataio.encoder.TextEncoder
          a text encoder for graphemes. If not provided,
      takes: str
          the name of the input
      uppercase: bool
          whether or not to convert items to uppercase
  
      Returns
      -------
      grapheme_list: list
          a raw list of graphemes, excluding any non-matching
          labels
      grapheme_encoded_list: list
          a list of graphemes encoded as integers
      grapheme_encoded: torch.Tensor
      """
      if uppercase:
          char = char.upper()
      grapheme_list = [
          grapheme
          for grapheme in char
          if grapheme in grapheme_encoder.lab2ind
      ]
      yield grapheme_list
      grapheme_encoded_list = grapheme_encoder.encode_sequence(
          grapheme_list
      )
      yield grapheme_encoded_list
      grapheme_encoded = torch.LongTensor(grapheme_encoded_list)
      yield grapheme_encoded
  
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 2 for calling a global function with example usage: grapheme_pipeline(char, grapheme_encoder, uppercase) without return types