code: def framework_name_from_image(image_uri):
      # noinspection LongLine
      """Extract the framework and Python version from the image name.
  
      Args:
          image_uri (str): Image URI, which should be one of the following forms:
              legacy:
              '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>-<py_ver>-<device>:<container_version>'
              legacy:
              '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>-<py_ver>-<device>:<fw_version>-<device>-<py_ver>'
              current:
              '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>:<fw_version>-<device>-<py_ver>'
              current:
              '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-rl-<fw>:<rl_toolkit><rl_version>-<device>-<py_ver>'
              current:
              '<account>.dkr.ecr.<region>.amazonaws.com/<fw>-<image_scope>:<fw_version>-<device>-<py_ver>'
              current:
              '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-xgboost:<fw_version>-<container_version>'
  
      Returns:
          tuple: A tuple containing:
  
              - str: The framework name
              - str: The Python version
              - str: The image tag
              - str: If the TensorFlow image is script mode
      """
      sagemaker_pattern = re.compile(sagemaker.utils.ECR_URI_PATTERN)
      sagemaker_match = sagemaker_pattern.match(image_uri)
      if sagemaker_match is None:
          return None, None, None, None
  
      # extract framework, python version and image tag
      # We must support both the legacy and current image name format.
      name_pattern = re.compile(
          r"""^(?:sagemaker(?:-rl)?-)?
          (tensorflow|mxnet|chainer|pytorch|pytorch-trcomp|scikit-learn|xgboost
          |huggingface-tensorflow|huggingface-pytorch
          |huggingface-tensorflow-trcomp|huggingface-pytorch-trcomp)(?:-)?
          (scriptmode|training)?
          :(.*)-(.*?)-(py2|py3\d*)(?:.*)$""",
          re.VERBOSE,
      )
      name_match = name_pattern.match(sagemaker_match.group(9))
      if name_match is not None:
          fw, scriptmode, ver, device, py = (
              name_match.group(1),
              name_match.group(2),
              name_match.group(3),
              name_match.group(4),
              name_match.group(5),
          )
          return fw, py, "{}-{}-{}".format(ver, device, py), scriptmode
  
      legacy_name_pattern = re.compile(
          r"^sagemaker-(tensorflow|mxnet)-(py2|py3)-(cpu|gpu):(.*)$"
      )
      legacy_match = legacy_name_pattern.match(sagemaker_match.group(9))
      if legacy_match is not None:
          return (
              legacy_match.group(1),
              legacy_match.group(2),
              legacy_match.group(4),
              None,
          )
  
      # sagemaker-xgboost images are tagged with two aliases, e.g.:
      # 1. Long tag: "315553699071.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1-cpu-py3"
      # 2. Short tag: "315553699071.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1"
      # Note 1: Both tags point to the same image
      # Note 2: Both tags have full GPU capabilities, despite "cpu" delineation in the long tag
      short_xgboost_tag_pattern = re.compile(
          r"^sagemaker-(xgboost):(.*)$"
      )
      short_xgboost_tag_match = short_xgboost_tag_pattern.match(
          sagemaker_match.group(9)
      )
      if short_xgboost_tag_match is not None:
          return (
              short_xgboost_tag_match.group(1),
              "py3",
              short_xgboost_tag_match.group(2),
              None,
          )
      return None, None, None, None
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os
  import re
  import time
  import shutil
  import tempfile
  from collections import namedtuple
  from typing import List, Optional, Union, Dict
  from packaging import version
  import sagemaker.image_uris
  from sagemaker.instance_group import InstanceGroup
  from sagemaker.s3_utils import s3_path_join
  from sagemaker.session_settings import SessionSettings
  import sagemaker.utils
  from sagemaker.workflow import is_pipeline_variable
  from sagemaker.deprecations import renamed_warning, renamed_kwargs
  from sagemaker.workflow.entities import PipelineVariable
  from sagemaker.deprecations import deprecation_warn_base
label_desc: Use image node_id 8 for calling a global function with example usage: framework_name_from_image(image_uri) and returns: None,  None,  None,  None, None,  None,  None,  None, fw,  py,  str,  scriptmode, legacy_match,  legacy_match,  legacy_match,  None, short_xgboost_tag_match,  str,  short_xgboost_tag_match,  None