def _instantiate_session(self, method_name, proxy=None, *args, **kwargs):
if '<STR_LIT>' in kwargs:<EOL><INDENT>session_class = getattr(kwargs['<STR_LIT>'], method_name)<EOL>del kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>session_class = getattr(self._provider_manager, method_name)<EOL><DEDENT>if proxy is None:<EOL><INDENT>try:<EOL><INDENT>return session_class(bank_id=self._catalog_id, *args, **kwargs)<EOL><DEDENT>except AttributeError:<EOL><INDENT>return session_class(*args, **kwargs)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return session_class(bank_id=self._catalog_id, proxy=proxy, *args, **kwargs)<EOL><DEDENT>except AttributeError:<EOL><INDENT>return session_class(proxy=proxy, *args, **kwargs)<EOL><DEDENT><DEDENT>
Instantiates a provider session