class_docstr: ResNet used to compute the agent's Q-values.
class_docstr_tok: ["ResNet","used","to","compute","the","agent","'s","Q-values","."]
code: def __call__(self, x):
      # We need to reset the list otherwise it would have the previous values each
      # time we create a new network.
      if self.is_initializing():
          for _ in range(len(self.layer_names)):
              self.layer_names.pop()
  
      def _scale_width(n):
          return int(math.ceil(n * self.width))
  
      initializer = nn.initializers.xavier_uniform()
  
      x = x.astype(jnp.float32) / 255.0
      for stack_size in [32, 64, 64]:
          stack = Stack(num_ch=stack_size * self.width)
          x = stack(x)
          if self.is_initializing():
              self.layer_names.extend(stack.layer_names)
      # TODO(evcu) make this safer. Each call adds new layer names to the
      # `stack.layer_names` since layer_names is treated as a class attribute
      # since it is mutable. Better way to do this would be to overwrite the
      # __init__ method to create instance objects.
      # Following will add all layer names in all stacks in order.
  
      x = nn.relu(x)
      x = x.reshape((-1))  # flatten
      layer = nn.Dense(
          features=_scale_width(512), kernel_init=initializer
      )
      x = layer(x)
      x = nn.relu(x)
      x = self._record_activations(x, layer)
      layer = nn.Dense(
          features=self.num_actions,
          kernel_init=initializer,
          name="final_layer",
      )
      q_values = layer(x)
      q_values = self._record_activations(q_values, layer)
      return atari_lib.DQNNetworkType(q_values)
  
imports: import math
  from dopamine.discrete_domains import atari_lib
  from flax import linen
  import gin
  import jax.numpy
label_desc: Use image node_id 2 for calling the ScalableDQNResNet obj's underlying member method code with example usage: obj.__call__(x) and returns: atari_lib, int