code: def baichuan_13b_gen_alibi_mask(tensor, n_head, max_pos):
      # May use fp16 for alibi mask to further reduce memory
      slopes = torch.Tensor(_get_interleave(n_head))  # .half()
      position_point = torch.arange(max_pos) - max_pos + 1
      position_point = (
          position_point.unsqueeze(0)
          .unsqueeze(0)
          .expand(n_head, -1, -1)
      )
      diag = torch.diag(position_point[0])
      position_point = position_point - diag.unsqueeze(0).unsqueeze(
          0
      ).transpose(-1, -2)
      alibi = slopes.unsqueeze(1).unsqueeze(1) * position_point
      alibi = alibi.view(n_head, 1, max_pos)
      alibi_mask = torch.triu(
          _fill_with_neg_inf(torch.zeros([max_pos, max_pos])), 1
      )  # .half()
      alibi_mask = alibi_mask.unsqueeze(0) + alibi
      if tensor.device.type == "xpu":
          alibi_mask = alibi_mask.to(tensor.device)
      return alibi_mask
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/models/baichuan2.py
imports: import math
  from typing import Optional, Tuple
  import torch
  import torch.utils.checkpoint
  from torch.nn import functional
  from bigdl.llm.ggml.quantize import ggml_tensor_qtype
  from bigdl.llm.transformers.models.utils import init_kv_cache, extend_kv_cache, append_kv_cache
  from bigdl.llm.transformers.models.utils import apply_rotary_pos_emb
  from bigdl.llm.transformers.models.utils import apply_rotary_pos_emb_no_cache_xpu
  from bigdl.llm.transformers.models.utils import mlp_fusion_check
  from transformers.utils import logging
label_desc: Use image node_id 8 for calling a global function with example usage: baichuan_13b_gen_alibi_mask(tensor, n_head, max_pos) and returns: alibi_mask