code: def compute_1d_relative_distance(
      query_len: int, key_len: int
  ) -> np.ndarray:
      """Generate relative positions of queries and keys for relative attention.
  
      Args:
        query_len: Length of the query.
        key_len: Length of the key.
  
      Returns:
        A numpy (np) int array of shape [len_q, len_k]   holding the distance
        between each query  and key pair, where the query and key are
          indexed by their position. The smallest value in the array is zero.
      """
      # A distance per dimension in the query-key arrays.
      relative_positions = (
          np.arange(key_len)[np.newaxis, :]
          - np.arange(query_len)[:, np.newaxis]
      )
      # These indices are being used by an embedding lookup, so shift the indices
      # such that the smallest index is zero.
      relative_positions -= np.min(relative_positions)
      return relative_positions
  
file_path: scenic/scenic/model_lib/layers/nn_ops.py
imports: from typing import Callable, Sequence
  import flax.linen
  import jax
  from jax import lax
  import jax.numpy
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: compute_1d_relative_distance(query_len, key_len) and returns: relative_positions