title: Python dynamic import third party sub-modules by importlib's question
body: <p>Python version: 3.8.10</p>
  <p>Hi, I am trying to import a third party sub-module using <code>importlib</code> by giving the string name of sub-module since the user input may only has name of the sub-modules, for example, while running the script:</p>
  <pre><code>import importlib
  
  pkg = importlib.import_module(&quot;transformers&quot;)
  print(dir(pkg))
  print(dir(pkg.BertTokenizer))
  
  mds = importlib.import_module(&quot;transformers.BertTokenizer&quot;)
  print(dir(mds))
  </code></pre>
  <p>It shows that the first <code>pkg</code> is OK to be loaded, yet <code>mds</code> is failed.
  The output message:</p>
  <pre><code>['ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',...,'xnli_tasks_num_labels']
  ['SPECIAL_TOKENS_ATTRIBUTES', '__annotations__',...,'vocab_size']
  
  Traceback (most recent call last):
    File &quot;test.py&quot;, line 7, in &lt;module&gt;
      mds = importlib.import_module(&quot;transformers.BertTokenizer&quot;)
    File &quot;c:\users\ychuang\appdata\local\programs\python\python38\lib\importlib\__init__.py&quot;, line 1
  27, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 973, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'transformers.BertTokenizer'
  </code></pre>
  <p>My question is if there is a corrected way to perform the method like <code>mds = importlib.import_module(&quot;transformers.BertTokenizer&quot;)</code>?</p>