code: def tuner_fn(
      fn_args: tfx.components.FnArgs,
  ) -> tfx.components.TunerFnResult:
      """Build the tuner using the CloudTuner API.
  
      Args:
        fn_args: Holds args as name/value pairs. See
          https://www.tensorflow.org/tfx/api_docs/python/tfx/components/trainer/fn_args_utils/FnArgs.
          - transform_graph_path: optional transform graph produced by TFT.
          - custom_config: An optional dictionary passed to the component. In this
            example, it contains the dict ai_platform_tuning_args.
          - working_dir: working dir for tuning.
          - train_files: List of file paths containing training tf.Example data.
          - eval_files: List of file paths containing eval tf.Example data.
          - train_steps: number of train steps.
          - eval_steps: number of eval steps.
  
      Returns:
        A namedtuple contains the following:
          - tuner: A BaseTuner that will be used for tuning.
          - fit_kwargs: Args to pass to tuner's run_trial function for fitting the
                        model , e.g., the training and validation dataset. Required
                        args depend on the above tuner's implementation. For
                        DistributingCloudTuner, we generate datasets at the remote
                        jobs rather than serialize and then deserialize them.
      """
  
      # study_id should be the same across multiple tuner workers which starts
      # approximately at the same time.
      study_id = "DistributingCloudTuner_study_{}".format(
          datetime.datetime.now().strftime("%Y%m%d%H")
      )
  
      if _CLOUD_FIT_IMAGE == "gcr.io/my-project-id/cloud_fit":
          raise ValueError(
              "Build your own cloud_fit image, "
              + "default dummy one is used!"
          )
  
      tuner = cloud_tuner.DistributingCloudTuner(
          _build_keras_model,
          # The project/region configuations for Cloud Vizier service and its trial
          # executions. Note: this example uses the same configuration as the
          # CAIP Training service for distributed tuning flock management to view
          # all of the pipeline's jobs and resources in the same project. It can
          # also be configured separately.
          project_id=fn_args.custom_config["ai_platform_tuning_args"][
              "project"
          ],
          region=fn_args.custom_config["ai_platform_tuning_args"][
              "region"
          ],
          objective=keras_tuner.Objective(
              "val_sparse_categorical_accuracy", "max"
          ),
          hyperparameters=_get_hyperparameters(),
          max_trials=5,  # Optional.
          directory=os.path.join(
              fn_args.custom_config["remote_trials_working_dir"],
              study_id,
          ),
          study_id=study_id,
          container_uri=_CLOUD_FIT_IMAGE,
          # Optional `MachineConfig` that represents the configuration for the
          # general workers in a distribution cluster. More options see:
          # https://github.com/tensorflow/cloud/blob/master/src/python/tensorflow_cloud/core/machine_config.py
          replica_config=machine_config.COMMON_MACHINE_CONFIGS[
              "K80_1X"
          ],
          # Optional total number of workers in a distribution cluster including a
          # chief worker.
          replica_count=2,
      )
  
      return tfx.components.TunerFnResult(
          tuner=tuner,
          fit_kwargs={
              "steps_per_epoch": fn_args.train_steps,
              "validation_steps": fn_args.eval_steps,
              "train_files": fn_args.train_files,
              "eval_files": fn_args.eval_files,
              "transform_graph_path": fn_args.transform_graph_path,
              "label_key": _LABEL_KEY,
              "train_batch_size": _TRAIN_BATCH_SIZE,
              "eval_batch_size": _EVAL_BATCH_SIZE,
          },
      )
  
imports: import datetime
  import os
  from typing import List
  from absl import logging
  import keras_tuner
  import tensorflow
  from tensorflow import keras
  import tensorflow_transform
  import tfx.v1
  from tfx_bsl.public import tfxio
  from tensorflow_cloud.core import machine_config
  from tensorflow_cloud.tuner import tuner
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: tuner_fn(fn_args) and returns: tfx