code: def run_fn(fn_args: tfx.components.FnArgs):
      """Train the model based on given args.
  
      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.
          - train_files: List of file paths containing training tf.Example data.
          - eval_files: List of file paths containing eval tf.Example data.
          - data_accessor: Contains factories that can create tf.data.Datasets or
            other means to access the train/eval data. They provide a uniform way of
            accessing data, regardless of how the data is stored on disk.
          - train_steps: number of train steps.
          - eval_steps: number of eval steps.
          - transform_output: A uri to a path containing statistics and metadata
            from TFTransform component. produced by TFT. Will be None if not
            specified.
          - model_run_dir: A single uri for the output directory of model training
            related files.
          - hyperparameters: An optional keras_tuner.HyperParameters config.
      """
      tf_transform_output = tft.TFTransformOutput(
          fn_args.transform_output
      )
      schema = tf_transform_output.transformed_metadata.schema
  
      train_dataset = _input_fn(
          fn_args.train_files,
          fn_args.data_accessor,
          schema,
          batch_size=_TRAIN_BATCH_SIZE,
      )
  
      eval_dataset = _input_fn(
          fn_args.eval_files,
          fn_args.data_accessor,
          schema,
          batch_size=_EVAL_BATCH_SIZE,
      )
  
      if fn_args.hyperparameters:
          hparams = keras_tuner.HyperParameters.from_config(
              fn_args.hyperparameters
          )
      else:
          # This is a shown case when hyperparameters is decided and Tuner is removed
          # from the pipeline. User can also inline the hyperparameters directly in
          # _build_keras_model.
          hparams = _get_hyperparameters()
      logging.info(
          "HyperParameters for training: %s", hparams.get_config()
      )
  
      mirrored_strategy = tf.distribute.MirroredStrategy()
      with mirrored_strategy.scope():
          model = _build_keras_model(hparams)
  
      # Write logs to path
      tensorboard_callback = tf.keras.callbacks.TensorBoard(
          log_dir=fn_args.model_run_dir, update_freq="epoch"
      )
  
      model.fit(
          train_dataset,
          steps_per_epoch=fn_args.train_steps,
          validation_data=eval_dataset,
          validation_steps=fn_args.eval_steps,
          callbacks=[tensorboard_callback],
      )
  
      signatures = {
          "serving_default": _get_tf_examples_serving_signature(
              model, tf_transform_output
          ),
          "transform_features": _get_transform_features_signature(
              model, tf_transform_output
          ),
      }
      model.save(
          fn_args.serving_model_dir,
          save_format="tf",
          signatures=signatures,
      )
  
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 9 for calling a global function with example usage: run_fn(fn_args) without return types