code: def test_evaluation_log_hook(pd_df, tmp):
      data, users, items = pd_df
  
      # Run hook 10 times
      hook_frequency = 10
      train_steps = 10
  
      _, deep_columns = build_feature_columns(
          users, items, model_type="deep"
      )
  
      model = build_model(
          tmp,
          deep_columns=deep_columns,
          save_checkpoints_steps=train_steps // hook_frequency,
      )
  
      evaluation_logger = MetricsLogger()
  
      # Train a model w/ the hook
      hooks = [
          evaluation_log_hook(
              model,
              logger=evaluation_logger,
              true_df=data,
              y_col=DEFAULT_RATING_COL,
              eval_df=data.drop(DEFAULT_RATING_COL, axis=1),
              every_n_iter=train_steps // hook_frequency,
              model_dir=tmp,
              eval_fns=[rmse],
          )
      ]
      model.train(
          input_fn=pandas_input_fn(
              df=data,
              y_col=DEFAULT_RATING_COL,
              batch_size=1,
              num_epochs=None,
              shuffle=True,
          ),
          hooks=hooks,
          steps=train_steps,
      )
  
      # Check if hook logged the given metric
      assert rmse.__name__ in evaluation_logger.get_log()
      assert (
          len(evaluation_logger.get_log()[rmse.__name__])
          == hook_frequency
      )
  
      # Close the event file so that the model folder can be cleaned up.
      summary_writer = tf.compat.v1.summary.FileWriterCache.get(
          model.model_dir
      )
      summary_writer.close()
  
file_path: recommenders/tests/unit/recommenders/utils/test_tf_utils.py
imports: import os
  import pytest
  import numpy
  import pandas
  import itertools
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, SEED
  from recommenders.evaluation.python_evaluation import rmse
label_desc: Use image node_id 4 for calling a global function with example usage: test_evaluation_log_hook(pd_df, tmp) without return types