'Call `var.load(val)` with the default session.
Args:
var (tf.Variable):
strict (bool): Behave less strict if set to False.'

@staticmethod
def load_value_to_var(var, val, strict=False):

    if strict:
        var.load(val)
        return
    name = var.op.name
    varshape = tuple(var.get_shape().as_list())
    if (varshape != val.shape):
        assert (np.prod(varshape) == np.prod(val.shape)), '{}:    {}!={}'.format(name, varshape, val.shape)
        logger.warn('Variable    {}    is    reshaped    {}->{}    during    assigning'.format(name, val.shape, varshape))
        val = val.reshape(varshape)
    def upcast(vartype, valtype):
        if ((vartype == tf.float64) and (valtype == np.float32)):
            return np.float64
        if ((vartype in [tf.int64, tf.int32]) and (valtype in [np.int32, np.int16, np.int8])):
            return (np.int64 if (vartype == tf.int64) else np.int32)
        return None
    if hasattr(val, 'dtype'):
        vartype = var.value().dtype
        if (vartype != val.dtype):
            msg = 'Variable    {}    has    dtype    {}    but    was    given    a    value    of    dtype    {}.'.format(name, vartype, val.dtype)
            newtype = upcast(var.dtype, val.dtype)
            if (newtype is not None):
                val = newtype(val)
                logger.warn((msg + '    Load    it    after    casting!'))
            else:
                assert (vartype == val.dtype), msg
    try:
        var.load(val)
    except tf.errors.InvalidArgumentError:
        logger.exc('Cannot    load    this    value    to    the    variable    {}'.format(name))
