[retake][mobile] Fix lightweight dispatch OOM error by introducing selective build
See #78983 for more details. This PR adds a new option argument to avoid changing the existing one and added unit tests to cover the arugments.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/79215
Approved by: https://github.com/cccclai