class_docstr: Patches for TensorFlow.
  
  There are multiple "monkey patches":
  1) Patches the `value` attribute of a `ResourceVariable` to return
  the `graph_element` or `cached_value` instead of a `ReadVariableOp`.
  Not having to read the variable from memory again can provide
  performance increases.
  2) Patches optimizers to save their type and arguments so that we
  can re-create them when partitioning variables.
  3) Patches Keras' `Session` fetcher to return AutoDist's custom `Session`
  so that AutoDist is compatible with Keras.
docstr: Patch all instances of OptimizerV2 for us to store optimizer and gradient information.
docstr_tok: ["Patch","all","instances","of","OptimizerV2","for","us","to","store","optimizer","and","gradient","information","."]
code: def patch_optimizers():
      """Patch all instances of OptimizerV2 for us to store optimizer and gradient information."""
      q = deque(
          chain(
              OptimizerV2.__subclasses__(), OptimizerV1.__subclasses__()
          )
      )
      while q:
          subclass = q.popleft()
          q.extend(list(subclass.__subclasses__()))
          subclass.__init__ = wrap_optimizer_init(subclass.__init__)
          subclass.apply_gradients = wrap_optimizer_apply_gradient(
              subclass.apply_gradients
          )
          logging.debug(
              "Optimizer type: %s has been patched" % subclass.__name__
          )
  
imports: from collections import deque
  from itertools import chain
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python import keras
  from tensorflow.python.client import session
  from tensorflow.python.framework import ops
  from tensorflow.python.keras.engine import training
  from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.resource_variable_ops import ResourceVariable
  from tensorflow.python.training.optimizer import Optimizer
  import autodist.autodist
  from autodist.graph_item import wrap_optimizer_init, wrap_optimizer_apply_gradient
  from autodist.runner import get_default_session_config
  from autodist.utils import logging
label_desc: Use image node_id 3 for calling the PatchTensorFlow obj's underlying member method code with example usage: obj.patch_optimizers() without return types