class_docstr: Abstract base PyTorch compressor
code: def patch_optimizer(self, *tasks):
      def patch_step(old_step):
          def new_step(_, *args, **kwargs):
              # call origin optimizer step method
              output = old_step(*args, **kwargs)
              # calculate mask
              for task in tasks:
                  task()
              return output
  
          return new_step
  
      if self.optimizer is not None:
          self.optimizer.step = types.MethodType(
              patch_step(self.optimizer.step), self.optimizer
          )
  
imports: import types
  import logging
  import torch
  from .None import default_layers
label_desc: Use image node_id 16 for calling the Compressor obj's underlying member method code with example usage: obj.patch_optimizer() and returns: new_step, output