def _set_checkpoint_initializer(variable, ckpt_file, tensor_name, slice_spec, name='checkpoint_initializer', write_version=saver_pb2.SaverDef.DIT):
    "Overrides given variable's initialization op.\n\n  Sets variable initializer to assign op that initializes variable from tensor's\n  value in the checkpoint.\n\n  Args:\n    variable: `tf.Variable` object.\n    ckpt_file: string, full path of the checkpoint.\n    tensor_name: Name of the tensor to load from the checkpoint.\n    slice_spec: Slice specification for loading partitioned tensors.\n    name: Name of the operation.\n  "
    base_type = variable.dtype.base_dtype
    with ops.device(variable.device), ops.device('/cpu:0'):
        if ((self._write_version == saver_pb2.SaverDef.V1) or (self._write_version == saver_pb2.SaverDef.V2)):
            restore_op = io_ops.restore_v2(ckpt_file, [tensor_name], [slice_spec], [base_type], name=name)[0]
        elif (self._write_version == saver_pb2.SaverDef.DIT):
            restore_op = io_ops.restore_dit(ckpt_file, [tensor_name], [slice_spec], [base_type], name=name)[0]
        else:
            raise RuntimeError(('Unexpected write_version: ' + self._write_version))
        names_to_saveables = saveable_object_util.op_list_to_dict([variable])
        saveable_objects = []
        for (name, op) in names_to_saveables.items():
            for s in saveable_object_util.saveable_objects_for_op(op, name):
                saveable_objects.append(s)
        assert (len(saveable_objects) == 1)
    init_op = saveable_objects[0].restore([restore_op], restored_shapes=None)
    variable._initializer_op = init_op
    restore_op.set_shape(variable.shape)
    variable._initial_value = restore_op
Overrides given variable's initialization op.

Sets variable initializer to assign op that initializes variable from tensor's
value in the checkpoint.

Args:
  variable: `tf.Variable` object.
  ckpt_file: string, full path of the checkpoint.
  tensor_name: Name of the tensor to load from the checkpoint.
  slice_spec: Slice specification for loading partitioned tensors.
  name: Name of the operation.
def _set_checkpoint_initializer(variable, ckpt_file, tensor_name, slice_spec, name='checkpoint_initializer', write_version=saver_pb2.SaverDef.DIT):
    "Overrides given variable's initialization op.\n\n  Sets variable initializer to assign op that initializes variable from tensor's\n  value in the checkpoint.\n\n  Args:\n    variable: `tf.Variable` object.\n    ckpt_file: string, full path of the checkpoint.\n    tensor_name: Name of the tensor to load from the checkpoint.\n    slice_spec: Slice specification for loading partitioned tensors.\n    name: Name of the operation.\n  "
    base_type = variable.dtype.base_dtype
    with ops.device(variable.device), ops.device('/cpu:0'):
        if ((self._write_version == saver_pb2.SaverDef.V1) or (self._write_version == saver_pb2.SaverDef.V2)):
            restore_op = io_ops.restore_v2(ckpt_file, [tensor_name], [slice_spec], [base_type], name=name)[0]
        elif (self._write_version == saver_pb2.SaverDef.DIT):
            restore_op = io_ops.restore_dit(ckpt_file, [tensor_name], [slice_spec], [base_type], name=name)[0]
        else:
            raise RuntimeError(('Unexpected write_version: ' + self._write_version))
        names_to_saveables = saveable_object_util.op_list_to_dict([variable])
        saveable_objects = []
        for (name, op) in names_to_saveables.items():
            for s in saveable_object_util.saveable_objects_for_op(op, name):
                saveable_objects.append(s)
        assert (len(saveable_objects) == 1)
    init_op = saveable_objects[0].restore([restore_op], restored_shapes=None)
    variable._initializer_op = init_op
    restore_op.set_shape(variable.shape)
    variable._initial_value = restore_op