<p dir="auto"><a href="https://github.com/huggingface/pytorch-pretrained-BERT/blob/35becc6d84f620c3da48db460d6fb900f2451782/pytorch_pretrained_bert/modeling.py#L387-L394">https://github.com/huggingface/pytorch-pretrained-BERT/blob/35becc6d84f620c3da48db460d6fb900f2451782/pytorch_pretrained_bert/modeling.py#L387-L394</a></p>
<p dir="auto">I don't understand how it is useful to wrap the BertLMPredictionHead class like that, perhaps it was forgotten in some refactoring ? I can do a PR if you confirm me it can be replaced.</p>
<p dir="auto">BertOnlyMLMHead is only used in BertForMaskedLM.</p>
<h2 dir="auto">Environment info</h2>
<ul dir="auto">
<li><code class="notranslate">transformers</code> version: 4.18.0.dev0</li>
<li>Platform: macos high sierra 10.13.4</li>
<li>Python version: 3.9</li>
<li>PyTorch version (GPU?): 1.8.1 CPU</li>
<li>Using GPU in script?: no</li>
<li>Using distributed or parallel set-up in script?: no</li>
</ul>
<h3 dir="auto">Who can help</h3>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sgugger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sgugger">@sgugger</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/LysandreJik/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/LysandreJik">@LysandreJik</a></p>
<h2 dir="auto">Information</h2>
<p dir="auto">When trying to create a new model with <code class="notranslate">add-new-model-like</code> without having flax installed, an error message is raised.</p>
<p dir="auto">While I think the code should work without flax, especially considering the numerous flags across the codebase (<code class="notranslate">is_*_available()</code>) to handle when one of the deep learning framework isn't installed.</p>
<p dir="auto">The problem arises when using:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> the official example scripts: (give details below)</li>
</ul>
<h2 dir="auto">To reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>run <code class="notranslate">transformers-cli add-new-model-like</code></li>
<li>ask for <code class="notranslate">deit</code></li>
<li>see error message</li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ transformers-cli add-new-model-like
What is the model you would like to duplicate? deit
Traceback (most recent call last):
  File &quot;/usr/local/bin/transformers-cli&quot;, line 33, in &lt;module&gt;
    sys.exit(load_entry_point('transformers==4.18.0.dev0', 'console_scripts', 'transformers-cli')())
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/transformers_cli.py&quot;, line 52, in main
    service = args.func(args)
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py&quot;, line 1283, in add_new_model_like_command_factory
    return AddNewModelLikeCommand(config_file=args.config_file, path_to_repo=args.path_to_repo)
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py&quot;, line 1314, in __init__
    ) = get_user_input()
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py&quot;, line 1419, in get_user_input
    old_model_info = retrieve_info_for_model(old_model_type)
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py&quot;, line 690, in retrieve_info_for_model
    model_classes = retrieve_model_classes(model_type, frameworks=frameworks)
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py&quot;, line 624, in retrieve_model_classes
    &quot;flax&quot;: auto_module.modeling_flax_auto,
  File &quot;/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/file_utils.py&quot;, line 2770, in __getattr__
    raise AttributeError(f&quot;module {self.__name__} has no attribute {name}&quot;)
AttributeError: module transformers.models.auto has no attribute modeling_flax_auto"><pre class="notranslate">$ transformers-cli add-new-model-like
What is the model you would like to duplicate<span class="pl-k">?</span> deit
Traceback (most recent call last):
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/bin/transformers-cli<span class="pl-pds">"</span></span>, line 33, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
    sys.exit(load_entry_point(<span class="pl-s"><span class="pl-pds">'</span>transformers==4.18.0.dev0<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>console_scripts<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>transformers-cli<span class="pl-pds">'</span></span>)())
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/transformers_cli.py<span class="pl-pds">"</span></span>, line 52, <span class="pl-k">in</span> main
    service = args.func(args)
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py<span class="pl-pds">"</span></span>, line 1283, <span class="pl-k">in</span> add_new_model_like_command_factory
    <span class="pl-k">return</span> AddNewModelLikeCommand(config_file=args.config_file, path_to_repo=args.path_to_repo)
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py<span class="pl-pds">"</span></span>, line 1314, <span class="pl-k">in</span> __init__
    ) = <span class="pl-en">get_user_input</span>()
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py<span class="pl-pds">"</span></span>, line 1419, <span class="pl-k">in</span> get_user_input
    old_model_info = retrieve_info_for_model(old_model_type)
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py<span class="pl-pds">"</span></span>, line 690, <span class="pl-k">in</span> retrieve_info_for_model
    model_classes = retrieve_model_classes(model_type, frameworks=frameworks)
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/commands/add_new_model_like.py<span class="pl-pds">"</span></span>, line 624, <span class="pl-k">in</span> retrieve_model_classes
    <span class="pl-s"><span class="pl-pds">"</span>flax<span class="pl-pds">"</span></span>: auto_module.modeling_flax_auto,
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python3.9/site-packages/transformers-4.18.0.dev0-py3.9.egg/transformers/file_utils.py<span class="pl-pds">"</span></span>, line 2770, <span class="pl-k">in</span> __getattr__
    raise AttributeError(f<span class="pl-s"><span class="pl-pds">"</span>module {self.__name__} has no attribute {name}<span class="pl-pds">"</span></span>)
AttributeError: module transformers.models.auto has no attribute modeling_flax_auto</pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Either work without having to install flax, or raise an error message telling me I need to install flax (which would be a bit annoying if I only intend to contribute to pytorch).</p>
<p dir="auto">Thank you very much for this library, it's great! <g-emoji class="g-emoji" alias="heart" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2764.png">❤️</g-emoji></p>