code: def get_public_api(
      api_mapping_files: Sequence[str],
      file_prefixes_to_strip: Sequence[str],
      packages_to_ignore: Sequence[str],
      output_package: str,
      module_prefix: str,
  ) -> PublicAPI:
      """Generates the structure of the public API from the given files.
  
      Args:
        api_mapping_files: List of files containing the exported API mappings and
          docstrings.
        file_prefixes_to_strip: A list of prefixes to strip from files when
          determining the packages to ignore.
        packages_to_ignore: A list of python packages that should be ignored when
          searching for tf_exports.
        output_package: The package to use for the imports.
        module_prefix: A prefix to add to the non-generated imports.
  
      Raises:
        DocExportedTwiceError: Two docstrings are registered for the same module.
  
      Returns:
        The public API structure.
      """
      ea = exported_api.ExportedApi()
      for f in api_mapping_files:
          ea.read(f)
  
      v1_entrypoints_by_module = collections.defaultdict(set)
      v2_entrypoints_by_module = collections.defaultdict(set)
  
      def add_exported_symbols(
          api_names: list[str],
          s: exported_api.ExportedSymbol,
          entrypoints_by_module: Mapping[str, set[_Entrypoint]],
      ):
          for api_name in api_names:
              index_of_last_dot = api_name.rfind(".")
              index_of_first_dot = api_name.find(".")
              module = output_package
              if index_of_first_dot + 1 < index_of_last_dot:
                  module += f".{api_name[index_of_first_dot + 1:index_of_last_dot]}"
              name = api_name[index_of_last_dot + 1 :]
              entrypoints_by_module[module].add(
                  _Entrypoint(module, name, s)
              )
  
      for s in ea.symbols:
          if _should_skip_file(
              s.file_name,
              file_prefixes_to_strip,
              packages_to_ignore,
              module_prefix,
          ):
              continue
          add_exported_symbols(s.v1_apis, s, v1_entrypoints_by_module)
          add_exported_symbols(s.v2_apis, s, v2_entrypoints_by_module)
  
      v1_generated_imports_by_module = collections.defaultdict(set)
      v2_generated_imports_by_module = collections.defaultdict(set)
  
      def add_generated_imports(
          entrypoints_by_module: Mapping[str, set[_Entrypoint]],
          generated_imports_by_module: Mapping[str, set[str]],
      ):
          for module in entrypoints_by_module:
              i = module.rfind(".")
              if i == -1:
                  continue
              while i != -1:
                  parent = module[:i]
                  generated_imports_by_module[parent].add(module)
                  module = parent
                  i = module.rfind(".")
  
      add_generated_imports(
          v1_entrypoints_by_module, v1_generated_imports_by_module
      )
      add_generated_imports(
          v2_entrypoints_by_module, v2_generated_imports_by_module
      )
  
      docs_by_module = {}
  
      for d in ea.docs:
          for m in d.modules:
              if m in docs_by_module:
                  raise DocExportedTwiceError(
                      f"Docstring at {d.file_name}:{d.line_no} is registered for {m},"
                      " which already has a registered docstring."
                  )
              docs_by_module[m] = d.docstring
  
      return PublicAPI(
          v1_entrypoints_by_module=v1_entrypoints_by_module,
          v2_entrypoints_by_module=v2_entrypoints_by_module,
          v1_generated_imports_by_module=v1_generated_imports_by_module,
          v2_generated_imports_by_module=v2_generated_imports_by_module,
          docs_by_module=docs_by_module,
      )
  
imports: import collections
  from collections.abc import Mapping, Sequence, Set
  import dataclasses
  import os
  from typing import Optional
  from absl import app
  from absl import flags
  from tensorflow.python.tools.api.generator2.shared import exported_api
label_desc: Use image node_id 5 for calling a global function with example usage: get_public_api(api_mapping_files, file_prefixes_to_strip, packages_to_ignore, output_package, module_prefix) and returns: PublicAPI