code: def transform_inertia(transform, inertia_tensor):
      
      # check inputs and extract rotation
      transform = np.asanyarray(transform, dtype=np.float64)
      if transform.shape == (4, 4):
          rotation = transform[:3, :3]
      elif transform.shape == (3, 3):
          rotation = transform
      else:
          raise ValueError('transform must be (3,3) or (4,4)!')
  
      inertia_tensor = np.asanyarray(inertia_tensor, dtype=np.float64)
      if inertia_tensor.shape != (3, 3):
          raise ValueError('inertia_tensor must be (3,3)!')
  
      transformed = util.multi_dot([rotation,
                                    inertia_tensor * negate_nondiagonal,
                                    rotation.T])
      transformed *= negate_nondiagonal
      return transformed
docs: Transform an inertia tensor to a new frame.
  
      More details in OCW PDF:
      MIT16_07F09_Lec26.pdf
  
      Parameters
      ------------
      transform : (3, 3) or (4, 4) float
        Transformation matrix
      inertia_tensor : (3, 3) float
        Inertia tensor
  
      Returns
      ------------
      transformed : (3, 3) float
        Inertia tensor in new frame