code: def extend_kv_cache(
      batch_size,
      num_heads,
      head_dim,
      current_length,
      max_length,
      dtype,
      device,
  ):
      # empty cache to reduce gpu memory
      if device.type == "xpu":
          torch.xpu.empty_cache()
      return init_kv_cache(
          batch_size,
          num_heads,
          head_dim,
          current_length,
          max_length,
          dtype,
          device,
      )
  
imports: import os
  import torch
  from bigdl.llm.utils.common import invalidInputError
  from bigdl.llm.ggml.quantize import ggml_tensor_qtype
  from bigdl.llm.transformers.utils import get_ipex_version, get_xpu_device_type
label_desc: Use image node_id 2 for calling a global function with example usage: extend_kv_cache(batch_size, num_heads, head_dim, current_length, max_length, dtype, device) and returns: init_kv_cache