docstr: Parse a python dict object according to the decision on word cases and removal of lexical stress markers.
  
  Args:
      phoneme_dict_obj (Dict[str, List[List[str]]]): a dictionary object.
          e.g. {..., "Wire": [["ˈ", "w", "a", "ɪ", "ɚ"], ["ˈ", "w", "a", "ɪ", "ɹ"]], ...}
  
  Returns:
      g2p_dict (dict): processed dict.
      symbols (set): a IPA phoneme set, or its union with grapheme set.
docstr_tok: ["Parse","a","python","dict","object","according","to","the","decision","on","word","cases","and","removal","of","lexical","stress","markers",".","Args",":","phoneme_dict_obj","(","Dict","[","str",",","List","[","List","[","str","]","]","]",")",":","a","dictionary","object",".","e.g",".","{","...",",","``","Wire","''",":","[","[","``","\u02c8","''",",","``","w","''",",","``","a","''",",","``","\u026a","''",",","``","\u025a","''","]",",","[","``","\u02c8","''",",","``","w","''",",","``","a","''",",","``","\u026a","''",",","``","\u0279","''","]","]",",","...","}","Returns",":","g2p_dict","(","dict",")",":","processed","dict",".","symbols","(","set",")",":","a","IPA","phoneme","set",",","or","its","union","with","grapheme","set","."]
code: def _normalize_dict(
      self, phoneme_dict_obj: Dict[str, List[List[str]]]
  ) -> Tuple[Dict[str, List[List[str]]], Set]:
      """
      Parse a python dict object according to the decision on word cases and removal of lexical stress markers.
  
      Args:
          phoneme_dict_obj (Dict[str, List[List[str]]]): a dictionary object.
              e.g. {..., "Wire": [["ˈ", "w", "a", "ɪ", "ɚ"], ["ˈ", "w", "a", "ɪ", "ɹ"]], ...}
  
      Returns:
          g2p_dict (dict): processed dict.
          symbols (set): a IPA phoneme set, or its union with grapheme set.
  
      """
      g2p_dict = defaultdict(list)
      symbols = set()
      for word, prons in phoneme_dict_obj.items():
          # process word
          # update word cases.
          word_new = set_grapheme_case(word, case=self.grapheme_case)
  
          # add grapheme symbols if `use_chars=True`.
          if self.use_chars:
              # remove punctuations within a word. Punctuations can exist at the start, middle, and end of a word.
              word_no_punct = self.PUNCT_REGEX.sub("", word_new)
  
              # add prefix to distinguish graphemes from phonemes.
              symbols.update(
                  self._prepend_prefix_for_one_word(word_no_punct)
              )
  
          # process IPA pronunciations
          # update phoneme symbols by removing lexical stress markers if `use_stresses=False`.
          prons_new = list()
          if not self.use_stresses:
              for pron in prons:
                  prons_new.append(
                      [
                          symbol
                          for symbol in pron
                          if symbol not in self.STRESS_SYMBOLS
                      ]
                  )
          else:
              prons_new = prons
  
          # update symbols
          for pron in prons_new:
              symbols.update(
                  pron
              )  # This will insert each char individually
  
          # update dict entry
          g2p_dict[word_new] = prons_new
  
          # duplicate word entries if grapheme_case is mixed. Even though grapheme_case is set to mixed, the words in
          # the original input text and the g2p_dict remain unchanged, so they could still be either lowercase,
          # uppercase, or mixed-case as defined in `set_grapheme_case` func. When mapping an uppercase word, e.g.
          # "HELLO", into phonemes using the g2p_dict with {"Hello": [["həˈɫoʊ"]]}, "HELLO" can't find its
          # pronunciations in the g2p_dict due to the case-mismatch of the words. Augmenting the g2p_dict with its
          # uppercase word entry, e.g. {"Hello": [["həˈɫoʊ"]], "HELLO": [["həˈɫoʊ"]]} would provide possibility to
          # find "HELLO"'s pronunciations rather than directly considering it as an OOV.
          if (
              self.grapheme_case == GRAPHEME_CASE_MIXED
              and not word_new.isupper()
          ):
              g2p_dict[word_new.upper()] = prons_new
  
      return g2p_dict, symbols
  
imports: import pathlib
  import random
  import re
  from collections import defaultdict
  from typing import Callable, Dict, List, Optional, Set, Tuple, Union
  from nemo.collections.common.tokenizers.text_to_speech.ipa_lexicon import validate_locale
  from nemo.collections.common.tokenizers.text_to_speech.tokenizer_utils import LATIN_CHARS_ALL, any_locale_word_tokenize, english_word_tokenize, normalize_unicode_text
  from nemo.collections.tts.g2p.models.base import BaseG2p
  from nemo.collections.tts.g2p.utils import GRAPHEME_CASE_MIXED, GRAPHEME_CASE_UPPER, set_grapheme_case
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 6 for calling the IpaG2p obj's underlying member method code with example usage: obj._normalize_dict(phoneme_dict_obj) and returns: g2p_dict,  symbols