code: def validate_pytorch_distribution(
      distribution,
      framework_name,
      framework_version,
      py_version,
      image_uri,
  ):
      """Check if pytorch distribution strategy is correctly invoked by the user.
  
      Args:
          distribution (dict): A dictionary with information to enable distributed training.
              (Defaults to None if distributed training is not enabled.) For example:
  
              .. code:: python
  
                  {
                      "pytorchddp": {
                          "enabled": True
                      }
                  }
          framework_name (str): A string representing the name of framework selected.
          framework_version (str): A string representing the framework version selected.
          py_version (str): A string representing the python version selected.
          image_uri (str): A string representing a Docker image URI.
  
      Raises:
          ValueError: if
              `py_version` is not python3 or
              `framework_version` is not in PYTORCHDDP_SUPPORTED_FRAMEWORK_VERSIONS
      """
      if framework_name and framework_name != "pytorch":
          # We need to validate only for PyTorch framework
          return
  
      pytorch_ddp_enabled = False
      if "pytorchddp" in distribution:
          pytorch_ddp_enabled = distribution.get("pytorchddp").get(
              "enabled", False
          )
      if not pytorch_ddp_enabled:
          # Distribution strategy other than pytorchddp is selected
          return
  
      err_msg = ""
      if not image_uri:
          # ignore framework_version and py_version if image_uri is set
          # in case image_uri is not set, then both are mandatory
          if (
              framework_version
              not in PYTORCHDDP_SUPPORTED_FRAMEWORK_VERSIONS
          ):
              err_msg += (
                  f"Provided framework_version {framework_version} is not supported by"
                  " pytorchddp.\n"
                  "Please specify one of the supported framework versions:"
                  f" {PYTORCHDDP_SUPPORTED_FRAMEWORK_VERSIONS} \n"
              )
          if "py3" not in py_version:
              err_msg += (
                  f"Provided py_version {py_version} is not supported by pytorchddp.\n"
                  "Please specify py_version>=py3"
              )
      if err_msg:
          raise ValueError(err_msg)
  
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 17 for calling a global function with example usage: validate_pytorch_distribution(distribution, framework_name, framework_version, py_version, image_uri) without return types