In order to make it more reusable, we want to support parameter management, CPU/GPU migration, robust and flexible save/load features, etc.
These features are all supported by the Chain class in Chainer.
Then, what we have to do here is just define the above class as a subclass of Chain:

It shows how a complex chain is constructed by simpler links.
Links like l1 and l2 are called child links of MyChain.
Note that Chain itself inherits Link.
It means we can define more complex chains that hold MyChain objects as their child links.

Note

We often define a single forward method of a link by the forward operator.
Such links and chains are callable and behave like regular functions of Variables.

Another way to define a chain is using the ChainList class, which behaves like a list of links: