Maybe I can do this in the initializer like this:
class ModuleB(jit.ScriptModule):

   def __init__(self):
         if TRAINING:
             self.forward = self.forward_training
         else:
             self.forward = self.forward_inference

   @jit.script_method
   def forward_inference(self, inputs)
   def forward_training(self, inputs):