code: def cloud_fit(
      model: tf.keras.Model,
      remote_dir: Text,
      region: Optional[Text] = None,
      project_id: Optional[Text] = None,
      image_uri: Optional[Text] = None,
      distribution_strategy: Text = DEFAULT_DISTRIBUTION_STRATEGY,
      job_spec: Optional[Dict[str, Any]] = None,
      job_id: Optional[Text] = None,
      **fit_kwargs,
  ) -> Text:
      """Executes in-memory Model and Dataset remotely on AI Platform.
  
      Args:
          model: A compiled Keras Model.
          remote_dir: Google Cloud Storage path for temporary assets and
              AI Platform training output. Will overwrite value in job_spec.
          region: Target region for running the AI Platform Training job.
          project_id: Project id where the training should be deployed to.
          image_uri: based image used to use for AI Platform Training
          distribution_strategy: Specifies the distribution strategy for remote
              execution when a jobspec is provided. Accepted values are strategy
              names as specified by 'tf.distribute.<strategy>.__name__'.
          job_spec: AI Platform Training job_spec, will take precedence over all
              other provided values except for remote_dir. If none is provided a
              default cluster spec and distribution strategy will be used.
          job_id: A name to use for the AI Platform Training job (mixed-case
              letters, numbers, and underscores only, starting with a letter).
          **fit_kwargs: Args to pass to model.fit() including training and eval
              data. Only keyword arguments are supported. Callback functions will
              be serialized as is, they must be available in run time environment.
  
      Returns:
          AI Platform job ID
  
      Raises:
          RuntimeError: If executing in graph mode, eager execution is required
              for cloud_fit.
          NotImplementedError: Tensorflow v1.x is not supported.
      """
      logging.set_verbosity(logging.INFO)
  
      if distribution_strategy not in SUPPORTED_DISTRIBUTION_STRATEGIES:
          raise ValueError(
              "{} is not supported. Supported Strategies are {}".format(
                  distribution_strategy,
                  list(SUPPORTED_DISTRIBUTION_STRATEGIES.keys()),
              )
          )
  
      if cloud_fit_utils.is_tf_v1():
          raise NotImplementedError("Tensorflow v1.x is not supported.")
  
      # Can only export Datasets which were created executing eagerly
      # Raise an error if eager execution is not enabled.
      if not tf.executing_eagerly():
          raise RuntimeError(
              "Eager execution is required for cloud_fit."
          )
  
      if job_spec:
          job_spec["trainingInput"]["args"] = [
              "--remote_dir",
              remote_dir,
              "--distribution_strategy",
              distribution_strategy,
          ]
  
      else:
          job_spec = _default_job_spec(
              region=region,
              image_uri=image_uri,
              entry_point_args=[
                  "--remote_dir",
                  remote_dir,
                  "--distribution_strategy",
                  distribution_strategy,
              ],
          )
  
      _serialize_assets(remote_dir, model, **fit_kwargs)
  
      # Setting AI Platform Training to use chief in TF_CONFIG environment
      # variable.
      # https://cloud.google.com/ai-platform/training/docs/distributed-training-details#chief-versus-master  # pylint: disable=line-too-long
      job_spec["trainingInput"]["useChiefInTfConfig"] = "True"
  
      # If job_id is provided overwrite the job_id value.
      if job_id:
          job_spec["job_id"] = job_id
  
      _submit_job(job_spec, project_id)
      return 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 1 for calling a global function with example usage: cloud_fit(model, remote_dir, region, project_id, image_uri, distribution_strategy, job_spec, job_id) and returns: job_spec