code: def generate(self, filename: str) -> None:
      self.collect_rules()
      header = self.grammar.metas.get("header", MODULE_PREFIX)
      if header is not None:
          basename = os.path.basename(filename)
          self.print(header.rstrip("\n").format(filename=basename))
      subheader = self.grammar.metas.get("subheader", "")
      if subheader:
          self.print(subheader)
      cls_name = self.grammar.metas.get("class", "GeneratedParser")
      self.print(
          "# Keywords and soft keywords are listed at the end of the parser definition."
      )
      self.print(f"class {cls_name}(Parser):")
      for rule in self.all_rules.values():
          self.print()
          with self.indent():
              self.visit(rule)
  
      self.print()
      with self.indent():
          self.print(f"KEYWORDS = {tuple(self.keywords)}")
          self.print(f"SOFT_KEYWORDS = {tuple(self.soft_keywords)}")
  
      trailer = self.grammar.metas.get(
          "trailer", MODULE_SUFFIX.format(class_name=cls_name)
      )
      if trailer is not None:
          self.print(trailer.rstrip("\n"))
  
imports: import os.path
  import token
  from typing import IO, Any, Dict, Optional, Sequence, Set, Text, Tuple
  from pegen import grammar
  from pegen.grammar import Alt, Cut, Forced, Gather, GrammarVisitor, Group, Lookahead, NamedItem, NameLeaf, NegativeLookahead, Opt, PositiveLookahead, Repeat0, Repeat1, Rhs, Rule, StringLeaf
  from pegen.parser_generator import ParserGenerator
label_desc: Use image node_id 2 for calling the PythonParserGenerator obj's underlying member method code with example usage: obj.generate(filename) without return types