code: def vonneumann_entropy(tensor):
      """Returns the von Neumann entropy of a density matrix (2-mode, square) tensor (matrix).
  
      Parameters
      ----------
      tensor : Non-decomposed tensor with indices whose shapes are all a factor of two (represent one or more qubits)
  
      Returns
      -------
      von_neumann_entropy : order-0 tensor
  
      Notes
      -----
      The von Neumann entropy is :math:`- \\sum_i p_i ln(p_i)`,
      where p_i are the probabilities that each state is occupied
      (the eigenvalues of the density matrix).
      """
      square_dim = int(math.sqrt(math.prod(tensor.shape)))
      tensor = tl.reshape(tensor, (square_dim, square_dim))
      try:
          eig_vals = T.eigh(tensor)[0]
      except:
          # All density matrices are Hermitian, here real. Hermitianize matrix if rounding/transformation
          # errors have occured.
          tensor = (tensor + tl.transpose(tensor)) / 2
          eig_vals = T.eigh(tensor)[0]
      eps = tl.eps(eig_vals.dtype)
      eig_vals = eig_vals[eig_vals > eps]
  
      return -T.sum(T.log2(eig_vals) * eig_vals)
  
imports: import math
  import tensorly
  from ..None import backend
  from ..tt_tensor import tt_to_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: vonneumann_entropy(tensor) and returns: unknown