code: def tuner_fn(fn_args: FnArgs) -> TunerFnResult:
      """Build the tuner using the KerasTuner API.
  
      Args:
        fn_args: Holds args as name/value pairs.
          - 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.
          - schema_path: optional schema of the input data.
          - transform_graph_path: optional transform graph produced by TFT.
  
      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.
      """
      hp = keras_tuner.HyperParameters()
      # Defines search space.
      hp.Choice("learning_rate", [1e-1, 1e-3])
      hp.Int("num_layers", 1, 5)
  
      # RandomSearch is a subclass of Keras model Tuner.
      tuner = keras_tuner.RandomSearch(
          _build_keras_model,
          max_trials=3,
          hyperparameters=hp,
          allow_new_entries=False,
          objective="val_sparse_categorical_accuracy",
          directory=fn_args.working_dir,
          project_name="test",
      )
  
      schema = schema_pb2.Schema()
      io_utils.parse_pbtxt_file(fn_args.schema_path, schema)
      train_dataset = _input_fn(
          fn_args.train_files, fn_args.data_accessor, schema
      )
      eval_dataset = _input_fn(
          fn_args.eval_files, fn_args.data_accessor, schema
      )
  
      return TunerFnResult(
          tuner=tuner,
          fit_kwargs={
              "x": train_dataset,
              "validation_data": eval_dataset,
              "steps_per_epoch": fn_args.train_steps,
              "validation_steps": fn_args.eval_steps,
          },
      )
  
file_path: tfx/tfx/components/testdata/module_file/tuner_module.py
imports: from typing import List
  import absl
  import keras_tuner
  import tensorflow
  from tensorflow import keras
  from tfx.components.trainer.fn_args_utils import DataAccessor
  from tfx.components.trainer.fn_args_utils import FnArgs
  from tfx.components.tuner.component import TunerFnResult
  from tfx.utils import io_utils
  from tfx_bsl.tfxio import dataset_options
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: tuner_fn(fn_args) and returns: TunerFnResult