code: def generate_alibi(n_head, dtype=torch.float16):
      """
      This method is adapted from `_generate_alibi` function
      in `lightllm/models/bloom/layer_weights/transformer_layer_weight.py`
      of the ModelTC/lightllm GitHub repository.
      This method is originally the `build_alibi_tensor` function
      in `transformers/models/bloom/modeling_bloom.py`
      of the huggingface/transformers GitHub repository.
      """
  
      def get_slopes_power_of_2(n):
          start = 2 ** (-(2 ** -(math.log2(n) - 3)))
          return [start * start**i for i in range(n)]
  
      def get_slopes(n):
          if math.log2(n).is_integer():
              return get_slopes_power_of_2(n)
          else:
              closest_power_of_2 = 2 ** math.floor(math.log2(n))
              slopes_power_of_2 = get_slopes_power_of_2(
                  closest_power_of_2
              )
              slopes_double = get_slopes(2 * closest_power_of_2)
              slopes_combined = (
                  slopes_power_of_2
                  + slopes_double[0::2][: n - closest_power_of_2]
              )
              return slopes_combined
  
      slopes = get_slopes(n_head)
      return torch.tensor(slopes, dtype=dtype)
  
file_path: colossalai/colossalai/inference/engine/modeling/bloom.py
imports: import math
  import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.distributed
  from torch.nn import functional
  from transformers.models.bloom.modeling_bloom import BaseModelOutputWithPastAndCrossAttentions, BloomAttention, BloomBlock, BloomForCausalLM, BloomModel
  from transformers.utils import logging
  from colossalai.inference.kv_cache.batch_infer_state import BatchInferState
  from colossalai.kernel.triton import bloom_context_attn_fwd, copy_kv_cache_to_dest, token_attention_fwd
  from colossalai.pipeline.stage_manager import PipelineStageManager
label_desc: Use image node_id 1 for calling a global function with example usage: generate_alibi(n_head, dtype) and returns: torch, unknown, get_slopes_power_of_2, slopes_combined