def METHOD_NAME(self, data):
    if isinstance(data, collections.abc.Mapping):
        return {key: self.to_gpu(data[key] if self.mask[idx] else data[key]) for idx, key in enumerate(data)}
    if isinstance(data, collections.abc.Sequence):
        return [self.to_gpu(v) if self.mask[idx] else v for idx, v in enumerate(data)]
    raise Exception("mask only supports list/tuple/dict data type")