def test_create_federated_eval_fns(self, use_test_cd):
    """Test for create_federated_eval_fns."""

    (part_train_eval_fn, part_val_fn, unpart_fn,
     test_fn) = trainer_utils.create_federated_eval_fns(
         tff_model_builder=tff_model_builder,
         metrics_builder=metrics_builder,
         part_train_eval_cd=create_federated_cd(),
         part_val_cd=create_federated_cd(),
         unpart_cd=create_federated_cd(),
         test_cd=create_federated_cd() if use_test_cd else None,
         stat_fns=eval_metric_distribution.ALL_STAT_FNS,
         rounds_per_eval=1,
         part_clients_per_eval=2,
         unpart_clients_per_eval=2,
         test_clients_for_eval=3,
         resample_eval_clients=False,
         eval_clients_random_seed=1)
    keras_model = keras_model_builder_with_zeros()
    model_weights = tff.learning.ModelWeights.from_model(keras_model)
    server_state = tff.learning.framework.ServerState(model_weights, [], [], [])

    expected_keys = [
        f'mean_squared_error/{s}' for s in eval_metric_distribution.ALL_STAT_FNS
    ]

    # Federated validation fn requires a positional arg round_num.
    if use_test_cd:
      self.assertIsNotNone(test_fn)
      eval_fns_to_test = (part_train_eval_fn, part_val_fn, unpart_fn, test_fn)
    else:
      self.assertIsNone(test_fn)
      eval_fns_to_test = (part_train_eval_fn, part_val_fn, unpart_fn)

    for eval_fn in eval_fns_to_test:
      metrics_dict = eval_fn(server_state, 0)
      self.assertEqual(list(metrics_dict.keys()), expected_keys)