class_docstr: Base implementation of ResNet v2 from https://arxiv.org/abs/1603.05027.
docstr: Creates ResNetV2 instance.
  
  Args:
      in_channels: number of channels in the input image.
      num_classes: number of output classes.
      blocks_per_group: number of blocks in each block group.
      bottleneck: if True then use bottleneck blocks.
      channels_per_group: number of output channels for each block group.
      group_strides: strides for each block group.
      normalization_fn: module which used as normalization function.
      activation_fn: activation function.
docstr_tok: ["Creates","ResNetV2","instance",".","Args",":","in_channels",":","number","of","channels","in","the","input","image",".","num_classes",":","number","of","output","classes",".","blocks_per_group",":","number","of","blocks","in","each","block","group",".","bottleneck",":","if","True","then","use","bottleneck","blocks",".","channels_per_group",":","number","of","output","channels","for","each","block","group",".","group_strides",":","strides","for","each","block","group",".","normalization_fn",":","module","which","used","as","normalization","function",".","activation_fn",":","activation","function","."]
code: def __init__(
      self,
      in_channels: int,
      num_classes: int,
      blocks_per_group: Sequence[int],
      bottleneck: bool = True,
      channels_per_group: Sequence[int] = (256, 512, 1024, 2048),
      group_strides: Sequence[int] = (1, 2, 2, 2),
      group_use_projection: Sequence[bool] = (True, True, True, True),
      normalization_fn: Callable[
          ..., objax.Module
      ] = objax.nn.BatchNorm2D,
      activation_fn: Callable[
          [JaxArray], JaxArray
      ] = objax.functional.relu,
  ):
      """Creates ResNetV2 instance.
  
      Args:
          in_channels: number of channels in the input image.
          num_classes: number of output classes.
          blocks_per_group: number of blocks in each block group.
          bottleneck: if True then use bottleneck blocks.
          channels_per_group: number of output channels for each block group.
          group_strides: strides for each block group.
          normalization_fn: module which used as normalization function.
          activation_fn: activation function.
      """
      assert len(channels_per_group) == len(blocks_per_group)
      assert len(group_strides) == len(blocks_per_group)
      assert len(group_use_projection) == len(blocks_per_group)
      nin = in_channels
      nout = 64
      ops = [
          Conv2D(nin, nout, k=7, strides=2, **conv_args(7, 64, (3, 3))),
          functools.partial(
              jn.pad, pad_width=((0, 0), (0, 0), (1, 1), (1, 1))
          ),
          functools.partial(
              objax.functional.max_pool_2d,
              size=3,
              strides=2,
              padding=ConvPadding.VALID,
          ),
      ]
      for i in range(len(blocks_per_group)):
          nin = nout
          nout = channels_per_group[i]
          ops.append(
              ResNetV2BlockGroup(
                  nin,
                  nout,
                  num_blocks=blocks_per_group[i],
                  stride=group_strides[i],
                  bottleneck=bottleneck,
                  use_projection=group_use_projection[i],
                  normalization_fn=normalization_fn,
                  activation_fn=activation_fn,
              )
          )
  
      ops.extend(
          [
              normalization_fn(nout),
              activation_fn,
              lambda x: x.mean((2, 3)),
              objax.nn.Linear(
                  nout, num_classes, w_init=objax.nn.init.xavier_normal
              ),
          ]
      )
      super().__init__(ops)
  
imports: import functools
  from typing import Callable, Sequence, Union, Optional
  from jax import numpy
  import objax
  from objax.constants import ConvPadding
  from objax.nn import Conv2D
  from objax.typing import JaxArray, ConvPaddingInt
label_desc: Use image node_id 1 to create a new ResNetV2 object from inherited base classes: objax.nn with example: obj = ResNetV2(in_channels, num_classes, blocks_per_group, bottleneck, channels_per_group, group_strides, group_use_projection, normalization_fn, activation_fn)