code: def logging_callback(spec: Dict[str, Any], project_id: str):
      """Returns a callback of the format required by the GCloud REST api's job
      creation endpoint. The returned function accepts:
  
      - a request_id
      - a Job object, in case the request succeeds:
        https://cloud.google.com/ml-engine/reference/rest/v1/projects.jobs#Job
      - an exception if the request fails.
  
      """
      job_id = spec["jobId"]
  
      def callback(_, exception):
          logging.debug("spec for job {}: {}".format(job_id, spec))
          prefix = "Request for job '{}'".format(spec["jobId"])
  
          if exception is None:
              url = job_url(project_id, job_id)
              stream_command = _stream_cmd(job_id)
  
              logging.info(t.green("{} succeeded!".format(prefix)))
              logging.info(t.green("Job URL: {}".format(url)))
              logging.info(
                  t.green(
                      "Streaming log CLI command: $ {}".format(
                          stream_command
                      )
                  )
              )
          else:
              logging.error(t.red("{} failed! Details:".format(prefix)))
              logging.error(t.red(exception._get_reason()))
  
      return callback
  
imports: from __future__ import absolute_import, division, print_function
  import datetime
  import traceback
  from copy import deepcopy
  from pprint import pformat
  from typing import Any, Dict, Iterable, List, Optional, Tuple
  import tqdm
  from absl import logging
  from blessings import Terminal
  from googleapiclient import discovery
  from googleapiclient.errors import HttpError
  import caliban.config
  import caliban.config.experiment
  import caliban.docker.build
  import caliban.docker.push
  import caliban.history.types
  import caliban.platform.cloud.types
  import caliban.platform.cloud.util
  import caliban.util
  import caliban.util.auth
  import caliban.util.metrics
  import caliban.util.tqdm
  from caliban.history.util import create_experiments, generate_container_spec, get_mem_engine, get_sql_engine, session_scope
label_desc: Use image node_id 4 for calling a global function with example usage: logging_callback(spec, project_id) and returns: callback