code: def stop_aip_training_job(job_id: Text, project_id: Text):
      """Cancels a running AIP Training job.
  
      Args:
          job_id: ID for AIP training job.
          project_id: Project under which the AIP Training job is running.
      """
      job_name = "projects/{}/jobs/{}".format(project_id, job_id)
      # Disable cache_discovery to remove excessive info logs see:
      # https://github.com/googleapis/google-api-python-client/issues/299
      api_client = discovery.build("ml", "v1", cache_discovery=False)
  
      logging.info("Canceling the job %s.", job_name)
  
      request = api_client.projects().jobs().cancel(name=job_name)
  
      try:
          request.execute()
      except errors.HttpError as e:
          if e.resp.status == 400:
              logging.info(
                  # If job is already completed, the request will result in a 400
                  # error with similar to 'description': 'Cannot cancel an already
                  # completed job.' In this case we will absorb the error.
                  "Job %s has already completed.",
                  job_id,
              )
              return
          logging.error("Cancel Request for job %s failed.", job_name)
          raise e
  
imports: import enum
  import json
  import os
  import sys
  import time
  from typing import Dict, Text, Union
  from ..None import version
  from absl import logging
  from googleapiclient import discovery
  from googleapiclient import errors
  from googleapiclient import http
label_desc: Use image node_id 8 for calling a global function with example usage: stop_aip_training_job(job_id, project_id) without return types