<commit_before>import math
import logging

import torch
from torch.utils.data import Dataset

logger = logging.getLogger(__name__)


class BaseDataset:
    """
    This is a base class to used for manipulating a dataset. This is composed
    of a .data attribute for inputs and a .targets one for labels. It is to
    be used like the MNIST Dataset object, and is useful to avoid handling
    the two inputs and label tensors separately.
    """

    def __init__(self, data, targets):
        self.data = data
        self.targets = targets

    def __len__(self):
        return len(self.data)

    def __getitem__(self, index):
        return self.data[index], self.targets[index]

    def send(self, worker):
        self.data.send_(worker)
        self.targets.send_(worker)
        return self

    def get(self):
        self.data.get_()
        self.targets.get_()
        return self

    @property
    def location(self):
        return self.data.location<commit_msg>Add ability to fix_prec / share a sy.BaseDataset<commit_after>import math
import logging

import torch
from torch.utils.data import Dataset

logger = logging.getLogger(__name__)


class BaseDataset:
    """
    This is a base class to used for manipulating a dataset. This is composed
    of a .data attribute for inputs and a .targets one for labels. It is to
    be used like the MNIST Dataset object, and is useful to avoid handling
    the two inputs and label tensors separately.
    """

    def __init__(self, data, targets):
        self.data = data
        self.targets = targets

    def __len__(self):
        return len(self.data)

    def __getitem__(self, index):
        return self.data[index], self.targets[index]

    def send(self, worker):
        self.data.send_(worker)
        self.targets.send_(worker)
        return self

    def get(self):
        self.data.get_()
        self.targets.get_()
        return self

    def fix_prec(self, *args, **kwargs):
        self.data.fix_prec_(*args, **kwargs)
        self.targets.fix_prec_(*args, **kwargs)
        return self

    fix_precision = fix_prec

    def float_prec(self, *args, **kwargs):
        self.data.float_prec_(*args, **kwargs)
        self.targets.float_prec_(*args, **kwargs)
        return self

    float_precision = float_prec

    def share(self, *args, **kwargs):
        self.data.share_(*args, **kwargs)
        self.targets.share_(*args, **kwargs)
        return self

    @property
    def location(self):
        return self.data.location
{'fraction_non_alphanumeric': 0.09145129224652088, 'fraction_numerical': 0.0, 'mean_word_length': 2.5586987270155586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2482727', 'n_tokens_mistral': 748, 'n_tokens_neox': 710, 'n_words': 237}