code: def test_t5relative(cfg):
      # non-causal
      PE_nc = T5RelativePositionEmbedding(
          bidirectional=True,
          num_attention_heads=cfg["num_attention_heads"],
          layer_type=cfg["layer_type"],
          init_method=init_method_normal(cfg["rpe_init_method_std"]),
          relative_position_num_buckets=cfg["rpe_num_buckets"],
          relative_position_max_distance=cfg["rpe_max_distance"],
      )
  
      # causal
      PE_c = T5RelativePositionEmbedding(
          bidirectional=False,
          num_attention_heads=cfg["num_attention_heads"],
          layer_type=cfg["layer_type"],
          init_method=init_method_normal(cfg["rpe_init_method_std"]),
          relative_position_num_buckets=cfg["rpe_num_buckets"],
          relative_position_max_distance=cfg["rpe_max_distance"],
      )
  
      q_len = k_len = random.randint(1, cfg["max_seq_len"] * 2)
  
      bias_nc = PE_nc(q_len, k_len)
      assert bias_nc.shape == (
          1,
          cfg["num_attention_heads"],
          q_len,
          k_len,
      )
  
      bias_c = PE_c(q_len, k_len)
      assert bias_c.shape == (
          1,
          cfg["num_attention_heads"],
          q_len,
          k_len,
      )
      assert (
          len(torch.triu(bias_c, diagonal=0).unique())
          == cfg["num_attention_heads"] + 1
          if q_len > 1
          else cfg["num_attention_heads"]
      )
  
file_path: NeMo/tests/collections/nlp/test_position_embedding.py
imports: import random
  import pytest
  import torch
  from nemo.collections.nlp.modules.common.megatron.layer_type import LayerType
  from nemo.collections.nlp.modules.common.megatron.position_embedding import ALiBiRelativePositionEmbedding, KERPLERelativePositionEmbedding, RotaryEmbedding, SandwichRelativePositionEmbedding, T5RelativePositionEmbedding, XPOSPositionEmbedding
  from nemo.collections.nlp.modules.common.megatron.position_embedding.rotary_position_embedding import apply_rotary_pos_emb
  from nemo.collections.nlp.modules.common.megatron.utils import init_method_normal
label_desc: Use image node_id 5 for calling a global function with example usage: test_t5relative(cfg) without return types