code: def update_estimator_from_task(estimator, task_id, task_type):
      """Update training job of the estimator from a task in the DAG
  
      Args:
          estimator (sagemaker.estimator.EstimatorBase): The estimator to update
          task_id (str): The task id of any
              airflow.contrib.operators.SageMakerTrainingOperator or
              airflow.contrib.operators.SageMakerTuningOperator that generates
              training jobs in the DAG.
          task_type (str): Whether the task is from SageMakerTrainingOperator or
              SageMakerTuningOperator. Values can be 'training', 'tuning' or None
              (which means training job is not from any task).
      """
      if task_type is None:
          return
      if task_type.lower() == "training":
          training_job = (
              "{{ ti.xcom_pull(task_ids='%s')['Training']['TrainingJobName'] }}"
              % task_id
          )
          job_name = training_job
      elif task_type.lower() == "tuning":
          training_job = (
              "{{ ti.xcom_pull(task_ids='%s')['Tuning']['BestTrainingJob']['TrainingJobName'] }}"
              % task_id
          )
          # need to strip the double quotes in json to get the string
          job_name = (
              "{{ ti.xcom_pull(task_ids='%s')['Tuning']['TrainingJobDefinition']"
              "['StaticHyperParameters']['sagemaker_job_name'].strip('%s') }}"
              % (task_id, '"')
          )
      else:
          raise ValueError(
              "task_type must be either 'training', 'tuning' or None."
          )
      estimator._current_job_name = training_job
      if isinstance(estimator, sagemaker.estimator.Framework):
          update_submit_s3_uri(estimator, job_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 11 for calling a global function with example usage: update_estimator_from_task(estimator, task_id, task_type) without return types