code: def tuner_fn(
      fn_args: tfx.components.FnArgs,
  ) -> tfx.components.TunerFnResult:
      """Builds a Keras Tuner for the model.
  
      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.
      """
      # RandomSearch is a subclass of kt.Tuner which inherits from
      # BaseTuner.
      tuner = kt.RandomSearch(
          _make_keras_model,
          max_trials=6,
          hyperparameters=_get_hyperparameters(),
          allow_new_entries=False,
          # The model is tuned on the loss computed on the TFX validation dataset.
          objective=kt.Objective("val_loss", "min"),
          directory=fn_args.working_dir,
          project_name="penguin_tuning",
      )
  
      transform_graph = tft.TFTransformOutput(
          fn_args.transform_graph_path
      )
  
      train_dataset = input_fn(
          fn_args.train_files,
          fn_args.data_accessor,
          transform_graph,
          base.TRAIN_BATCH_SIZE,
      )
  
      eval_dataset = input_fn(
          fn_args.eval_files,
          fn_args.data_accessor,
          transform_graph,
          base.EVAL_BATCH_SIZE,
      )
  
      return tfx.components.TunerFnResult(
          tuner=tuner,
          fit_kwargs={
              "x": train_dataset,
              "validation_data": eval_dataset,
          },
      )
  
file_path: tfx/tfx/examples/penguin/penguin_utils_tfdf_experimental.py
imports: from typing import List
  import keras_tuner
  import tensorflow
  import tensorflow_decision_forests
  import tensorflow_transform
  from tfx import v1
  from tfx.examples.penguin import penguin_utils_base
  from tfx_bsl.public import tfxio
label_desc: Use image node_id 4 for calling a global function with example usage: tuner_fn(fn_args) and returns: tfx