code: def test_only_if(self):
      class Example(callbacks.Callback):
          @callbacks.only_if(lambda s: s[torchbearer.EPOCH] % 2 == 0)
          def on_step_validation(self, state):
              state["value"] += 1
  
      state = {torchbearer.EPOCH: 0, "value": 0}
  
      cb = Example()
  
      cb.on_step_validation(state)
      self.assertTrue(state["value"] == 1)
  
      cb.on_step_validation(state)
      self.assertTrue(state["value"] == 2)
  
      state[torchbearer.EPOCH] += 1
      cb.on_step_validation(state)
      self.assertTrue(state["value"] == 2)
  
      state[torchbearer.EPOCH] += 1
      cb.on_step_validation(state)
      self.assertTrue(state["value"] == 3)
  
imports: import unittest
  import torchbearer.callbacks
  import torchbearer
label_desc: Use image node_id 25 for calling the TestDecorators obj's underlying member method code with example usage: obj.test_only_if() without return types