code: def freeze_requirements():
      source = env.REQUIREMENTS
  
      print(
          ansi.success("EXECUTE")
          + " "
          + env.BIN_PYTHON
          + " -m pip freeze -r "
          + source
      )
      vcs = split_vcs_lines()
      pip = subprocess.Popen(
          (env.BIN_PYTHON, "-m", "pip", "freeze", "-r", source),
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
      )
      (stdout, stderr) = pip.communicate()
      pip.wait()
  
      restore_vcs_lines(vcs)
  
      present = stdout.decode("utf-8").split(os.linesep)
      errors = stderr.decode("utf-8").split(os.linesep)
      missing = [
          line for line in errors if "package is not installed" in line
      ]
      regex = re.compile(r"contains ([\w\-\_]+)")
      needed = [
          m.group(1).lower()
          for l in missing
          for m in [regex.search(l)]
          if m
      ]
  
      divider = (
          "## The following requirements were added by pip freeze:"
      )
      added_index = (
          present.index(divider) if divider in present else None
      )
      unsafe = None
      if added_index is not None:
          added = present[added_index + 1 : -1]
          present = set(present[0:added_index])
          safe = set()
          unsafe = set()
          for package in added:
              name = package.split("==")[0]
              if re.match(r"^-e.*#egg=" + env.APP, name):
                  unsafe.add(package)
  
              for bad in vcs:
                  if name in bad:
                      unsafe.add(package)
                      continue
  
              if name.lower() in needed:
                  needed.remove(name.lower())
  
              safe.add(package)
          present |= safe
          present -= unsafe
  
      if needed:
          args = [env.BIN_PYTHON, "-m", "pip", "install"] + needed
          print(ansi.success("EXECUTE ") + " ".join(args))
          subprocess.check_call(args)
          return freeze_requirements()
  
      if unsafe:
          if vcs:
              print(
                  ansi.warning()
                  + " Non pypi packages were detected in your "
                  + ansi.underline("requirements.txt")
                  + " that can not be "
                  "completely frozen by pip. "
                  + os.linesep
                  + os.linesep
                  + os.linesep.join(vcs)
              )
  
          print(
              ansi.info()
              + " You should check the following packages in to "
              + ansi.underline("requirements.txt")
              + " or `lore pip uninstall` them"
          )
          if vcs:
              print(
                  ansi.warning("unless")
                  + " they are covered by the previously listed packages"
                  " that pip can not freeze."
              )
          print(os.linesep + os.linesep.join(unsafe) + os.linesep)
  
      with open(source, "w", encoding="utf-8") as f:
          if present:
              f.write(
                  os.linesep.join(
                      sorted(present, key=lambda s: s.lower())
                  ).strip()
                  + os.linesep
              )
          if vcs:
              f.write(os.linesep.join(vcs) + os.linesep)
  
imports: from __future__ import absolute_import, unicode_literals
  import argparse
  import datetime
  import distutils.dir_util
  import glob
  from io import open
  import importlib
  import inspect
  import json
  import logging
  import os
  import platform
  import pkgutil
  import re
  import shutil
  import subprocess
  import sys
  import lore
  from lore import ansi, env, util
  from lore.util import timer, which
label_desc: Use image node_id 44 for calling a global function with example usage: freeze_requirements() and returns: freeze_requirements