<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prepare(self, data, groupname):
 """Clear the group if existing and initialize empty datasets."""

        if groupname in self.h5file:
            del self.h5file[groupname]
        group = self.h5file.create_group(groupname)
        group.attrs['version'] = self.version
        data.init_group(
            group, self.chunk_size, self.compression, self.compression_opts)
        return group