<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sample(self, trials: int) -> np.ndarray: """Measure the state in the computational basis the the given number of trials, and return the counts of each output configuration. """

        # TODO: Can we do this within backend?
        probs = np.real(bk.evaluate(self.probabilities()))
        res = np.random.multinomial(trials, probs.ravel())
        res = res.reshape(probs.shape)
        return res