code: def _validate_version_and_set_if_needed(version, config, framework):
      """Checks if the framework/algorithm version is one of the supported versions."""
      available_versions = list(config["versions"].keys())
      aliased_versions = list(config.get("version_aliases", {}).keys())
  
      if (
          len(available_versions) == 1
          and version not in aliased_versions
      ):
          log_message = "Defaulting to the only supported framework/algorithm version: {}.".format(
              available_versions[0]
          )
          if version and version != available_versions[0]:
              logger.warning(
                  "%s Ignoring framework/algorithm version: %s.",
                  log_message,
                  version,
              )
          elif not version:
              logger.info(log_message)
  
          return available_versions[0]
  
      if version is None and framework in [
          DATA_WRANGLER_FRAMEWORK,
          HUGGING_FACE_LLM_FRAMEWORK,
          STABILITYAI_FRAMEWORK,
      ]:
          version = _get_latest_versions(available_versions)
  
      _validate_arg(
          version,
          available_versions + aliased_versions,
          "{} version".format(framework),
      )
      return version
  
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 11 for calling a global function with example usage: _validate_version_and_set_if_needed(version, config, framework) and returns: version, available_versions