What would be more inline with best practices for the select all / select none option on group checkboxes?
OR
Since you essentially have tabular data, you can include the top level checkbox as part of the header.
The user will get immediate feedback in close proximity as they toggle the checkbox, and select/deselect any items, so the result is right in front of them.
You see this in Material Design guidelines for checkboxes