class_docstr: Writes a single pyi file
class_docstr_tok: ["Writes","a","single","pyi","file"]
docstr: Imports a stdlib path and returns a handle to it
  eg. self._import("typing", "Optional") -> "Optional"
docstr_tok: ["Imports","a","stdlib","path","and","returns","a","handle","to","it","eg",".","self._import","(","``","typing","''",",","``","Optional","''",")","-",">","``","Optional","''"]
code: def _import(
      self, path: str, name: str, import_as: Optional[str] = None
  ) -> str:
      """Imports a stdlib path and returns a handle to it
      eg. self._import("typing", "Optional") -> "Optional"
      """
      imp = path.replace("/", ".")
      if import_as is not None:
          self.imports[imp].add(f"{name} as {import_as}")
          return import_as
      else:
          self.imports[imp].add(name)
          return name
  
file_path: onnx/tools/protoc-gen-mypy.py
imports: import sys
  from collections import defaultdict
  from contextlib import contextmanager
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, cast
label_desc: Use image node_id 2 for calling the PkgWriter obj's underlying member method code with example usage: obj._import(path, name, import_as) and returns: import_as, name