code: def _submit_job(
      job_spec: Dict[Text, Text],
      project_id: Optional[Text] = None,
  ) -> None:
      """Submits a training job to cloud AI Training .
  
      Args:
          job_spec: AI Platform Training job_spec.
          project_id: Project id where the training should be deployed to.
  
      Raises:
          RuntimeError: If fails to submit the job.
          ValueError: if project id is not provided and can not be retrieved from
          the environment.
      """
      if project_id is None:
          _, project_id = google.auth.default()
  
      if project_id is None:
          raise ValueError(
              "Could not retrieve the Project ID, it must be provided or "
              "pre-configured in the environment."
          )
      project_id = "projects/{}".format(project_id)
  
      # Submit job to AIP Training
      logging.info(
          "Submitting job=%s, project=%s to AI Platform.",
          job_spec["job_id"],
          project_id,
      )
  
      # Configure AI Platform Training job
      # Disabling cache discovery to suppress noisy warning. More details at:
      # https://github.com/googleapis/google-api-python-client/issues/299
      api_client = discovery.build(
          "ml",
          "v1",
          cache_discovery=False,
          requestBuilder=google_api_client.TFCloudHttpRequest,
      )
  
      try:
          request = (
              api_client.projects()
              .jobs()
              .create(body=job_spec, parent=project_id)
          )
          request.execute()
      except Exception as e:
          raise RuntimeError(
              "Submitting job to AI Platform Training failed with error: "
              "{}".format(e)
          )
  
      logging.info(
          "Job submitted successfully to AI Platform Training."
      )
      logging.info(
          "Use gcloud to get the job status or stream logs as follows:"
      )
      logging.info(
          "gcloud ai-platform jobs describe %s/jobs/%s",
          project_id,
          job_spec["job_id"],
      )
      logging.info(
          "gcloud ai-platform jobs stream-logs %s/jobs/%s",
          project_id,
          job_spec["job_id"],
      )
  
file_path: cloud/src/python/tensorflow_cloud/tuner/cloud_fit_client.py
imports: import datetime
  import os
  import pickle
  from typing import Text, Dict, Optional, Sequence, Any, Generator
  from absl import logging
  import google.auth
  from googleapiclient import discovery
  import tensorflow
  from tensorflow_cloud.tuner import cloud_fit_utils
  from tensorflow_cloud.utils import google_api_client
label_desc: Use image node_id 4 for calling a global function with example usage: _submit_job(job_spec, project_id) without return types