code: def mpt_multihead_attention_forward(
      self,
      x,
      past_key_value=None,
      attn_bias=None,
      attention_mask=None,
      is_causal=True,
      needs_weights=False,
  ):
      qkv = self.Wqkv(x)
      if self.clip_qkv:
          qkv.clamp_(min=-self.clip_qkv, max=self.clip_qkv)
      (query, key, value) = qkv.chunk(3, dim=2)
      key_padding_mask = attention_mask
      if self.qk_ln:
          dtype = query.dtype
          query = self.q_ln(query).to(dtype)
          key = self.k_ln(key).to(dtype)
      (
          context,
          attn_weights,
          past_key_value,
      ) = mpt_scaled_multihead_dot_product_attention(
          query,
          key,
          value,
          self.n_heads,
          past_key_value=past_key_value,
          softmax_scale=self.softmax_scale,
          attn_bias=attn_bias,
          key_padding_mask=key_padding_mask,
          is_causal=is_causal,
          dropout_p=self.attn_dropout_p,
          training=self.training,
          needs_weights=needs_weights,
      )
      return (self.out_proj(context), attn_weights, past_key_value)
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/models/mpt.py
imports: import warnings
  import torch
  from einops import rearrange
  import math
  import torch.nn.functional
  from bigdl.llm.utils.common import invalidInputError
  from bigdl.llm.transformers.models.utils import extend_kv_cache, init_kv_cache, append_kv_cache
label_desc: Use image node_id 1 for calling a global function with example usage: mpt_multihead_attention_forward(x, past_key_value, attn_bias, attention_mask, is_causal, needs_weights) and returns: self,  attn_weights,  past_key_value