class NeuralNet(tc.Tuple):
"""abstract methods omitted here"""
# the network architecture, like this parameter `n`,
# must be known at compile-time in order to construct
# an Optimizer for this ML model
# because the form of `DNN.forward` depends on `n`,
# the `DNN.forward` method must be defined at compile-time
def forward(self, inputs):
# `layers` is defined in the compile-time context
# so even though we have access to `layers` here,
# we still have to reference `self[i]` instead of `layers`
# otherwise the ops could fail at run-time because
# they might depend on a state that was only defined
state = self[0].forward(inputs)
state = self[i].forward(state)
# here the form of the returned instance is set to `layers`