code: def _logdet(A):
      """Compute the log det of a positive semidefinite matrix."""
      from scipy import linalg
  
      vals = linalg.eigvalsh(A)
      # avoid negative (numerical errors) or zero (semi-definite matrix) values
      tol = vals.max() * vals.size * np.finfo(np.float64).eps
      vals = np.where(vals > tol, vals, tol)
      return np.sum(np.log(vals))
  
imports: import inspect
  import operator
  import os
  import warnings
  from contextlib import contextmanager
  from io import StringIO
  from math import log
  from pprint import pprint
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: _logdet(A) and returns: np