code: def stop_master(
      master_id: str,
      boto3_session: boto3.session.Session,
      delete: bool = False,
  ) -> None:
      ec2 = boto3_session.client("ec2")
      waiter = ec2.get_waiter("instance_stopped")
      try:
          ec2.stop_instances(InstanceIds=[master_id])
      except ClientError as ex:
          if delete:
              error_code = ex.response.get("Error", {}).get("Code")
              if error_code in DELETE_MASTER_IGNORE_ERRORS:
                  print(
                      f"Failed to stop Master Instance: {error_code}. "
                      "This error is ignored as the instance is going to be deleted."
                  )
                  return
  
          raise
  
      ec2.modify_instance_attribute(
          Attribute="disableApiTermination",
          Value="false",
          InstanceId=master_id,
      )
  
      for n in range(NUM_WAITS):
          print("Waiting For Master Instance To Stop")
          try:
              waiter.wait(
                  InstanceIds=[master_id], WaiterConfig={"Delay": 10}
              )
              break
          except WaiterError as e:
              if n == NUM_WAITS - 1:
                  raise e
  
      print("Master Instance Stopped")
  
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 3 for calling a global function with example usage: stop_master(master_id, boto3_session, delete) without return types