in tasks/hierar-or-linear/generate_data.py [0:0]
def put_train_mdl(root, train_depth, test_from, test_to, rule):
with open(f'{root}/train.src', 'w') as train_src, open(f'{root}/train.dst', 'w') as train_tgt:
depths = [train_depth] + [d for d in range(test_from, test_to) if d != train_depth]
for d in depths:
for central_symbol, wrapper in itertools.product(['a', 'b'], ['a', 'b']):
train_input = [wrapper] * d + [central_symbol] + [wrapper] * d
print(' '.join(train_input), file=train_src)
print(rule(train_input), file=train_tgt)