code: def distmult_kbc_model(
      config, train_graph, is_train_ph, input_tensors
  ):
      """Use DistMult model to score candidates for kbc."""
      s, r, candidates = input_tensors
      model = {}
      entity_encoder = encoders.EmbeddingLookup(
          config.emb_dim,
          is_train_ph,
          train_dropout=config.entity_encoder_dropout,
          input_dim=train_graph.ent_vocab_size,
          scope="entity_embeddings",
          use_tanh=config.use_tanh,
      )
      model["entity_encoder"] = entity_encoder
  
      relation_encoder = encoders.EmbeddingLookup(
          config.emb_dim,
          is_train_ph,
          train_dropout=config.relation_encoder_dropout,
          input_dim=train_graph.rel_vocab_size,
          scope="relation_embeddings",
          use_tanh=config.use_tanh,
      )
      model["relation_encoder"] = relation_encoder
  
      source_emb = entity_encoder.lookup(s)
      relation_emb = relation_encoder.lookup(r)
      candidates_emb = entity_encoder.lookup(candidates)
  
      # Score candidates
      source_dot_query = source_emb * relation_emb
      scores = tf.squeeze(
          tf.matmul(
              tf.expand_dims(source_dot_query, 1),
              candidates_emb,
              transpose_b=True,
          ),
          axis=1,
      )
  
      return scores, model
  
file_path: neural-structured-learning/research/a2n/models.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import encoders
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: distmult_kbc_model(config, train_graph, is_train_ph, input_tensors) and returns: scores,  model