parameters: (self, variable_def, import_scope=None)
docstring: Initializes from `VariableDef` proto.
docstring_summary: Initializes from `VariableDef` proto.
docstring_tokens: Initializes from VariableDef proto .
function: def _init_from_proto(self, variable_def, import_scope=None):
      """Initializes from `VariableDef` proto."""
      assert isinstance(variable_def, variable_pb2.VariableDef)
      if not variable_def.is_resource:
        raise ValueError("Trying to restore Variable as ResourceVariable.")
  
      # Create from variable_def.
      g = ops.get_default_graph()
      self._handle = g.as_graph_element(
          ops.prepend_name_scope(variable_def.variable_name,
                                 import_scope=import_scope))
      self._initializer_op = g.as_graph_element(
          ops.prepend_name_scope(variable_def.initializer_name,
                                 import_scope=import_scope))
      if variable_def.snapshot_name:
        self._cached_value = g.as_graph_element(
            ops.prepend_name_scope(variable_def.snapshot_name,
                                   import_scope=import_scope))
      else:
        self._cached_value = None
      if variable_def.HasField("save_slice_info_def"):
        self._save_slice_info = variables.Variable.SaveSliceInfo(
            save_slice_info_def=variable_def.save_slice_info_def)
      else:
        self._save_slice_info = None
      self._caching_device = None
      self._dtype = dtypes.as_dtype(self._handle.op.get_attr("dtype"))
      self._graph_element = self.value()
function_tokens: def _init_from_proto ( self , variable_def , import_scope = None ) : assert isinstance ( variable_def , variable_pb2 . VariableDef ) if not variable_def . is_resource : raise ValueError ( "Trying to restore Variable as ResourceVariable." ) # Create from variable_def. g = ops . get_default_graph ( ) self . _handle = g . as_graph_element ( ops . prepend_name_scope ( variable_def . variable_name , import_scope = import_scope ) ) self . _initializer_op = g . as_graph_element ( ops . prepend_name_scope ( variable_def . initializer_name , import_scope = import_scope ) ) if variable_def . snapshot_name : self . _cached_value = g . as_graph_element ( ops . prepend_name_scope ( variable_def . snapshot_name , import_scope = import_scope ) ) else : self . _cached_value = None if variable_def . HasField ( "save_slice_info_def" ) : self . _save_slice_info = variables . Variable . SaveSliceInfo ( save_slice_info_def = variable_def . save_slice_info_def ) else : self . _save_slice_info = None self . _caching_device = None self . _dtype = dtypes . as_dtype ( self . _handle . op . get_attr ( "dtype" ) ) self . _graph_element = self . value ( )