docstr: Implementation of `ResNeXt <https://arxiv.org/pdf/1611.05431.pdf>`_.
  
  Args:
      small_input: set to `True` for 32x32 sized image inputs.
      final_bn_relu: set to `False` to exclude the final batchnorm and
          ReLU layers. These settings are useful when training Siamese
          networks.
      use_se: Enable squeeze and excitation
      se_reduction_ratio: The reduction ratio to apply in the excitation
          stage. Only used if `use_se` is `True`.
docstr_tok: ["Implementation","of","`","ResNeXt","<","https",":","\/\/arxiv.org\/pdf\/1611.05431.pdf",">","`","_",".","Args",":","small_input",":","set","to","`","True","`","for","32x32","sized","image","inputs",".","final_bn_relu",":","set","to","`","False","`","to","exclude","the","final","batchnorm","and","ReLU","layers",".","These","settings","are","useful","when","training","Siamese","networks",".","use_se",":","Enable","squeeze","and","excitation","se_reduction_ratio",":","The","reduction","ratio","to","apply","in","the","excitation","stage",".","Only","used","if","`","use_se","`","is","`","True","`","."]
code: def __init__(
      self,
      num_blocks,
      init_planes: int = 64,
      reduction: int = 4,
      small_input: bool = False,
      zero_init_bn_residuals: bool = False,
      base_width_and_cardinality: Optional[Sequence] = None,
      basic_layer: bool = False,
      final_bn_relu: bool = True,
      use_se: bool = False,
      se_reduction_ratio: int = 16,
  ):
      """
      Implementation of `ResNeXt <https://arxiv.org/pdf/1611.05431.pdf>`_.
  
      Args:
          small_input: set to `True` for 32x32 sized image inputs.
          final_bn_relu: set to `False` to exclude the final batchnorm and
              ReLU layers. These settings are useful when training Siamese
              networks.
          use_se: Enable squeeze and excitation
          se_reduction_ratio: The reduction ratio to apply in the excitation
              stage. Only used if `use_se` is `True`.
      """
      super().__init__()
  
      # assertions on inputs:
      assert isinstance(num_blocks, Sequence)
      assert all(is_pos_int(n) for n in num_blocks)
      assert is_pos_int(init_planes) and is_pos_int(reduction)
      assert type(small_input) == bool
      assert (
          type(zero_init_bn_residuals) == bool
      ), "zero_init_bn_residuals must be a boolean, set to true if gamma of last\
               BN of residual block should be initialized to 0.0, false for 1.0"
      assert base_width_and_cardinality is None or (
          isinstance(base_width_and_cardinality, Sequence)
          and len(base_width_and_cardinality) == 2
          and is_pos_int(base_width_and_cardinality[0])
          and is_pos_int(base_width_and_cardinality[1])
      )
      assert isinstance(use_se, bool), "use_se has to be a boolean"
  
      # initial convolutional block:
      self.num_blocks = num_blocks
      self.small_input = small_input
      self._make_initial_block(small_input, init_planes, basic_layer)
  
      # compute number of planes at each spatial resolution:
      out_planes = [
          init_planes * 2**i * reduction
          for i in range(len(num_blocks))
      ]
      in_planes = [init_planes] + out_planes[:-1]
  
      # create subnetworks for each spatial resolution:
      blocks = []
      for idx in range(len(out_planes)):
          mid_planes_and_cardinality = None
          if base_width_and_cardinality is not None:
              w, c = base_width_and_cardinality
              mid_planes_and_cardinality = (w * 2**idx, c)
          new_block = self._make_resolution_block(
              in_planes[idx],
              out_planes[idx],
              idx,
              num_blocks[idx],  # num layers
              stride=1 if idx == 0 else 2,
              mid_planes_and_cardinality=mid_planes_and_cardinality,
              reduction=reduction,
              final_bn_relu=final_bn_relu
              or (idx != (len(out_planes) - 1)),
              use_se=use_se,
              se_reduction_ratio=se_reduction_ratio,
          )
          blocks.append(new_block)
      self.blocks = nn.Sequential(*blocks)
  
      self.out_planes = out_planes[-1]
      self._num_classes = out_planes
  
      # initialize weights:
      self._initialize_weights(zero_init_bn_residuals)
  
imports: import copy
  import math
  import re
  import warnings
  from collections import OrderedDict
  from typing import Any, Dict, Optional, Sequence
  import torch.nn
  from classy_vision.generic.util import is_pos_int, is_pos_int_tuple
  from .None import register_model
  from .classy_model import ClassyModel
  from .squeeze_and_excitation_layer import SqueezeAndExcitationLayer
label_desc: Use image node_id 1 to create a new ResNeXt object from inherited base classes: ClassyModel with example: obj = ResNeXt(num_blocks, init_planes, reduction, small_input, zero_init_bn_residuals, base_width_and_cardinality, basic_layer, final_bn_relu, use_se, se_reduction_ratio)