code: def _cast_to_compatible_version(
      framework: str, fw_version: str
  ) -> Tuple[str]:
      """Given fw_version, detect the available versions"""
      config = image_uris._config_for_framework_and_scope(
          framework, "inference", None
      )
      available_versions = [
          version.parse(ver) for ver in list(config["versions"].keys())
      ]
      available_versions.sort()
  
      earliest_upcast_version = None
      exact_match_version = None
      latest_downcast_version = None
  
      major_version_pattern = r"^(\d+)"
      parsed_fw_version = version.parse(fw_version)
      major_verson = int(
          re.match(major_version_pattern, str(parsed_fw_version)).group(
              1
          )
      )
  
      for available_version in available_versions:
          candidate_major_version = int(
              re.match(
                  major_version_pattern, str(available_version)
              ).group(1)
          )
          if candidate_major_version != major_verson:
              continue
          if available_version < parsed_fw_version:
              latest_downcast_version = available_version
  
          elif available_version == parsed_fw_version:
              exact_match_version = parsed_fw_version
          else:
              earliest_upcast_version = available_version
              break
  
      if (
          not latest_downcast_version
          and not earliest_upcast_version
          and not exact_match_version
      ):
          logger.warning(
              (
                  "Auto detection could not find a compatible DLC version mapped to framework %s, "
                  "framework version %s. The available compatible versions "
                  "are as follows %s."
              ),
              framework,
              fw_version,
              list(config["versions"].keys()),
          )
  
      exact_match_version = _process_version(exact_match_version)
      latest_downcast_version = _process_version(
          latest_downcast_version
      )
      earliest_upcast_version = _process_version(
          earliest_upcast_version
      )
  
      return (
          exact_match_version,
          latest_downcast_version,
          earliest_upcast_version,
      )
  
file_path: sagemaker-python-sdk/src/sagemaker/serve/detector/image_detector.py
imports: from __future__ import absolute_import
  from typing import Tuple, List
  import platform
  import re
  import logging
  from packaging import version
  from sagemaker import image_uris
label_desc: Use image node_id 2 for calling a global function with example usage: _cast_to_compatible_version(framework, fw_version) and returns: exact_match_version,  latest_downcast_version,  earliest_upcast_version