code: def build_slopes(num_attention_heads, num_attention_heads_alibi):
      """
      Builds a slopes tensor.
      """
      slopes = (
          torch.Tensor(
              get_slopes(num_attention_heads_alibi)
              + [0] * (num_attention_heads - num_attention_heads_alibi)
          )
          .unsqueeze(-1)
          .unsqueeze(-1)
      )
  
      if torch.cuda.is_available():
          slopes = slopes.to(torch.cuda.current_device())
  
      return slopes
  
file_path: NeMo/nemo/collections/nlp/modules/common/megatron/position_embedding/alibi_relative_position_embedding.py
imports: import math
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: build_slopes(num_attention_heads, num_attention_heads_alibi) and returns: slopes