code: def default_de_config(
      embedding_dimension: int,
      initial_values: typing.List[float] = None,
      cs_config: cs_config_pb2.CandidateSamplerConfig = None,
  ):
      """Creates a default DynamicEmbeddingConfig and starts a local DES server.
  
      Args:
        embedding_dimension: An positive int specifying embedding dimension.
        initial_values: A list of float with size embedding_dimension if specified.
        cs_config: An instance of cs_config_pb2.CandidateSamplerConfig.
  
      Returns:
        A DynamicEmbeddingConfig.
      Raises:
        ValueError: if embedding_dimension is not positive or initial_values is
          given and its size is not embedding_dimension.
      """
      if embedding_dimension <= 0:
          raise ValueError(
              "Invalid embedding_dimension: %d" % embedding_dimension
          )
      if (
          initial_values is not None
          and len(initial_values) != embedding_dimension
      ):
          raise ValueError(
              "initial_values's size is not embedding_dimension"
          )
      config = de_config_pb2.DynamicEmbeddingConfig()
      text_format.Parse(
          """
      embedding_dimension: %d
      knowledge_bank_config {
        initializer {
          random_uniform_initializer {
            low: -0.5
            high: 0.5
          }
          use_deterministic_seed: true
        }
        extension {
          [type.googleapis.com/carls.InProtoKnowledgeBankConfig] {}
        }
      }
      gradient_descent_config {
        learning_rate: 0.1
        sgd {}
      }
    """
          % embedding_dimension,
          config,
      )
      if initial_values:
          default_embed = (
              config.knowledge_bank_config.initializer.default_embedding
          )
          for v in initial_values:
              default_embed.value.append(v)
      if cs_config:
          config.candidate_sampler_config.CopyFrom(cs_config)
      return config
  
file_path: neural-structured-learning/research/carls/testing/test_util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import typing
  from absl import flags
  from research.carls import dynamic_embedding_config_pb2
  from research.carls import kbs_server_helper_pybind
  from research.carls.candidate_sampling import candidate_sampler_config_pb2
  from google.protobuf import text_format
label_desc: Use image node_id 1 for calling a global function with example usage: default_de_config(embedding_dimension, initial_values, cs_config) and returns: config