code: def get_last_phoneme_info(words_seq, phones_seq):
      """This function takes word and phoneme tiers from a TextGrid file as input
      and provides a list of tuples for the phoneme sequence indicating whether
      each of the phonemes is the last phoneme of a word or not.
  
      Each tuple of the returned list has this format: (phoneme, flag)
  
  
      Arguments
      ---------
      words_seq :
          word tier from a TextGrid file
      phones_seq :
          phoneme tier from a TextGrid file
  
      Returns
      -------
      last_phoneme_flags : list
          each tuple of the returned list has this format: (phoneme, flag)
      """
  
      # Gets all phoneme objects for the entire sequence
      phoneme_objects = phones_seq._objects
      phoneme_iter = iter(phoneme_objects)
  
      # Stores flags to show if an element (phoneme) is a the last phoneme of a word
      last_phoneme_flags = list()
  
      # Matches the end times of the phoneme and word objects to get the last phoneme information
      for word_obj in words_seq._objects:
          word_end_time = word_obj.end_time
  
          current_phoneme = next(phoneme_iter, None)
          while current_phoneme:
              phoneme_end_time = current_phoneme.end_time
              if phoneme_end_time == word_end_time:
                  last_phoneme_flags.append((current_phoneme.text, 1))
                  break
              else:
                  last_phoneme_flags.append((current_phoneme.text, 0))
              current_phoneme = next(phoneme_iter, None)
  
      return last_phoneme_flags
  
imports: import os
  import csv
  import json
  import random
  import logging
  import torch
  import torchaudio
  import numpy
  from tqdm import tqdm
  from speechbrain.utils.data_utils import download_file
  from speechbrain.dataio.dataio import load_pkl, save_pkl
  import tgt
  from speechbrain.inference.text import GraphemeToPhoneme
  import re
  from unidecode import unidecode
  from speechbrain.utils.text_to_sequence import _g2p_keep_punctuations
label_desc: Use image node_id 6 for calling a global function with example usage: get_last_phoneme_info(words_seq, phones_seq) and returns: last_phoneme_flags