docstr: Loads pinyin dict file, and generates a set of all valid symbols.
docstr_tok: ["Loads","pinyin","dict","file",",","and","generates","a","set","of","all","valid","symbols","."]
code: def _parse_as_pinyin_dict(
      phoneme_dict_path: Union[str, pathlib.Path],
      phoneme_prefix: str,
      phoneme_case: str,
  ) -> Dict[str, List[str]]:
      """Loads pinyin dict file, and generates a set of all valid symbols."""
      g2p_dict = defaultdict(list)
      with open(phoneme_dict_path, "r") as file:
          for line in file:
              # skip empty lines and comment lines starting with `;;;`.
              if line.startswith(";;;") or len(line.strip()) == 0:
                  continue
  
              parts = line.split("\t")
              # Convert the cases of Chinese syllables loaded from the dictionary to lowercase to match the lowercase
              # Chinese syllable outputs generated by the function `pypinyin.lazy_pinyin`. Note that the function
              # `pypinyin.lazy_pinyin` preserves the cases of ASCII letters.
              syllable = parts[0].lower()
              pronunciation = set_grapheme_case(
                  parts[1], case=phoneme_case
              ).split()
  
              # add a prefix to distinguish phoneme symbols from non-phoneme symbols.
              pronunciation_with_prefix = [
                  phoneme_prefix + pron for pron in pronunciation
              ]
              g2p_dict[syllable] = pronunciation_with_prefix
  
      return g2p_dict
  
file_path: NeMo/nemo/collections/tts/g2p/models/zh_cn_pinyin.py
imports: import pathlib
  from collections import defaultdict
  from typing import Dict, List, Optional, Union
  from nemo.collections.common.tokenizers.text_to_speech.ipa_lexicon import get_grapheme_character_set
  from nemo.collections.tts.g2p.models.base import BaseG2p
  from nemo.collections.tts.g2p.utils import set_grapheme_case
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling the ChineseG2p obj's underlying member method code with example usage: obj._parse_as_pinyin_dict(phoneme_dict_path, phoneme_prefix, phoneme_case) and returns: g2p_dict