class_docstr: A helper ContextManager decorating a method with a custom function.
class_docstr_tok: ["A","helper","ContextManager","decorating","a","method","with","a","custom","function","."]
code: def __enter__(self):
      self.original_method = getattr(self.classx, self.method_name)
      if not hasattr(
          self.original_method,
          "sacred_patched%s" % self.__class__.__name__,
      ):
  
          @functools.wraps(self.original_method)
          def decorated(instance, *args, **kwargs):
              return self.decorator_func(
                  instance, self.original_method, args, kwargs
              )
  
          setattr(self.classx, self.method_name, decorated)
          setattr(
              decorated,
              "sacred_patched%s" % self.__class__.__name__,
              True,
          )
          self.patched_by_me = True
  
imports: import functools
label_desc: Use image node_id 2 for calling the ContextMethodDecorator obj's underlying member method code with example usage: obj.__enter__() and returns: self