def get_input_embeddings(model_config, bert_config, features, is_training,
                         use_one_hot_embeddings):
  """Returns tensor representing inputs for the given batch."""
  with tf.variable_scope("bert") as scope:
    wordpiece_embeddings = _bert_embeddings(
        model_config.model_parameters.source_embedding_dims, bert_config,
        features, is_training, use_one_hot_embeddings, scope,
        model_config.model_parameters.use_segment_ids)

  # Apply extra features, if present.
  if model_config.model_parameters.use_foreign_key_features:
    with tf.variable_scope("foreign_key_embeddings") as scope:
      # Embed them
      initializer = _default_initializer(model_config.model_parameters)
      key_embeddings_dim = model_config.model_parameters.source_embedding_dims
      foreign_key_embeddings = tf.get_variable(
          name="foreign_keys",
          shape=[3, key_embeddings_dim],
          initializer=initializer)

      # Looks up the embedding. Adds 1 first, because 0 indicates padding.
      wordpiece_embeddings = wordpiece_embeddings + _ignore_pad(
          foreign_key_embeddings, features[constants.FOREIGN_KEY_KEY] + 1,
          use_one_hot_embeddings)
  if model_config.model_parameters.use_alignment_features:
    with tf.variable_scope("alignment_features") as scope:
      initializer = _default_initializer(model_config.model_parameters)
      key_embeddings_dim = model_config.model_parameters.source_embedding_dims
      foreign_key_embeddings = tf.get_variable(
          name="alignment_embeddings",
          shape=[3, key_embeddings_dim],
          initializer=initializer)

      features = features[constants.ALIGNED_KEY] + 1

      # Looks up the embedding. Adds 1 first, because 0 indicates padding.
      wordpiece_embeddings = wordpiece_embeddings + _ignore_pad(
          foreign_key_embeddings, features, use_one_hot_embeddings)

  return wordpiece_embeddings
Returns tensor representing inputs for the given batch.
language/xsp/model/embeddings.py