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: It only works with tf.gradients but not tape.gradients.
docstr_tok: ["It","only","works","with","tf.gradients","but","not","tape.gradients","."]
code: def patch_var_reading():
      """It only works with tf.gradients but not tape.gradients."""
  
      def value(self):
          """A cached operation which reads the value of this variable."""
          if self._cached_value is not None:
              return self._cached_value
          with ops.colocate_with(None, ignore_existing=True):
              with ops.device(self._handle.device):
                  # return self._read_variable_op() # original line
                  return self._graph_element
  
      setattr(ResourceVariable, "value", value)
      logging.warning(
          "Resource variable is patched "
          "to behave as ref (only on reading) to avoid multiple recv_tensor."
      )
  
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 1 for calling the PatchTensorFlow obj's underlying member method code with example usage: obj.patch_var_reading() and returns: self, self