def METHOD_NAME(f, key, boundaries, ids):
    dset = f[key]
    refs = []
    for j in range(len(boundaries) - 1):
        l, r = boundaries[ids[j]], boundaries[ids[j]+1]
        refs.append(dset.regionref[l:r]) 
    f.create_dataset(key+'_template', data=refs,
                     dtype=h5py.special_dtype(ref=h5py.RegionReference))