class_docstr: Support class for stubbing methods out for unit testing.
  
  Sample Usage:
  
  You want os.path.exists() to always return true during testing.
  
     stubs = StubOutForTesting()
     stubs.Set(os.path, 'exists', lambda x: 1)
       ...
     stubs.CleanUp()
  
  The above changes os.path.exists into a lambda that returns 1.  Once
  the ... part of the code finishes, the CleanUp() looks up the old
  value of os.path.exists and restores it.
class_docstr_tok: ["Support","class","for","stubbing","methods","out","for","unit","testing",".","Sample","Usage",":","You","want","os.path.exists","(",")","to","always","return","true","during","testing",".","stubs","=","StubOutForTesting","(",")","stubs.Set","(","os.path",",","'exists","'",",","lambda","x",":","1",")","...","stubs.CleanUp","(",")","The","above","changes","os.path.exists","into","a","lambda","that","returns","1",".","Once","the","...","part","of","the","code","finishes",",","the","CleanUp","(",")","looks","up","the","old","value","of","os.path.exists","and","restores","it","."]
docstr: In parent, replace child_name's old definition with new_child.
  
  The parent could be a module when the child is a function at
  module scope.  Or the parent could be a class when a class' method
  is being replaced.  The named child is set to new_child, while the
  prior definition is saved away for later, when UnsetAll() is
  called.
  
  This method supports the case where child_name is a staticmethod or a
  classmethod of parent.
  
  Args:
    parent: The context in which the attribute child_name is to be changed.
    child_name: The name of the attribute to change.
    new_child: The new value of the attribute.
docstr_tok: ["In","parent",",","replace","child_name","'s","old","definition","with","new_child",".","The","parent","could","be","a","module","when","the","child","is","a","function","at","module","scope",".","Or","the","parent","could","be","a","class","when","a","class","'","method","is","being","replaced",".","The","named","child","is","set","to","new_child",",","while","the","prior","definition","is","saved","away","for","later",",","when","UnsetAll","(",")","is","called",".","This","method","supports","the","case","where","child_name","is","a","staticmethod","or","a","classmethod","of","parent",".","Args",":","parent",":","The","context","in","which","the","attribute","child_name","is","to","be","changed",".","child_name",":","The","name","of","the","attribute","to","change",".","new_child",":","The","new","value","of","the","attribute","."]
code: def Set(self, parent, child_name, new_child):
      """In parent, replace child_name's old definition with new_child.
  
      The parent could be a module when the child is a function at
      module scope.  Or the parent could be a class when a class' method
      is being replaced.  The named child is set to new_child, while the
      prior definition is saved away for later, when UnsetAll() is
      called.
  
      This method supports the case where child_name is a staticmethod or a
      classmethod of parent.
  
      Args:
        parent: The context in which the attribute child_name is to be changed.
        child_name: The name of the attribute to change.
        new_child: The new value of the attribute.
      """
      old_child = getattr(parent, child_name)
  
      old_attribute = parent.__dict__.get(child_name)
      if old_attribute is not None and isinstance(
          old_attribute, staticmethod
      ):
          old_child = staticmethod(old_child)
  
      self.cache.append((parent, old_child, child_name))
      setattr(parent, child_name, new_child)
  
imports: import atexit
  import os
  import sys
  import tempfile
  from absl import app
  from absl.testing.absltest import *
  from tensorflow.python.framework import errors
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.platform import benchmark
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import tf_decorator
  from tensorflow.python.util import tf_inspect
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 8 for calling the StubOutForTesting obj's underlying member method code with example usage: obj.Set(parent, child_name, new_child) without return types