code: def _create_and_fit_estimator(
      sagemaker_session, tf_version, py_version, instance_type
  ):
      estimator = TensorFlow(
          entry_point=SCRIPT,
          source_dir=MNIST_RESOURCE_PATH,
          role=ROLE,
          instance_count=2,
          instance_type=instance_type,
          sagemaker_session=sagemaker_session,
          framework_version=tf_version,
          py_version=py_version,
          distribution=PARAMETER_SERVER_DISTRIBUTION,
          disable_profiler=True,
      )
      inputs = estimator.sagemaker_session.upload_data(
          path=os.path.join(MNIST_RESOURCE_PATH, "data"),
          key_prefix="scriptmode/distributed_mnist",
      )
  
      with tests.integ.timeout.timeout(
          minutes=tests.integ.TRAINING_DEFAULT_TIMEOUT_MINUTES
      ):
          estimator.fit(
              inputs=inputs,
              job_name=unique_name_from_base("test-tf-sm-distributed"),
          )
      assert_s3_file_patterns_exist(
          sagemaker_session,
          estimator.model_dir,
          [r"model\.ckpt-\d+\.index", r"checkpoint"],
      )
  
imports: from __future__ import absolute_import
  import numpy
  import os
  import time
  import pytest
  from sagemaker.serverless import ServerlessInferenceConfig
  from sagemaker.tensorflow import TensorFlow, TensorFlowProcessor, TensorFlowModel
  from sagemaker.utils import unique_name_from_base, sagemaker_timestamp
  import tests.integ
  from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES, kms_utils, timeout
  from tests.integ.retry import retries
  from tests.integ.utils import gpu_list, retry_with_instance_list
  from tests.integ.s3_utils import assert_s3_file_patterns_exist
  from packaging.version import Version
label_desc: Use image node_id 7 for calling a global function with example usage: _create_and_fit_estimator(sagemaker_session, tf_version, py_version, instance_type) without return types