@classmethod
def initialize_with(cls, numpy_func, shape, *args, qhape=None, charge=None,
    invar=None, dirs=None, **kwargs):
    """Use the given `numpy_func` to initialize a tensor of `shape`."""
    shape = cls.flatten_shape(shape)
    res = numpy_func(shape, *args, **kwargs).view(cls)
    return res
