code: def auto_detect_container(
      model, region: str, instance_type: str
  ) -> str:
      """Auto detect the container off of model and instance type"""
  
      logger.info(
          "Autodetecting image since image_uri was not provided in ModelBuilder()"
      )
  
      if not instance_type:
          raise ValueError(
              "Instance type is not specified.\
                  Unable to detect if the container needs to be GPU or CPU."
          )
  
      logger.warning(
          "Auto detection is only supported for single models DLCs with a framework backend."
      )
  
      model_base = _get_model_base(model)
  
      py_tuple = platform.python_version_tuple()
  
      fw, fw_version = _detect_framework_and_version(str(model_base))
      logger.info("Autodetected framework is %s", fw)
      logger.info("Autodetected framework version is %s", fw_version)
  
      casted_versions = (
          _cast_to_compatible_version(fw, fw_version)
          if fw_version
          else (None,)
      )
      dlc = None
  
      for casted_version in casted_versions:
          try:
              dlc = image_uris.retrieve(
                  framework=fw,
                  region=region,
                  version=casted_version,
                  image_scope="inference",
                  py_version=f"py{py_tuple[0]}{py_tuple[1]}",
                  instance_type=instance_type,
              )
              break
          except ValueError:
              pass
  
      if dlc:
          logger.info(
              "Auto detected %s. Proceeding with the the deployment.",
              dlc,
          )
          return dlc
  
      raise ValueError(
          (
              "Unable to auto detect a DLC for framework %s, framework version %s "
              "and python version %s. "
              "Please manually provide image_uri to ModelBuilder()"
          )
          % (fw, f"py{py_tuple[0]}{py_tuple[1]}", fw_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 1 for calling a global function with example usage: auto_detect_container(model, region, instance_type) and returns: dlc