code: def _generate_relative_positions_embeddings(length_q, length_k, depth,
                                              max_relative_position, name,
                                              cache=False):
    
    with tf.variable_scope(name):
      relative_positions_matrix = _generate_relative_positions_matrix(
          length_q, length_k, max_relative_position, cache=cache)
      vocab_size = max_relative_position * 2 + 1
      # Generates embedding for each relative position of dimension depth.
      embeddings_table = tf.get_variable("embeddings", [vocab_size, depth])
      embeddings = tf.gather(embeddings_table, relative_positions_matrix)
      return embeddings
docs: Generates tensor of size [1 if cache else length_q, length_k, depth].