def METHOD_NAME(
    dim: int, *, random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None
) -> np.ndarray:
    """Returns a random unitary matrix distributed with Haar measure.
    Args:
        dim: The width and height of the matrix.
        random_state: A seed to use for random number generation.
    Returns:
        The sampled unitary matrix.
    References:
        'How to generate random matrices from the classical compact groups'
        http://arxiv.org/abs/math-ph/0609050
    """
    random_state = value.parse_random_state(random_state)
    z = random_state.randn(dim, dim) + 1j * random_state.randn(dim, dim)
    q, r = np.linalg.qr(z)
    d = np.diag(r)
    return q * (d / abs(d))