code: def inv3d(H, sym=False):
      """
      Calculates the inverse of a batched 3-D matrix
      """
      detH = determinant_3d(H)
      Hinv = torch.empty_like(H)
      Hinv[..., 0, 0] = (
          H[..., 1, 1] * H[..., 2, 2] - H[..., 1, 2] * H[..., 2, 1]
      )
      Hinv[..., 1, 1] = (
          H[..., 0, 0] * H[..., 2, 2] - H[..., 0, 2] * H[..., 2, 0]
      )
      Hinv[..., 2, 2] = (
          H[..., 0, 0] * H[..., 1, 1] - H[..., 0, 1] * H[..., 1, 0]
      )
  
      Hinv[..., 0, 1] = (
          H[..., 0, 2] * H[..., 2, 1] - H[..., 0, 1] * H[..., 2, 2]
      )
      Hinv[..., 0, 2] = (
          H[..., 0, 1] * H[..., 1, 2] - H[..., 0, 2] * H[..., 1, 1]
      )
      Hinv[..., 1, 2] = (
          H[..., 0, 2] * H[..., 1, 0] - H[..., 0, 0] * H[..., 1, 2]
      )
  
      if sym:
          Hinv[..., 1, 0] = Hinv[..., 0, 1]
          Hinv[..., 2, 0] = Hinv[..., 0, 2]
          Hinv[..., 2, 1] = Hinv[..., 1, 2]
      else:
          Hinv[..., 1, 0] = (
              H[..., 2, 0] * H[..., 1, 2] - H[..., 1, 0] * H[..., 2, 2]
          )
          Hinv[..., 2, 0] = (
              H[..., 1, 0] * H[..., 2, 1] - H[..., 2, 0] * H[..., 1, 1]
          )
          Hinv[..., 2, 1] = (
              H[..., 2, 0] * H[..., 0, 1] - H[..., 0, 0] * H[..., 2, 1]
          )
      Hinv = Hinv / detH.unsqueeze(-1).unsqueeze(-1)
      return Hinv
  
file_path: pyro/pyro/ops/linalg.py
imports: import math
  import warnings
  from contextlib import contextmanager
  import torch
label_desc: Use image node_id 5 for calling a global function with example usage: inv3d(H, sym) and returns: Hinv