code: def _create_request_dict(
      job_id,
      region,
      image_uri,
      chief_config,
      worker_count,
      worker_config,
      entry_point_args,
      job_labels,
      service_account,
  ):
      """Creates request dictionary for the CAIP training service."""
      training_input = {}
      training_input["region"] = region
      training_input["scaleTier"] = "custom"
      training_input["masterType"] = gcp.get_machine_type(
          chief_config.cpu_cores,
          chief_config.memory,
          chief_config.accelerator_type,
      )
  
      # Set master config
      chief_machine_config = {}
      chief_machine_config["imageUri"] = image_uri
      chief_machine_config["acceleratorConfig"] = {}
      chief_machine_config["acceleratorConfig"]["count"] = str(
          chief_config.accelerator_count
      )
      chief_machine_config["acceleratorConfig"][
          "type"
      ] = gcp.get_accelerator_type(chief_config.accelerator_type.value)
  
      training_input["masterConfig"] = chief_machine_config
      training_input["workerCount"] = str(worker_count)
  
      if worker_count > 0:
          training_input["workerType"] = gcp.get_machine_type(
              worker_config.cpu_cores,
              worker_config.memory,
              worker_config.accelerator_type,
          )
  
          worker_machine_config = {}
          worker_machine_config["imageUri"] = image_uri
          worker_machine_config["acceleratorConfig"] = {}
          worker_machine_config["acceleratorConfig"]["count"] = str(
              worker_config.accelerator_count
          )
          worker_machine_config["acceleratorConfig"][
              "type"
          ] = gcp.get_accelerator_type(
              worker_config.accelerator_type.value
          )
  
          # AI Platform runtime version spec is required for training
          # on cloud TPUs.
          # Use TF runtime version 2.1 (latest supported) as the default.
          # https://cloud.google.com/ai-platform/training/docs/runtime-version-list#tpu-support  # pylint: disable=line-too-long
          if machine_config.is_tpu_config(worker_config):
              worker_machine_config["tpuTfVersion"] = "2.1"
          training_input["workerConfig"] = worker_machine_config
  
      if entry_point_args is not None:
          training_input["args"] = entry_point_args
  
      # This is temporarily required so that the `TF_CONFIG` generated by
      # CAIP uses the keyword 'chief' instead of 'master'.
      training_input["use_chief_in_tf_config"] = True
      request_dict = {}
      request_dict["jobId"] = job_id
      request_dict["trainingInput"] = training_input
      if job_labels:
          request_dict["labels"] = job_labels
      if service_account:
          training_input["serviceAccount"] = service_account
      return request_dict
  
file_path: cloud/src/python/tensorflow_cloud/core/deploy.py
imports: import subprocess
  import uuid
  from .None import gcp
  from .None import machine_config
  from googleapiclient import discovery
  from googleapiclient import errors
  from ..utils import google_api_client
label_desc: Use image node_id 2 for calling a global function with example usage: _create_request_dict(job_id, region, image_uri, chief_config, worker_count, worker_config, entry_point_args, job_labels, service_account) and returns: request_dict