class_docstr: A checkpointable object whose NumPy array attributes are saved/restored.
  
  Example usage:
  
  ```python
  arrays = _NumpyState()
  checkpoint = tf.train.Checkpoint(numpy_arrays=arrays)
  arrays.x = numpy.zeros([3, 4])
  save_path = checkpoint.save("/tmp/ckpt")
  arrays.x[1, 1] = 4.
  checkpoint.restore(save_path)
  assert (arrays.x == numpy.zeros([3, 4])).all()
  
  second_checkpoint = tf.train.Checkpoint(
      numpy_arrays=_NumpyState())
  # Attributes of NumpyState objects are created automatically by restore()
  second_checkpoint.restore(save_path)
  assert (second_checkpoint.numpy_arrays.x == numpy.zeros([3, 4])).all()
  ```
  
  Note that `NumpyState` objects re-create the attributes of the previously
  saved object on `restore()`. This is in contrast to TensorFlow variables, for
  which a `Variable` object must be created and assigned to an attribute.
  
  This snippet works both when graph building and when executing eagerly. On
  save, the NumPy array(s) are fed as strings to be saved in the checkpoint (via
  a placeholder when graph building, or as a string constant when executing
  eagerly). When restoring they skip the TensorFlow graph entirely, and so no
  restore ops need be run. This means that restoration always happens eagerly,
  rather than waiting for `checkpoint.restore(...).run_restore_ops()` like
  TensorFlow variables when graph building.
class_docstr_tok: ["A","checkpointable","object","whose","NumPy","array","attributes","are","saved\/restored",".","Example","usage",":","``","`","python","arrays","=","_NumpyState","(",")","checkpoint","=","tf.train.Checkpoint","(","numpy_arrays=arrays",")","arrays.x","=","numpy.zeros","(","[","3",",","4","]",")","save_path","=","checkpoint.save","(","``","\/tmp\/ckpt","''",")","arrays.x","[","1",",","1","]","=","4.","checkpoint.restore","(","save_path",")","assert","(","arrays.x","==","numpy.zeros","(","[","3",",","4","]",")",")",".all","(",")","second_checkpoint","=","tf.train.Checkpoint","(","numpy_arrays=_NumpyState","(",")",")","#","Attributes","of","NumpyState","objects","are","created","automatically","by","restore","(",")","second_checkpoint.restore","(","save_path",")","assert","(","second_checkpoint.numpy_arrays.x","==","numpy.zeros","(","[","3",",","4","]",")",")",".all","(",")","``","`","Note","that","`","NumpyState","`","objects","re-create","the","attributes","of","the","previously","saved","object","on","`","restore","(",")","`",".","This","is","in","contrast","to","TensorFlow","variables",",","for","which","a","`","Variable","`","object","must","be","created","and","assigned","to","an","attribute",".","This","snippet","works","both","when","graph","building","and","when","executing","eagerly",".","On","save",",","the","NumPy","array","(","s",")","are","fed","as","strings","to","be","saved","in","the","checkpoint","(","via","a","placeholder","when","graph","building",",","or","as","a","string","constant","when","executing","eagerly",")",".","When","restoring","they","skip","the","TensorFlow","graph","entirely",",","and","so","no","restore","ops","need","be","run",".","This","means","that","restoration","always","happens","eagerly",",","rather","than","waiting","for","`","checkpoint.restore","(","...",")",".run_restore_ops","(",")","`","like","TensorFlow","variables","when","graph","building","."]
docstr: Automatically wrap NumPy arrays assigned to attributes.
docstr_tok: ["Automatically","wrap","NumPy","arrays","assigned","to","attributes","."]
code: def __setattr__(self, name, value):
      """Automatically wrap NumPy arrays assigned to attributes."""
      if isinstance(value, (numpy.ndarray, numpy.generic)):
          try:
              existing = getattr(self._arrays, name)
              existing.array = value
              return
          except AttributeError:
              value = _NumpyWrapper(value)
          setattr(self._arrays, name, value)
          return
      super(_NumpyState, self).__setattr__(name, value)
  
imports: import io
  import os
  import numpy
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.client import session
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.module import module
  from tensorflow.python.platform import test
  from tensorflow.python.trackable import python_state
label_desc: Use image node_id 3 for calling the _NumpyState obj's underlying member method code with example usage: obj.__setattr__(name, value) without return types