code: def update_stack(
      stack_name: str,
      template_body: str,
      boto3_session: boto3.session.Session,
      deployment_type: str,
      extra_tags: Optional[List[Tuple[str, str]]],
      parameters: Optional[List] = None,
      update_terminate_agents: bool = True,
  ) -> None:
      cfn = boto3_session.client("cloudformation")
      ec2 = boto3_session.client("ec2")
      update_waiter = cfn.get_waiter("stack_update_complete")
  
      print(
          f"Updating stack {stack_name}. This may take a few minutes... "
          f"Check the CloudFormation Console for updates"
      )
      stack_output = get_output(stack_name, boto3_session)
  
      if update_terminate_agents:
          if stack_uses_spot(stack_name, boto3_session):
              clean_up_spot(
                  stack_name, boto3_session, disable_tqdm=True
              )
          else:
              terminate_running_agents(
                  stack_output[constants.cloudformation.AGENT_TAG_NAME],
                  boto3_session,
              )
  
      if not parameters:
          parameters = []
  
      tags = [
          {
              "Key": constants.defaults.STACK_TAG_KEY,
              "Value": constants.defaults.STACK_TAG_VALUE,
          },
          {
              "Key": constants.deployment_types.TYPE_TAG_KEY,
              "Value": deployment_type,
          },
      ]
      if extra_tags:
          for et in extra_tags:
              tags.append({"Key": et[0], "Value": et[1]})
  
      try:
          cfn.update_stack(
              StackName=stack_name,
              TemplateBody=template_body,
              Parameters=parameters,
              Capabilities=["CAPABILITY_IAM"],
              Tags=tags,
          )
      except ClientError as e:
          if (
              e.response["Error"]["Message"]
              != "No updates are to be performed."
          ):
              raise e
  
          print(e.response["Error"]["Message"])
  
          ec2.start_instances(
              InstanceIds=[
                  stack_output[constants.cloudformation.MASTER_ID]
              ]
          )
          start_waiter = ec2.get_waiter("instance_running")
          start_waiter.wait(
              InstanceIds=[
                  stack_output[constants.cloudformation.MASTER_ID]
              ],
              WaiterConfig={"Delay": 10},
          )
          return
  
      update_waiter.wait(
          StackName=stack_name, WaiterConfig={"Delay": 10}
      )
  
imports: import sys
  import threading
  import time
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import boto3
  import tqdm
  from botocore.exceptions import ClientError, WaiterError
  from determined.deploy.aws import constants
label_desc: Use image node_id 8 for calling a global function with example usage: update_stack(stack_name, template_body, boto3_session, deployment_type, extra_tags, parameters, update_terminate_agents) without return types