code: def test_algorithm_supported_input_mode_with_valid_input_types(
      session,
  ):
      # verify that the Estimator verifies the
      # input mode that an Algorithm supports.
      session.sagemaker_config = {}
  
      file_mode_algo = copy.deepcopy(DESCRIBE_ALGORITHM_RESPONSE)
      file_mode_algo["TrainingSpecification"]["TrainingChannels"] = [
          {
              "Name": "training",
              "Description": "Input channel that provides training data",
              "IsRequired": True,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["File"],
          },
          {
              "Name": "validation",
              "Description": "Input channel that provides validation data",
              "IsRequired": False,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["File", "Pipe"],
          },
      ]
  
      session.sagemaker_client.describe_algorithm = Mock(
          return_value=file_mode_algo
      )
  
      # Creating a File mode Estimator with a File mode algorithm should work
      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,
      )
  
      pipe_mode_algo = copy.deepcopy(DESCRIBE_ALGORITHM_RESPONSE)
      pipe_mode_algo["TrainingSpecification"]["TrainingChannels"] = [
          {
              "Name": "training",
              "Description": "Input channel that provides training data",
              "IsRequired": True,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["Pipe"],
          },
          {
              "Name": "validation",
              "Description": "Input channel that provides validation data",
              "IsRequired": False,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["File", "Pipe"],
          },
      ]
  
      session.sagemaker_client.describe_algorithm = Mock(
          return_value=pipe_mode_algo
      )
  
      # Creating a Pipe mode Estimator with a Pipe mode algorithm should work.
      AlgorithmEstimator(
          algorithm_arn="arn:aws:sagemaker:us-east-2:1234:algorithm/scikit-decision-trees",
          role="SageMakerRole",
          instance_type="ml.m4.xlarge",
          instance_count=1,
          input_mode="Pipe",
          sagemaker_session=session,
      )
  
      any_input_algo = copy.deepcopy(DESCRIBE_ALGORITHM_RESPONSE)
      any_input_algo["TrainingSpecification"]["TrainingChannels"] = [
          {
              "Name": "training",
              "Description": "Input channel that provides training data",
              "IsRequired": True,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["File", "Pipe"],
          },
          {
              "Name": "validation",
              "Description": "Input channel that provides validation data",
              "IsRequired": False,
              "SupportedContentTypes": ["text/csv"],
              "SupportedCompressionTypes": ["None"],
              "SupportedInputModes": ["File", "Pipe"],
          },
      ]
  
      session.sagemaker_client.describe_algorithm = Mock(
          return_value=any_input_algo
      )
  
      # Creating a File mode Estimator with an algorithm that supports both input modes
      # should work.
      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,
      )
  
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 1 for calling a global function with example usage: test_algorithm_supported_input_mode_with_valid_input_types(session) without return types