I don’t know if there is an automatic way to transform the code directly to PyTorch and would recommend to split the code into small units and port these one by one verifying that each submodule is working correctly.