class_docstr: Writes a single pyi file
class_docstr_tok: ["Writes","a","single","pyi","file"]
docstr: Import a referenced message and return a handle
docstr_tok: ["Import","a","referenced","message","and","return","a","handle"]
code: def _import_message(self, type_name: d.FieldDescriptorProto) -> str:
      """Import a referenced message and return a handle"""
      name = cast(str, type_name)
  
      if name[0] == "." and name[1].isupper() and name[2].islower():
          # Message defined in this file
          return name[1:]
  
      message_fd = self.descriptors.message_to_fd[name]
      if message_fd.name == self.fd.name:
          # message defined in this package
          split = name.split(".")
          for i, segment in enumerate(split):
              if (
                  segment
                  and segment[0].isupper()
                  and segment[1].islower()
              ):
                  return ".".join(split[i:])
  
      # Not in package. Must import
      split = name.split(".")
      for i, segment in enumerate(split):
          if segment and segment[0].isupper() and segment[1].islower():
              assert message_fd.name.endswith(".proto")
              import_name = self._import(
                  message_fd.name[:-6].replace("-", "_") + "_pb2",
                  segment,
              )
              remains = ".".join(split[i + 1 :])
              if not remains:
                  return import_name
              raise AssertionError("Don't support nested imports yet")
              # return new_nested_import(import_name, remains)
  
      raise AssertionError("Could not parse local name " + 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 3 for calling the PkgWriter obj's underlying member method code with example usage: obj._import_message(type_name) and returns: name, str, import_name