Thanks, I can see how that solves the problem.  But I don’t understand why it was set up this way.  Usually if you are trying to change an attribute or a setting, the method would be called something like set_attribute(value).  In this case, set_mode("train") maybe or set_trainmode(True).  A method of this type would not be expected to return a value.  model.train() sounds like it is going to actually train the network.  Not very Pythonic!