See implementation notes which includes explanation of the various implementation versions, and additional details, such as an extension of the custom Subsampling layer.