model.train() and model.eval() are flags that tell the model that you are training the model and testing mode respectively. This will make the model behave accordingly to techniques such us dropout that have different procedures in train and testing mode.
class NeuralNet(torch.nn.Module):
    def __init__(self, input_size, hidden_size, num_classes):
        super(NeuralNet, self).__init__()
        # Code..

    def forward(self, x):
        out = some_func(x)
         ## Code..
        return out

Suppose I’ve written a different function some_func() that I want to be executed only on training mode. How can I modify the functions model.train() and model.eval() to do that ?