in augmentation/augmenters.py [0:0]
def substitute(self, text):
translated = self.sample_n(
self.model.from_model,
text,
beam=self.n_predictions,
n_samples=self.n_predictions,
**self.generation_kwargs
)
result = []
for t in translated:
nested = self.sample_n(
self.model.to_model,
t,
beam=self.n_predictions,
n_samples=self.n_predictions,
**self.generation_kwargs
) # List[List[str]]
backtranslated = list(set(
deepflatten_sequence(nested)
)) # List[str] with unique entries
result.append(backtranslated)
return result