Return the trace, the sum of the diagonal elements of the (super)
        operator.

def trace(self) -> bk.BKTensor:
        """
        Return the trace, the sum of the diagonal elements of the (super)
        operator.
        """
        N = self.qubit_nb
        R = self.rank
        if R == 1:
            raise ValueError('Cannot take trace of vector')

        tensor = bk.reshape(self.tensor, [2**(N*R//2)] * 2)
        tensor = bk.trace(tensor)
        return tensor