def _edge_vectors_attention_inner(x,
                                  y,
                                  adjacency_matrix,
                                  num_labels,
                                  transpose,
                                  name,
                                  use_one_hot_embeddings=False):
  """Edge vector attention inner calculation.

  Args:
    x: <float>[batch_size, heads, length, length or emb_size].
    y: <float>[batch_size, heads, length, emb_size].
    adjacency_matrix: <int>[batch, length, length]
    num_labels: Number of unique labels in adjacency matrix.
    transpose: Whether to transpose inner matrices of y and z. Should be true if
      last dimension of x is emb_size, not length.
    name: Name for variable scope.
    use_one_hot_embeddings: bool. If True, use one-hot method for word
      embeddings. If False, use `tf.nn.embedding_lookup()`.

  Returns:
    <float>[batch_size, heads, length, length or emb_size].
  """
  with tf.variable_scope(name, values=[x, y]):
    emb_size = y.get_shape()[-1]
    xy = tf.matmul(x, y, transpose_b=transpose)
    # Generates embedding for each relative position.
    embeddings_table = tf.get_variable("embeddings", [num_labels, emb_size])
    graph_embeddings = embedding_lookup(embeddings_table, adjacency_matrix,
                                        use_one_hot_embeddings)
    # embeddings is <float>[batch, length, length, emb_size].
    x_t = tf.transpose(x, [0, 2, 1, 3])
    # x_t is <float>[batch, length, heads, length or emb_size].
    xz = tf.matmul(x_t, graph_embeddings, transpose_b=transpose)
    # xz is <float>[batch, length, heads, length or emb_size].
    xz_t = tf.transpose(xz, [0, 2, 1, 3])
    # xz_t is <float>[batch, heads, length, length or emb_size].
    return xy + xz_t
Edge vector attention inner calculation.

  Args:
    x: <float>[batch_size, heads, length, length or emb_size].
    y: <float>[batch_size, heads, length, emb_size].
    adjacency_matrix: <int>[batch, length, length]
    num_labels: Number of unique labels in adjacency matrix.
    transpose: Whether to transpose inner matrices of y and z. Should be true if
      last dimension of x is emb_size, not length.
    name: Name for variable scope.
    use_one_hot_embeddings: bool. If True, use one-hot method for word
      embeddings. If False, use `tf.nn.embedding_lookup()`.

  Returns:
    <float>[batch_size, heads, length, length or emb_size].
  
language/xsp/model/common_layers.py