It’s a Python question, use some dirty trick
def forward(self, x):

        x = self.conv1(x)
        x=self.R1(x)
        ........
        ........
         
       layer1_var=self.variance(x) ##calculate variance
      if self.plot:
             feature_maps( layer1_var)
             self.plot=False


for epoch in range(10):
         model.plot=True
         for data in dataloader:
                  output = model(input)