Unexpected error while changing the norm_layer in EfficientNet from torchvision

rauffatali: <p>I got the following error while setting the normalization layer of EfficientNet to FrozenBatchNorm2d.</p>
<pre><code class="lang-auto">efficientnet.__dict__['efficientnet_v2_s'](weights='DEFAULT', norm_layer=misc.FrozenBatchNorm2d)
</code></pre>
<pre><code class="lang-auto">---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[12], line 3
      1 from torchvision.models import efficientnet
----&gt; 3 backbone = efficientnet.__dict__['efficientnet_v2_s'](weights='DEFAULT', norm_layer=misc.FrozenBatchNorm2d)

File /opt/conda/lib/python3.10/site-packages/torchvision/models/_utils.py:142, in kwonly_to_pos_or_kw.&lt;locals&gt;.wrapper(*args, **kwargs)
    135     warnings.warn(
    136         f"Using {sequence_to_str(tuple(keyword_only_kwargs.keys()), separate_last='and ')} as positional "
    137         f"parameter(s) is deprecated since 0.13 and may be removed in the future. Please use keyword parameter(s) "
    138         f"instead."
    139     )
    140     kwargs.update(keyword_only_kwargs)
--&gt; 142 return fn(*args, **kwargs)

File /opt/conda/lib/python3.10/site-packages/torchvision/models/_utils.py:228, in handle_legacy_interface.&lt;locals&gt;.outer_wrapper.&lt;locals&gt;.inner_wrapper(*args, **kwargs)
    225     del kwargs[pretrained_param]
    226     kwargs[weights_param] = default_weights_arg
--&gt; 228 return builder(*args, **kwargs)

File /opt/conda/lib/python3.10/site-packages/torchvision/models/efficientnet.py:1047, in efficientnet_v2_s(weights, progress, **kwargs)
   1044 weights = EfficientNet_V2_S_Weights.verify(weights)
   1046 inverted_residual_setting, last_channel = _efficientnet_conf("efficientnet_v2_s")
-&gt; 1047 return _efficientnet(
   1048     inverted_residual_setting,
   1049     kwargs.pop("dropout", 0.2),
   1050     last_channel,
   1051     weights,
   1052     progress,
   1053     norm_layer=partial(nn.BatchNorm2d, eps=1e-03),
   1054     **kwargs,
   1055 )

TypeError: torchvision.models.efficientnet._efficientnet() got multiple values for keyword argument 'norm_layer'
</code></pre>
<p>I can clearly see from the following implementation while defining small version of efficientnet, this norm_layer is hard-coded to <code>partial(nn.BatchNorm2d, eps=1e-03)</code> in line <code>1053</code> which results in above error:</p>
<pre><code class="lang-auto">-&gt; 1047 return _efficientnet(
   1048     inverted_residual_setting,
   1049     kwargs.pop("dropout", 0.2),
   1050     last_channel,
   1051     weights,
   1052     progress,
   1053     norm_layer=partial(nn.BatchNorm2d, eps=1e-03),
   1054     **kwargs,
   1055 )
</code></pre>
<p>Can we address this issue <a class="mention" href="/u/pmeier">@pmeier</a>? Thanks a lot.</p>

pmeier: <p>Hey <a class="mention" href="/u/rauffatali">@rauffatali</a>. I’m no longer actively maintaining <code>torchvision</code>. I suggest you open a <a href="https://github.com/pytorch/vision/issues/new?assignees=&amp;labels=&amp;projects=&amp;template=feature-request.yml" rel="noopener nofollow ugc">feature request on GitHub</a> and let the current maintainers have a look.</p>