Imported from https://github.com/ArchipLab-LinfengZhang/pytorch-scalable-neural-networks