code: def _get_final_image_scope(framework, instance_type, image_scope):
      """Return final image scope based on provided framework and instance type."""
      if (
          framework in GRAVITON_ALLOWED_FRAMEWORKS
          and utils.get_instance_type_family(instance_type)
          in GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY
      ):
          return INFERENCE_GRAVITON
      if image_scope is None and framework in (
          XGBOOST_FRAMEWORK,
          SKLEARN_FRAMEWORK,
      ):
          # Preserves backwards compatibility with XGB/SKLearn configs which no
          # longer define top-level "scope" keys after introducing support for
          # Graviton inference. Training and inference configs for XGB/SKLearn are
          # identical, so default to training.
          return "training"
      return image_scope
  
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 7 for calling a global function with example usage: _get_final_image_scope(framework, instance_type, image_scope) and returns: image_scope, INFERENCE_GRAVITON, str