Fix advanced profiler for python >=3.12 (#20809)
* Fix advanced profiler for python >=3.12
* test: add compatibility test for nested profiling in AdvancedProfiler (Python 3.12+)
* Update src/lightning/pytorch/profilers/advanced.py
* changelog
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Deependu <deependujha21@gmail.com>
Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>