<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def random_gate(qubits: Union[int, Qubits]) -> Gate: r"""Returns a random unitary gate on K qubits. Ref: "How to generate random matrices from the classical compact groups" Francesco Mezzadri, math-ph/0609050 """

    N, qubits = qubits_count_tuple(qubits)
    unitary = scipy.stats.unitary_group.rvs(2**N)
    return Gate(unitary, qubits=qubits, name='RAND{}'.format(N))