code: def init_custom_parser(modification, transformer=None):
      with open(grammar_file, encoding="utf-8") as f:
          latex_grammar = f.read()
  
      latex_grammar += modification
  
      with tempfile.NamedTemporaryFile() as f:
          f.write(bytes(latex_grammar, encoding="utf8"))
  
          parser = LarkLaTeXParser(
              grammar_file=f.name, transformer=transformer
          )
  
      return parser
  
file_path: sympy/sympy/parsing/tests/test_custom_latex.py
imports: import os
  import tempfile
  import sympy
  from sympy.testing.pytest import raises
  from sympy.parsing.latex.lark import LarkLaTeXParser, TransformToSymPyExpr, parse_latex_lark
  from sympy.external import import_module
label_desc: Use image node_id 1 for calling a global function with example usage: init_custom_parser(modification, transformer) and returns: parser