code: def dynamic_gaussian_memory_lookup(
      inputs: tf.Tensor,
      mode: typing.Union[int, tf.Tensor],
      config: de_config_pb2.DynamicEmbeddingConfig,
      var_name: typing.Text,
      service_address: typing.Text = "",
      timeout_ms: int = -1,
  ):
      """Applies dynamic Gaussian memory to given inputs.
  
      A Gaussian memory assumes the input pattern can be represented by a number of
      Gaussian clusters. This function returns the closest Gaussian mean, variance
      and the distance between each data and the closest Guassian center.
  
      This function can be used in conjunction with a DynamicNormalization layer in
      a DNN. The distance between the input and the Gaussian cluster can be used for
      model uncertainty inferece.
  
      Note that the memory data is only based on the last dimension of the input.
      Hence if the input shape is [d1, d2, ..., dn], it is assumed to contain
      d1*d2*...*dn-1 data points.
  
      Args:
        inputs: A float `Tensor` of shape [d1, d2, ..., dn] with n > 0.
        mode: An int or a `Tensor` whose value must be one of
          {LOOKUP_WITHOUT_UPDATE, LOOKUP_WITH_UPDATE, LOOKUP_WITH_GROW}.
        config: An instance of DynamicEmbeddingConfig.
        var_name: A unique name for the given op.
        service_address: The address of a knowledge bank 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:
        - A `Tensor` with the same shape of input representing the mean values.
        - A `Tensor` with the same shape of input representing the variance values.
        - A `Tensor` with the shape [d1, d2, ..., dn-1] representing the distance to
          the cluster center.
        - An int `Tensor` with the shape [d1, d2, ..., dn-1] representing the
        cluster ids.
      Raises:
        TypeError: if dm_config is not an instance of DynamicMemoryConfig.
        ValueError: If layer_name is not specified or mode is not valid.
      """
      if isinstance(mode, int) and mode not in {
          LOOKUP_WITHOUT_UPDATE,
          LOOKUP_WITH_UPDATE,
          LOOKUP_WITH_GROW,
      }:
          raise ValueError("Invalid mode: %r" % mode)
      else:  # mode is a Tensor
          mode = tf.cast(mode, tf.int32)
      if not var_name:
          raise ValueError("Must specify a valid layer_name.")
  
      context.add_to_collection(var_name, config)
      resource = gen_carls_ops.dynamic_embedding_manager_resource(
          config.SerializeToString(),
          var_name,
          service_address,
          timeout_ms,
      )
  
      return gen_carls_ops.dynamic_gaussian_memory_lookup(
          inputs, mode, resource
      )
  
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: dynamic_gaussian_memory_lookup(inputs, mode, config, var_name, service_address, timeout_ms) and returns: gen_carls_ops