Regarding Java code, as long as we can build the C++ API for Android, we can use that from Java with the JavaCPP Presets for PyTorch:
  
      
      github.com
  
  
    

bytedeco/javacpp-presets 3

master/pytorch

  The missing Java distribution of native C++ libraries