code: def renormalize(self, modelparams):
          
          # The 0th basis element (identity) should have
          # a value 1 / sqrt{dim}, since the trace of that basis
          # element is fixed to be sqrt{dim} by convention.
          norm = modelparams[:, 0] * np.sqrt(self._dim)
          assert not np.sum(norm == 0)
          return modelparams / norm[:, None]
docs: Renormalizes one or more states represented as model
          parameter vectors, such that each state has trace 1.
  
          :param np.ndarray modelparams: Array of shape ``(n_states,
              dim ** 2)`` representing one or more states as 
              model parameter vectors.
          :return: The same state, normalized to trace one.