code: def quat_to_rot(q):
      batch_size, _ = q.shape
      q = F.normalize(q, dim=1)
      R = torch.ones((batch_size, 3, 3)).cuda()
      qr = q[:, 0]
      qi = q[:, 1]
      qj = q[:, 2]
      qk = q[:, 3]
      R[:, 0, 0] = 1 - 2 * (qj**2 + qk**2)
      R[:, 0, 1] = 2 * (qj * qi - qk * qr)
      R[:, 0, 2] = 2 * (qi * qk + qr * qj)
      R[:, 1, 0] = 2 * (qj * qi + qk * qr)
      R[:, 1, 1] = 1 - 2 * (qi**2 + qk**2)
      R[:, 1, 2] = 2 * (qj * qk - qi * qr)
      R[:, 2, 0] = 2 * (qk * qi - qj * qr)
      R[:, 2, 1] = 2 * (qj * qk + qi * qr)
      R[:, 2, 2] = 1 - 2 * (qi**2 + qj**2)
      return R
  
file_path: insightface/reconstruction/PBIDR/code/utils/rend_util.py
imports: import numpy
  import imageio
  import skimage
  import cv2
  import torch
  from torch.nn import functional
label_desc: Use image node_id 8 for calling a global function with example usage: quat_to_rot(q) and returns: R