code: def set_installed_packages():
      """Idempotently caches the list of packages installed in the virtualenv.
      Can be run safely before the virtualenv is created, and will be rerun
      afterwards.
      """
      global INSTALLED_PACKAGES, REQUIRED_VERSION
      if INSTALLED_PACKAGES:
          return
  
      if os.path.exists(BIN_PYTHON):
          pip = subprocess.Popen(
              (BIN_PYTHON, "-m", "pip", "freeze"),
              stdout=subprocess.PIPE,
              stderr=subprocess.PIPE,
          )
          (stdout, stderr) = pip.communicate()
          pip.wait()
  
          INSTALLED_PACKAGES = [
              normalize_package_name(r.decode().split("==")[0].lower())
              for r in stdout.split()
          ]
          REQUIRED_VERSION = next(
              (
                  package
                  for package in INSTALLED_PACKAGES
                  if re.match(r"^lore[!<>=]", package)
              ),
              None,
          )
          if REQUIRED_VERSION:
              REQUIRED_VERSION = re.split(r"[!<>=]", REQUIRED_VERSION)[
                  -1
              ]
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  import glob
  import locale
  import os
  import re
  import socket
  import subprocess
  import sys
  import platform
  from io import open
  import pkg_resources
  from lore import ansi
label_desc: Use image node_id 14 for calling a global function with example usage: set_installed_packages() without return types