The above approaches no longer work for TF2.0 as the profiler methods have been deprecated and moved under compat.v1. Seems like this feature still needs to be implemented.
Below is an issue on Github:
https://github.com/tensorflow/tensorflow/issues/32809