class_docstr: Higher level block for ResNet implementation.
class_docstr_tok: ["Higher","level","block","for","ResNet","implementation","."]
code: def __init__(
      self,
      num_blocks: int,
      num_output_channels: int,
      conv_shape: Union[int, Sequence[int]],
      conv_stride: Union[int, Sequence[int]],
      pool_shape: Union[int, Sequence[int]],
      pool_stride: Union[int, Sequence[int]],
      data_format: str = "NHWC",
      activation: Callable[[tf.Tensor], tf.Tensor] = tf.nn.relu,
      name: Optional[str] = None,
  ):
      super().__init__(name=name)
  
      self._num_blocks = num_blocks
      self._data_format = data_format
      self._activation = activation
  
      # The pooling operation expects a 2-rank shape/stride (height and width).
      if isinstance(pool_shape, int):
          pool_shape = 2 * [pool_shape]
      if isinstance(pool_stride, int):
          pool_stride = 2 * [pool_stride]
  
      # Create a Conv2D factory since we'll be making quite a few.
      def build_conv_layer(name: str):
          return snt.Conv2D(
              num_output_channels,
              conv_shape,
              stride=conv_stride,
              padding="SAME",
              data_format=data_format,
              name=name,
          )
  
      # Create a pooling layer.
      def pooling_layer(inputs: tf.Tensor) -> tf.Tensor:
          return tf.nn.pool(
              inputs,
              pool_shape,
              pooling_type="MAX",
              strides=pool_stride,
              padding="SAME",
              data_format=data_format,
          )
  
      # Create an initial conv layer and pooling to scale the image down.
      self._downscale = snt.Sequential(
          [build_conv_layer("downscale"), pooling_layer]
      )
  
      # Residual block(s).
      self._convs = []
      for i in range(self._num_blocks):
          name = "residual_block_%d" % i
          self._convs.append(
              [
                  build_conv_layer(name + "_0"),
                  build_conv_layer(name + "_1"),
              ]
          )
  
file_path: acme/acme/tf/networks/vision.py
imports: from typing import Callable, Optional, Sequence, Union
  import sonnet
  import tensorflow
label_desc: Use image node_id 1 to create a new ResidualBlockGroup object from inherited base classes: snt with example: obj = ResidualBlockGroup(num_blocks, num_output_channels, conv_shape, conv_stride, pool_shape, pool_stride, data_format, activation, name)