Hi,
I successfully exported a module with a method:
    @torch.jit.export
     def inference(self, text_inputs, speaker_embed, style_embed):

as
ts_prosody = torch.jit.script(model.prosody_generator)
ts_prosody.save(f"../inference/{model_name}_prosody.pt")
ts_prosody_mobile = optimize_for_mobile(ts_prosody, preserved_methods=["inference", "inference_half"])
torch.jit.save(ts_prosody_mobile,
                      f"../inference/{model_name}_prosody_mobile.pt")

I verified that in Python both ts_prosody_mobile.inference() and ts_prosody_mobile.inference_half() exist.
Now in Java/Android I load the models with Module.load
then
        IValue[] prosodyOutput = modelProsody.runMethod("inference", ... );
works.
But
      IValue[] prosodyOutput = modelProsodyMobile.runMethod("inference", ... );
gives me
java.lang.IllegalArgumentException: Undefined method inference
Is there anything I missed?
I am using in Python:
torch.version
‘1.9.0+cu111’
And Java from the Gradle file:
implementation ‘org.pytorch:pytorch_android:1.9.0’
Thanks!