code: def test_variant_traffic_distribution(
      sagemaker_session, multi_variant_endpoint
  ):
      variant_1_invocation_count = 0
      variant_2_invocation_count = 0
  
      for i in range(0, VARIANT_TRAFFIC_SAMPLING_COUNT):
          response = sagemaker_session.sagemaker_runtime_client.invoke_endpoint(
              EndpointName=multi_variant_endpoint.endpoint_name,
              Body=TEST_CSV_DATA,
              ContentType="text/csv",
              Accept="text/csv",
          )
          if response["InvokedProductionVariant"] == TEST_VARIANT_1:
              variant_1_invocation_count += 1
          elif response["InvokedProductionVariant"] == TEST_VARIANT_2:
              variant_2_invocation_count += 1
  
      assert (
          variant_1_invocation_count + variant_2_invocation_count
          == VARIANT_TRAFFIC_SAMPLING_COUNT
      )
  
      variant_1_invocation_percentage = float(
          variant_1_invocation_count
      ) / float(VARIANT_TRAFFIC_SAMPLING_COUNT)
      variant_1_margin_of_error = _compute_and_retrieve_margin_of_error(
          TEST_VARIANT_1_WEIGHT
      )
      assert (
          variant_1_invocation_percentage
          < TEST_VARIANT_1_WEIGHT + variant_1_margin_of_error
      )
      assert (
          variant_1_invocation_percentage
          > TEST_VARIANT_1_WEIGHT - variant_1_margin_of_error
      )
  
      variant_2_invocation_percentage = float(
          variant_2_invocation_count
      ) / float(VARIANT_TRAFFIC_SAMPLING_COUNT)
      variant_2_margin_of_error = _compute_and_retrieve_margin_of_error(
          TEST_VARIANT_2_WEIGHT
      )
      assert (
          variant_2_invocation_percentage
          < TEST_VARIANT_2_WEIGHT + variant_2_margin_of_error
      )
      assert (
          variant_2_invocation_percentage
          > TEST_VARIANT_2_WEIGHT - variant_2_margin_of_error
      )
  
imports: from __future__ import absolute_import
  import json
  import math
  import os
  import pytest
  import scipy.stats
  from sagemaker import image_uris
  from sagemaker.deserializers import CSVDeserializer
  from sagemaker.s3 import S3Uploader
  from sagemaker.session import production_variant
  from sagemaker.sparkml import SparkMLModel
  from sagemaker.utils import unique_name_from_base
  from sagemaker.predictor import Predictor
  from sagemaker.serializers import CSVSerializer
  import tests.integ
label_desc: Use image node_id 4 for calling a global function with example usage: test_variant_traffic_distribution(sagemaker_session, multi_variant_endpoint) without return types