code: def filter_versions(
      versions,
      min_ver,
      max_ver,
      unsupported=None,
      allow_unreleased_max_version=False,
  ):
      """
      Returns the versions that satisfy the following conditions:
      1. Newer than or equal to `min_ver`.
      2. Older than or equal to `max_ver.major`.
      3. Not in `unsupported`.
      """
      unsupported = unsupported or []
      # Prevent specifying non-existent versions
      assert min_ver in versions
      assert max_ver in versions or allow_unreleased_max_version
      assert all(v in versions for v in unsupported)
  
      def _is_not_unsupported(v):
          return v not in unsupported
  
      def _is_older_than_or_equal_to_max_major_version(v):
          return v.major <= max_ver.major
  
      def _is_newer_than_or_equal_to_min_version(v):
          return v >= min_ver
  
      return list(
          functools.reduce(
              lambda vers, f: filter(f, vers),
              [
                  _is_not_unsupported,
                  _is_older_than_or_equal_to_max_major_version,
                  _is_newer_than_or_equal_to_min_version,
              ],
              versions,
          )
      )
  
imports: import argparse
  import functools
  import json
  import os
  import re
  import shutil
  import sys
  import typing
  from collections import defaultdict
  import requests
  import yaml
  from packaging.specifiers import SpecifierSet
  from packaging.version import InvalidVersion
  from packaging.version import Version
  from pydantic import BaseModel, validator
label_desc: Use image node_id 4 for calling a global function with example usage: filter_versions(versions, min_ver, max_ver, unsupported, allow_unreleased_max_version) and returns: list, unknown, unknown, unknown