For a Module under transformation, the same outside submodule can be passed in multiple times. Inside the transform boundary this means that multiple copies of the same submodule can point to the same duplicated Scope object. For compact submodules, this scope is rewound by returning a new rewound scope, but this doesn't correctly rewind the second reference of the original un-rewound scope. We solve this by making the single use of rewound in nn.Module instead call a new in-place "rewind" function that correctly updates all references to the scope object.
this occurs because in dupscopes, if the "paths" argument has duplicate root scopes as occurs above, for root scopes with trivial paths, we'll return identical root scope references.
This also includes a few type annotation fixes.