How to use torch.utils.bottleneck for profiling a module (vs a script)?

I’ve used to create a package of my code. The training script is a module that I invoke with “python -m”. Incidentally, it also uses hydra and so it’s command line args are a diff format:

python -m arg1=foo

How do I use torch.utils.bottleneck to profile my code?

$ python -m torch.utils.bottleneck
Running environment analysis...
Running your script with cProfile
Traceback (most recent call last):
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/", line 87, in _run_code
    exec(code, run_globals)
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/", line 231, in <module>
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/", line 209, in main
    cprofile_prof = run_cprofile(code, globs)
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/", line 74, in run_cprofile
    exec(code, globs, None)
  File "", line 17, in <module>
    from .config_parse.train import TrainScriptConfig
ImportError: attempted relative import with no known parent package