class_docstr: Base class representing a function patch implementation with a callback for error handling.
  `PatchFunction` should be subclassed and used in conjunction with `safe_patch` to
  safely modify the implementation of a function. Subclasses of `PatchFunction` should
  use `_patch_implementation` to define modified ("patched") function implementations and
  `_on_exception` to define cleanup logic when `_patch_implementation` terminates due
  to an unhandled exception.
class_docstr_tok: ["Base","class","representing","a","function","patch","implementation","with","a","callback","for","error","handling",".","`","PatchFunction","`","should","be","subclassed","and","used","in","conjunction","with","`","safe_patch","`","to","safely","modify","the","implementation","of","a","function",".","Subclasses","of","`","PatchFunction","`","should","use","`","_patch_implementation","`","to","define","modified","(","``","patched","''",")","function","implementations","and","`","_on_exception","`","to","define","cleanup","logic","when","`","_patch_implementation","`","terminates","due","to","an","unhandled","exception","."]
docstr: Called when an unhandled standard Python exception (i.e. an exception inheriting from
  `Exception`) or a `KeyboardInterrupt` prematurely terminates the execution of
  `_patch_implementation`.
  
  Args:
      exception: The unhandled exception thrown by `_patch_implementation`.
docstr_tok: ["Called","when","an","unhandled","standard","Python","exception","(","i.e",".","an","exception","inheriting","from","`","Exception","`",")","or","a","`","KeyboardInterrupt","`","prematurely","terminates","the","execution","of","`","_patch_implementation","`",".","Args",":","exception",":","The","unhandled","exception","thrown","by","`","_patch_implementation","`","."]
code: def _on_exception(self, exception):
      """Called when an unhandled standard Python exception (i.e. an exception inheriting from
      `Exception`) or a `KeyboardInterrupt` prematurely terminates the execution of
      `_patch_implementation`.
  
      Args:
          exception: The unhandled exception thrown by `_patch_implementation`.
      """
      pass
  
imports: import abc
  import functools
  import inspect
  import itertools
  import typing
  import uuid
  from abc import abstractmethod
  from contextlib import contextmanager
  import mlflow
  import mlflow.utils.autologging_utils
  from mlflow.entities.run_status import RunStatus
  from mlflow.environment_variables import _MLFLOW_AUTOLOGGING_TESTING
  from mlflow.tracking.client import MlflowClient
  from mlflow.utils import gorilla, is_iterator
  from mlflow.utils.autologging_utils import _logger
  from mlflow.utils.autologging_utils.events import AutologgingEventLogger
  from mlflow.utils.autologging_utils.logging_and_warnings import set_mlflow_events_and_warnings_behavior_globally, set_non_mlflow_warnings_behavior_for_current_thread
  from mlflow.utils.mlflow_tags import MLFLOW_AUTOLOGGING
label_desc: Use image node_id 2 for calling the PatchFunction obj's underlying member method code with example usage: obj._on_exception(exception) without return types