code: def import_try_install(
      package: str, extern_url: Optional[str] = None
  ):
      """
      Try import the specified package. Modified from gluon cv.
      If the package not installed, try use pip to install and import if success.
  
      Parameters
      ----------
      package
          The name of the package trying to import.
      extern_url
          The external url if package is not hosted on PyPI.
          For example, you can install a package using:
           "pip install git+http://github.com/user/repo/tarball/master/egginfo=xxx".
          In this case, you can pass the url to the extern_url.
  
      Returns
      -------
      <class 'Module'>
          The imported python module.
      """
      import tempfile
  
      import portalocker
  
      lockfile = os.path.join(
          tempfile.gettempdir(), package + "_install.lck"
      )
      with portalocker.Lock(lockfile):
          try:
              return __import__(package)
          except ImportError:
              try:
                  from pip import main as pipmain
              except ImportError:
                  from types import ModuleType
  
                  from pip._internal import main as pipmain
  
                  # fix for pip 19.3
                  if isinstance(pipmain, ModuleType):
                      from pip._internal.main import main as pipmain
  
              # trying to install package
              url = package if extern_url is None else extern_url
              pipmain(
                  ["install", "--user", url]
              )  # will raise SystemExit Error if fails
  
              # trying to load again
              try:
                  return __import__(package)
              except ImportError:
                  import site
                  import sys
  
                  user_site = site.getusersitepackages()
                  if user_site not in sys.path:
                      sys.path.append(user_site)
                  return __import__(package)
      return __import__(package)
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 10 for calling a global function with example usage: import_try_install(package, extern_url) and returns: __import__, __import__, __import__, __import__