docstr: Main function for Inference. Converts grapheme entries from the manifest "graheme_field" to phonemes
  Args:
      manifest_filepath: Path to .json manifest file
      output_manifest_filepath: Path to .json manifest file to save predictions, will be saved in "target_field"
      grapheme_field: name of the field in manifest_filepath for input grapheme text
      pred_field:  name of the field in the output_file to save predictions
      batch_size: int = 32 # Batch size to use for inference
      num_workers: int = 0 # Number of workers to use for DataLoader during inference
  
  Returns: Predictions generated by the model
docstr_tok: ["Main","function","for","Inference",".","Converts","grapheme","entries","from","the","manifest","``","graheme_field","''","to","phonemes","Args",":","manifest_filepath",":","Path","to",".json","manifest","file","output_manifest_filepath",":","Path","to",".json","manifest","file","to","save","predictions",",","will","be","saved","in","``","target_field","''","grapheme_field",":","name","of","the","field","in","manifest_filepath","for","input","grapheme","text","pred_field",":","name","of","the","field","in","the","output_file","to","save","predictions","batch_size",":","int","=","32","#","Batch","size","to","use","for","inference","num_workers",":","int","=","0","#","Number","of","workers","to","use","for","DataLoader","during","inference","Returns",":","Predictions","generated","by","the","model"]
code: def convert_graphemes_to_phonemes(
      self,
      manifest_filepath: str,
      output_manifest_filepath: str,
      grapheme_field: str = "text_graphemes",
      batch_size: int = 32,
      num_workers: int = 0,
      pred_field: Optional[str] = "pred_text",
  ) -> List[str]:
      """
      Main function for Inference. Converts grapheme entries from the manifest "graheme_field" to phonemes
      Args:
          manifest_filepath: Path to .json manifest file
          output_manifest_filepath: Path to .json manifest file to save predictions, will be saved in "target_field"
          grapheme_field: name of the field in manifest_filepath for input grapheme text
          pred_field:  name of the field in the output_file to save predictions
          batch_size: int = 32 # Batch size to use for inference
          num_workers: int = 0 # Number of workers to use for DataLoader during inference
  
      Returns: Predictions generated by the model
      """
      config = {
          "manifest_filepath": manifest_filepath,
          "grapheme_field": grapheme_field,
          "drop_last": False,
          "shuffle": False,
          "batch_size": batch_size,
          "num_workers": num_workers,
      }
  
      all_preds = self._infer(DictConfig(config))
      with open(manifest_filepath, "r") as f_in:
          with open(
              output_manifest_filepath, "w", encoding="utf-8"
          ) as f_out:
              for i, line in tqdm(enumerate(f_in)):
                  line = json.loads(line)
                  line[pred_field] = all_preds[i]
                  f_out.write(
                      json.dumps(line, ensure_ascii=False) + "\n"
                  )
  
      logging.info(f"Predictions saved to {output_manifest_filepath}.")
      return all_preds
  
imports: import json
  from abc import ABC, abstractmethod
  from contextlib import ExitStack, contextmanager
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig
  from tqdm import tqdm
  from nemo.collections.tts.parts.utils.helpers import OperationMode
  from nemo.core.classes import ModelPT
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types.elements import AudioSignal
  from nemo.core.neural_types.neural_type import NeuralType
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 1 for calling the G2PModel obj's underlying member method code with example usage: obj.convert_graphemes_to_phonemes(manifest_filepath, output_manifest_filepath, grapheme_field, batch_size, num_workers, pred_field) and returns: all_preds