code: def prepare_framework(estimator, s3_operations):
      """Prepare S3 operations and environment variables related to framework.
  
      S3 operations specify where to upload `source_dir`.
  
      Args:
          estimator (sagemaker.estimator.Estimator): The framework estimator to
              get information from and update.
          s3_operations (dict): The dict to specify s3 operations (upload
              `source_dir` ).
      """
      if estimator.code_location is not None:
          bucket, key = s3.parse_s3_url(estimator.code_location)
          key = s3.s3_path_join(
              key,
              estimator._current_job_name,
              "source",
              "sourcedir.tar.gz",
          )
      elif estimator.uploaded_code is not None:
          bucket, key = s3.parse_s3_url(
              estimator.uploaded_code.s3_prefix
          )
      else:
          bucket = estimator.sagemaker_session.default_bucket
          key = s3.s3_path_join(
              estimator.sagemaker_session.default_bucket_prefix,
              estimator._current_job_name,
              "source",
              "sourcedir.tar.gz",
          )
  
      script = os.path.basename(estimator.entry_point)
  
      if (
          estimator.source_dir
          and estimator.source_dir.lower().startswith("s3://")
      ):
          code_dir = estimator.source_dir
          estimator.uploaded_code = fw_utils.UploadedCode(
              s3_prefix=code_dir, script_name=script
          )
      else:
          code_dir = "s3://{}/{}".format(bucket, key)
          estimator.uploaded_code = fw_utils.UploadedCode(
              s3_prefix=code_dir, script_name=script
          )
          s3_operations["S3Upload"] = [
              {
                  "Path": estimator.source_dir or estimator.entry_point,
                  "Bucket": bucket,
                  "Key": key,
                  "Tar": True,
              }
          ]
      estimator._hyperparameters[
          sagemaker.model.DIR_PARAM_NAME
      ] = code_dir
      estimator._hyperparameters[
          sagemaker.model.SCRIPT_PARAM_NAME
      ] = script
      estimator._hyperparameters[
          sagemaker.model.CONTAINER_LOG_LEVEL_PARAM_NAME
      ] = estimator.container_log_level
      estimator._hyperparameters[
          sagemaker.model.JOB_NAME_PARAM_NAME
      ] = estimator._current_job_name
      estimator._hyperparameters[
          sagemaker.model.SAGEMAKER_REGION_PARAM_NAME
      ] = estimator.sagemaker_session.boto_region_name
  
imports: from __future__ import print_function, absolute_import
  import os
  import re
  import sagemaker
  from sagemaker import fw_utils, job, utils, s3, session, vpc_utils
  from sagemaker.amazon import amazon_estimator
  from sagemaker.tensorflow import TensorFlow
  from sagemaker.estimator import EstimatorBase
  from sagemaker.processing import Processor
  from sagemaker.utils import format_tags
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_framework(estimator, s3_operations) without return types