code: def get_training_image_uri(
      region,
      framework,
      framework_version=None,
      py_version=None,
      image_uri=None,
      distribution=None,
      compiler_config=None,
      tensorflow_version=None,
      pytorch_version=None,
      instance_type=None,
  ) -> str:
      """Retrieves the image URI for training.
  
      Args:
          region (str): The AWS region to use for image URI.
          framework (str): The framework for which to retrieve an image URI.
          framework_version (str): The framework version for which to retrieve an
              image URI (default: None).
          py_version (str): The python version to use for the image (default: None).
          image_uri (str): If an image URI is supplied, it is returned (default: None).
          distribution (dict): A dictionary with information on how to run distributed
              training (default: None).
          compiler_config (:class:`~sagemaker.training_compiler.TrainingCompilerConfig`):
              A configuration class for the SageMaker Training Compiler
              (default: None).
          tensorflow_version (str): The version of TensorFlow to use. (default: None)
          pytorch_version (str): The version of PyTorch to use. (default: None)
          instance_type (str): The instance type to use. (default: None)
  
      Returns:
          str: The image URI string.
      """
  
      if image_uri:
          return image_uri
  
      logger.info(
          "image_uri is not presented, retrieving image_uri based on instance_type, framework etc."
      )
      base_framework_version: Optional[str] = None
  
      if tensorflow_version is not None or pytorch_version is not None:
          processor = _processor(instance_type, ["cpu", "gpu"])
          is_native_huggingface_gpu = (
              processor == "gpu" and not compiler_config
          )
          container_version = (
              "cu110-ubuntu18.04" if is_native_huggingface_gpu else None
          )
          if tensorflow_version is not None:
              base_framework_version = f"tensorflow{tensorflow_version}"
          else:
              base_framework_version = f"pytorch{pytorch_version}"
      else:
          container_version = None
          base_framework_version = None
  
      # Check for smp library
      if distribution is not None:
          if (
              "torch_distributed" in distribution
              and "smdistributed" in distribution
          ):
              if "modelparallel" in distribution["smdistributed"]:
                  if distribution["smdistributed"]["modelparallel"].get(
                      "enabled", True
                  ):
                      framework = "pytorch-smp"
                      if "p5" in instance_type:
                          container_version = "cu121"
                      else:
                          container_version = "cu118"
  
      return retrieve(
          framework,
          region,
          instance_type=instance_type,
          version=framework_version,
          py_version=py_version,
          image_scope="training",
          distribution=distribution,
          base_framework_version=base_framework_version,
          container_version=container_version,
          training_compiler_config=compiler_config,
      )
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os
  import re
  from typing import Optional
  from packaging.version import Version
  from sagemaker import utils
  from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION
  from sagemaker.jumpstart.utils import is_jumpstart_model_input
  from sagemaker.spark import defaults
  from sagemaker.jumpstart import artifacts
  from sagemaker.workflow import is_pipeline_variable
  from sagemaker.workflow.utilities import override_pipeline_parameter_var
  from sagemaker.fw_utils import GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY, GRAVITON_ALLOWED_FRAMEWORKS
label_desc: Use image node_id 20 for calling a global function with example usage: get_training_image_uri(region, framework, framework_version, py_version, image_uri, distribution, compiler_config, tensorflow_version, pytorch_version, instance_type) and returns: retrieve, image_uri