(self)
Create batches
Create batches
Create batches
def create_batches(self):
        """ Create batches """
        if self.train:
            def _pool(data, random_shuffler):
                for p in torchtext.data.batch(data, self.batch_size * 100):
                    p_batch = torchtext.data.batch(
                        sorted(p, key=self.sort_key),
                        self.batch_size, self.batch_size_fn)
                    for b in random_shuffler(list(p_batch)):
                        yield b

            self.batches = _pool(self.data(), self.random_shuffler)
        else:
            self.batches = []
            for b in torchtext.data.batch(self.data(), self.batch_size,
                                          self.batch_size_fn):
                self.batches.append(sorted(b, key=self.sort_key))
def create_batches ( self ) : if self . train : def _pool ( data , random_shuffler ) : for p in torchtext . data . batch ( data , self . batch_size * 100 ) : p_batch = torchtext . data . batch ( sorted ( p , key = self . sort_key ) , self . batch_size , self . batch_size_fn ) for b in random_shuffler ( list ( p_batch ) ) : yield b self . batches = _pool ( self . data ( ) , self . random_shuffler ) else : self . batches = [ ] for b in torchtext . data . batch ( self . data ( ) , self . batch_size , self . batch_size_fn ) : self . batches . append ( sorted ( b , key = self . sort_key ) )