def _find_qubit_id(cmd):
    """Find qubit id in openqasm cmd."""
    left = []
    right = []
    for i, j in enumerate(cmd):
        if j == '[':
            left.append(i)
        elif j == ']':
            right.append(i)
    if len(left) != len(right):
        raise ValueError(f"Parsing failed for cmd {cmd}")
    idx = []
    for name_left, name_right in zip(left, right):
        idx.append(int(cmd[name_left + 1 : name_right]))  # noqa: E203
    return idx