code: def construct_model(user_input, item_input, params):
      # type: (tf.Tensor, tf.Tensor, dict) -> tf.keras.Model
      """Initialize NeuMF model.
  
      Args:
        user_input: keras input layer for users
        item_input: keras input layer for items
        params: Dict of hyperparameters.
      Raises:
        ValueError: if the first model layer is not even.
      Returns:
        model:  a keras Model for computing the logits
      """
      num_users = params["num_users"]
      num_items = params["num_items"]
  
      model_layers = params["model_layers"]
  
      mf_regularization = params["mf_regularization"]
      mlp_reg_layers = params["mlp_reg_layers"]
  
      mf_dim = params["mf_dim"]
  
      mlperf_helper.ncf_print(
          key=mlperf_helper.TAGS.MODEL_HP_MF_DIM, value=mf_dim
      )
      mlperf_helper.ncf_print(
          key=mlperf_helper.TAGS.MODEL_HP_MLP_LAYER_SIZES,
          value=model_layers,
      )
  
      if model_layers[0] % 2 != 0:
          raise ValueError(
              "The first layer size should be multiple of 2!"
          )
  
      # Initializer for embedding layers
      embedding_initializer = "glorot_uniform"
  
      def mf_slice_fn(x):
          x = tf.squeeze(x, [1])
          return x[:, :mf_dim]
  
      def mlp_slice_fn(x):
          x = tf.squeeze(x, [1])
          return x[:, mf_dim:]
  
      # It turns out to be significantly more effecient to store the MF and MLP
      # embedding portions in the same table, and then slice as needed.
      embedding_user = tf.keras.layers.Embedding(
          num_users,
          mf_dim + model_layers[0] // 2,
          embeddings_initializer=embedding_initializer,
          embeddings_regularizer=tf.keras.regularizers.l2(
              mf_regularization
          ),
          input_length=1,
          name="embedding_user",
      )(user_input)
  
      embedding_item = tf.keras.layers.Embedding(
          num_items,
          mf_dim + model_layers[0] // 2,
          embeddings_initializer=embedding_initializer,
          embeddings_regularizer=tf.keras.regularizers.l2(
              mf_regularization
          ),
          input_length=1,
          name="embedding_item",
      )(item_input)
  
      # GMF part
      mf_user_latent = tf.keras.layers.Lambda(
          mf_slice_fn, name="embedding_user_mf"
      )(embedding_user)
      mf_item_latent = tf.keras.layers.Lambda(
          mf_slice_fn, name="embedding_item_mf"
      )(embedding_item)
  
      # MLP part
      mlp_user_latent = tf.keras.layers.Lambda(
          mlp_slice_fn, name="embedding_user_mlp"
      )(embedding_user)
      mlp_item_latent = tf.keras.layers.Lambda(
          mlp_slice_fn, name="embedding_item_mlp"
      )(embedding_item)
  
      # Element-wise multiply
      mf_vector = tf.keras.layers.multiply(
          [mf_user_latent, mf_item_latent]
      )
  
      # Concatenation of two latent features
      mlp_vector = tf.keras.layers.concatenate(
          [mlp_user_latent, mlp_item_latent]
      )
  
      num_layer = len(model_layers)  # Number of layers in the MLP
      for layer in xrange(1, num_layer):
          model_layer = tf.keras.layers.Dense(
              model_layers[layer],
              kernel_regularizer=tf.keras.regularizers.l2(
                  mlp_reg_layers[layer]
              ),
              activation="relu",
          )
          mlp_vector = model_layer(mlp_vector)
  
      # Concatenate GMF and MLP parts
      predict_vector = tf.keras.layers.concatenate(
          [mf_vector, mlp_vector]
      )
  
      # Final prediction layer
      logits = tf.keras.layers.Dense(
          1,
          activation=None,
          kernel_initializer="lecun_uniform",
          name=movielens.RATING_COLUMN,
      )(predict_vector)
  
      # Print model topology.
      model = tf.keras.models.Model([user_input, item_input], logits)
      model.summary()
      sys.stdout.flush()
  
      return model
  
file_path: autodist/examples/benchmark/utils/recommendation/neumf_model.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from six.moves import xrange
  import tensorflow
  from utils.recommendation import constants
  from utils.recommendation import movielens
  from utils.recommendation import ncf_common
  from utils.recommendation import stat_utils
  from utils.logs import mlperf_helper
label_desc: Use image node_id 4 for calling a global function with example usage: construct_model(user_input, item_input, params) and returns: model, x, x