code: def rotate_half(x):
      x1, x2 = x[..., : x.shape[-1] // 2], x[..., x.shape[-1] // 2 :]
      return torch.cat((-x2, x1), dim=x1.ndim - 1)
  
file_path: BigDL/python/llm/src/bigdl/llm/transformers/models/chatglm.py
imports: import math
  import torch
  import torch.utils.checkpoint
  import torch.nn.functional
  from typing import Optional, Tuple
  from bigdl.llm.transformers.models.utils import init_kv_cache, extend_kv_cache, append_kv_cache
label_desc: Use image node_id 1 for calling a global function with example usage: rotate_half(x) and returns: torch