code: def top_k(
      inputs: tf.Tensor,
      k: int,
      de_config: de_config_pb2.DynamicEmbeddingConfig,
      var_name: typing.Text,
      service_address: typing.Text = "",
      timeout_ms: int = -1,
  ):
      """Computes logits for the top k closest embeddings to the inputs.
  
      Args:
        inputs: A float `Tensor` of shape `[batch_size, dim]` representing the
          forward activations of the input network.
        k: An `int` denoting the number of returned keys.
        de_config: A DynamicEmbeddingConfig for configuring the dynamic embedding.
        var_name: A unique name for the operation.
        service_address: The address of a dynamic embedding service. If empty, the
          value passed from --kbs_address flag will be used instead.
        timeout_ms: Timeout millseconds for the connection. If negative, never
          timout.
  
      Returns:
        keys: A string `Tensor` of shape `[batch_size, k]` representing the top k
            keys relative to the input.
        logits: A float `Tensor` of shape `[batch_size, k]` representing the logits
            for the returned keys.
  
      Raises:
        ValueError: if k is not greater than zero.
  
      Note: The (keys, logits) pair returned here should not be used for training as
      they only represent biased sampling. Instead, use sampled_softmax_loss()
      for training.
      """
      if not var_name:
          raise ValueError("Must specify a valid var_name.")
      if k <= 0:
          raise ValueError("k must be greater than zero, got %d" % k)
  
      context.add_to_collection(var_name, de_config)
      resource = gen_carls_ops.dynamic_embedding_manager_resource(
          de_config.SerializeToString(),
          var_name,
          service_address,
          timeout_ms,
      )
      return gen_carls_ops.topk_lookup(inputs, k, resource)
  
file_path: neural-structured-learning/research/carls/candidate_sampling_ops.py
imports: import typing
  from research.carls import context
  from research.carls import dynamic_embedding_config_pb2
  from research.carls.kernels import gen_carls_ops
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: top_k(inputs, k, de_config, var_name, service_address, timeout_ms) and returns: gen_carls_ops