From your post, I see that you want to avoid classes and inheritance.
You could look at Sergey Zagoruyko’s purely functional implementation of Wide ResNets:

  
      github.com
  
  
    pytorch/examples/blob/4f58379e51c563b8e461b7f99cb09714cdabd34d/resnet/main.py 59
"""
    PyTorch training code for Wide Residual Networks:
    http://arxiv.org/abs/1605.07146

    The code reproduces *exactly* it's lua version:
    https://github.com/szagoruyko/wide-residual-networks

    2016 Sergey Zagoruyko
"""

import argparse
import os
import json
import numpy as np
import math
from tqdm import tqdm
from nested_dict import nested_dict
from collections import OrderedDict
import torch
import torch.optim


  This file has been truncated. show original