code: def _get_version(package, use_base_version: bool = False):
      try:
          pkg = importlib.import_module(package)
      except (ModuleNotFoundError, DistributionNotFound):
          return False
      try:
          if hasattr(pkg, "__version__"):
              pkg_version = Version(pkg.__version__)
          else:
              # try pkg_resources to infer version
              pkg_version = Version(
                  pkg_resources.get_distribution(package).version
              )
      except TypeError:
          # this is mocked by Sphinx, so it should return True to generate all summaries
          return True
      if use_base_version:
          pkg_version = Version(pkg_version.base_version)
      return pkg_version
  
file_path: fastNLP/fastNLP/envs/utils.py
imports: import os
  import math
  import time
  from importlib.util import find_spec
  from typing import Callable
  import importlib
  from pkg_resources import DistributionNotFound
  from packaging.version import Version
  import subprocess
  import pkg_resources
label_desc: Use image node_id 2 for calling a global function with example usage: _get_version(package, use_base_version) and returns: pkg_version, False, True