code: def set_density_matrix(self, density_matrix_repr: Union[int, np.ndarray]):
          
          density_matrix = density_matrix_utils.to_valid_density_matrix(
              density_matrix_repr, len(self._qubit_map), self._dtype)
          density_matrix = np.reshape(density_matrix,
                                      self.simulator_state().density_matrix.shape)
          np.copyto(dst=self.simulator_state().density_matrix, src=density_matrix)
docs: Set the density matrix to a new density matrix.
  
          Args:
              density_matrix_repr: If this is an int, the density matrix is set to
              the computational basis state corresponding to this state. Otherwise
              if this is a np.ndarray it is the full state, either a pure state
              or the full density matrix.  If it is the pure state it must be the
              correct size, be normalized (an L2 norm of 1), and be safely
              castable to an appropriate dtype for the simulator.  If it is a
              mixed state it must be correctly sized and positive semidefinite
              with trace one.