class_docstr: This class defines the `EfficientNet architecture <https://arxiv.org/abs/1905.11946>`_
class_docstr_tok: ["This","class","defines","the","`","EfficientNet","architecture","<","https",":","\/\/arxiv.org\/abs\/1905.11946",">","`","_"]
code: def _make_layer(
      self,
      opts,
      block_config,
      stochastic_depth_prob: float,
      prev_layers_cnt: int,  # number of layers before calling this function
      total_layers: int,  # Total number of layers in the network
      dilate: Optional[bool] = False,
      *args,
      **kwargs,
  ) -> Tuple[nn.Module, int]:
      # This is to accommodate segmentation architectures modifying strides of the backbone network.
      prev_dilation = self.dilation
      # For classification, dilation here should always be 1.
      block = []
      count = 0
  
      for layer_config in block_config:
          assert isinstance(layer_config, EfficientNetBlockConfig)
          in_channels = layer_config.in_channels
          out_channels = layer_config.out_channels
          for layer_idx in range(layer_config.num_layers):
              stride = layer_config.stride if layer_idx == 0 else 1
              if dilate and stride == 2:
                  self.dilation *= stride
                  stride = 1
                  dilate = False
  
              sd_prob = (
                  stochastic_depth_prob
                  * float(prev_layers_cnt + count)
                  / total_layers
              )
              sd_prob = round(sd_prob, 4)
  
              efficient_net_layer = EfficientNetBlock(
                  stochastic_depth_prob=sd_prob,
                  opts=opts,
                  in_channels=in_channels,
                  out_channels=out_channels,
                  kernel_size=layer_config.kernel,
                  stride=stride,
                  expand_ratio=layer_config.expand_ratio,
                  dilation=prev_dilation
                  if count == 0
                  else self.dilation,
                  use_hs=False,
                  use_se=True,
                  use_input_as_se_dim=True,
                  squeeze_factor=layer_config.expand_ratio * 4,
                  act_fn_name="swish",
                  se_scale_fn_name="sigmoid",
              )
              block.append(efficient_net_layer)
              count += 1
              in_channels = out_channels
      prev_layers_cnt += count
      return nn.Sequential(*block), prev_layers_cnt
  
file_path: ml-cvnets/cvnets/models/classification/efficientnet.py
imports: import argparse
  from typing import Any, Optional, Tuple
  from torch import nn
  from cvnets.layers import ConvLayer2d, Dropout, GlobalPool, LinearLayer
  from cvnets.models import MODEL_REGISTRY
  from cvnets.models.classification.base_image_encoder import BaseImageEncoder
  from cvnets.models.classification.config.efficientnet import EfficientNetBlockConfig, get_configuration
  from cvnets.modules import EfficientNetBlock
label_desc: Use image node_id 2 for calling the EfficientNet obj's underlying member method code with example usage: obj._make_layer(opts, block_config, stochastic_depth_prob, prev_layers_cnt, total_layers, dilate) and returns: nn,  prev_layers_cnt