code: def test_algorithm_supported_input_mode_with_bad_input_types(session):
      # verify that the Estimator verifies raises exceptions when
      # attempting to train with an incorrect input type
      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 Pipe mode Estimator with a File mode 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.m4.xlarge",
              instance_count=1,
              input_mode="Pipe",
              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 File mode Estimator with a Pipe mode 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.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 2 for calling a global function with example usage: test_algorithm_supported_input_mode_with_bad_input_types(session) without return types