Only look for a profile in the cfg dict or function if one has been passed.
Merge pull request #19211 from garethgreenaway/returner_with_profile_fix

Fixes to returner __init__.py