code: def test_algorithm_distributed_training_validation(session):
      session.sagemaker_config = {}
      distributed_algo = copy.deepcopy(DESCRIBE_ALGORITHM_RESPONSE)
      distributed_algo["TrainingSpecification"][
          "SupportsDistributedTraining"
      ] = True
  
      single_instance_algo = copy.deepcopy(DESCRIBE_ALGORITHM_RESPONSE)
      single_instance_algo["TrainingSpecification"][
          "SupportsDistributedTraining"
      ] = False
  
      session.sagemaker_client.describe_algorithm = Mock(
          return_value=distributed_algo
      )
  
      # Distributed training should work for Distributed and Single instance.
      AlgorithmEstimator(
          algorithm_arn="arn:aws:sagemaker:us-east-2:1234:algorithm/scikit-decision-trees",
          role="SageMakerRole",
          instance_type="ml.m4.xlarge",
          instance_count=1,
          sagemaker_session=session,
      )
  
      AlgorithmEstimator(
          algorithm_arn="arn:aws:sagemaker:us-east-2:1234:algorithm/scikit-decision-trees",
          role="SageMakerRole",
          instance_type="ml.m4.xlarge",
          instance_count=2,
          sagemaker_session=session,
      )
  
      session.sagemaker_client.describe_algorithm = Mock(
          return_value=single_instance_algo
      )
  
      # distributed training on a single instance algorithm should fail.
      with pytest.raises(ValueError):
          AlgorithmEstimator(
              algorithm_arn="arn:aws:sagemaker:us-east-2:1234:algorithm/scikit-decision-trees",
              role="SageMakerRole",
              instance_type="ml.m5.2xlarge",
              instance_count=2,
              sagemaker_session=session,
          )
  
imports: from __future__ import absolute_import
  import copy
  import datetime
  import pytest
  from mock import Mock, patch
  from sagemaker.algorithm import AlgorithmEstimator
  from sagemaker.estimator import _TrainingJob
  from sagemaker.transformer import Transformer
label_desc: Use image node_id 7 for calling a global function with example usage: test_algorithm_distributed_training_validation(session) without return types