code: def get_pip_packages(run_lambda, patterns=None):
      """Return `pip list` output. Note: will also find conda-installed pytorch and numpy packages."""
      if patterns is None:
          patterns = DEFAULT_PIP_PATTERNS
  
      # People generally have `pip` as `pip` or `pip3`
      # But here it is invoked as `python -mpip`
      def run_with_pip(pip):
          out = run_and_read_all(
              run_lambda, pip + ["list", "--format=freeze"]
          )
          return "\n".join(
              line
              for line in out.splitlines()
              if any(name in line for name in patterns)
          )
  
      pip_version = "pip3" if sys.version[0] == "3" else "pip"
      out = run_with_pip([sys.executable, "-mpip"])
  
      return pip_version, out
  
imports: import datetime
  import locale
  import re
  import subprocess
  import sys
  import os
  from collections import namedtuple
label_desc: Use image node_id 23 for calling a global function with example usage: get_pip_packages(run_lambda, patterns) and returns: pip_version,  out, str