def METHOD_NAME(name, value=None, dtype=np.dtype("float32"), N=None):
    buf = getattr(storage, name, None)
    if value is not None:
        N = len(value)
        dtype = value.dtype
    if dtype.name == "float64":
        warnings.warn("Casting input argument from float64 to float32 since Metal does not support float64")
        dtype = np.dtype("float32")
    nbytes = N * dtype.itemsize
    if buf is not None and buf.length() != nbytes:
        # doesn't match size, create a new one
        buf = None
    # create a buffer
    if buf is None:
        buf = self.device.newBufferWithLength_options_(nbytes, 0)
        setattr(storage, name, buf)
    # copy data to buffer
    if value is not None:
        mv = buf.contents().as_buffer(buf.length())
        buf_as_numpy = np.frombuffer(mv, dtype=dtype)
        buf_as_numpy[:] = value.astype(dtype, copy=False)
    return buf