code: def trace(self) -> bk.BKTensor:
          
          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
docs: Return the trace, the sum of the diagonal elements of the (super)
          operator.