class_docstr: ImportApiPackagesTest class. See description at the top of the file.
docstr: Try to import all packages from api packages file one by one.
docstr_tok: ["Try","to","import","all","packages","from","api","packages","file","one","by","one","."]
code: def test_import_runtime(self):
      """Try to import all packages from api packages file one by one."""
      version = "v2"
      failed_packages = []
  
      logging.info("Try to import packages at runtime...")
      for package_name in self.api_packages_v2:
          # Convert package name to the short version:
          # tensorflow._api.v2.distribute.experimental to
          # tensorflow.distribute.experimental
          short_package_name = package_name.replace(
              f"_api.{version}.", ""
          )
          # skip non-importable paths
          if short_package_name not in self.packages_for_skip:
              try:
                  __import__(short_package_name)
              except ImportError:
                  logging.exception(
                      "error importing %s", short_package_name
                  )
                  failed_packages.append(package_name)
  
      if failed_packages:
          self.fail(
              "Failed to import"
              f" {len(failed_packages)}/{len(self.api_packages_v2)} packages"
              f" {version}:\n{failed_packages}"
          )
      logging.info("Import of packages was successful.")
  
imports: import logging
  import unittest
  import pkg_resources
label_desc: Use image node_id 2 for calling the ImportApiPackagesTest obj's underlying member method code with example usage: obj.test_import_runtime() without return types