-
Notifications
You must be signed in to change notification settings - Fork 6
/
pointerNetwork.py
598 lines (506 loc) · 25.3 KB
/
pointerNetwork.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
from utilities import *
import random
import math
import torch.nn as nn
import torch
import torch.nn.functional as F
import torch.optim as optimization
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
from MHDPA import *
from programGraph import ProgramGraph
from API import Program
import numpy as np
class Pointer():
def __init__(self, i, m=None):
self.i = i
self.m = m
def __str__(self): return f"P({self.i}, max={self.m})"
def __repr__(self): return str(self)
class SymbolEncoder(Module):
def __init__(self, lexicon, H=256):
super(SymbolEncoder, self).__init__()
self.encoder = nn.Embedding(len(lexicon), H)
self.lexicon = lexicon
self.wordToIndex = {w: j for j,w in enumerate(self.lexicon) }
self.finalize()
def forward(self, objects):
return self.encoder(self.device(torch.tensor([self.wordToIndex[o] for o in objects])))
class LineDecoder(Module):
def __init__(self, lexicon, H=256, encoderDimensionality=256, layers=1):
"""
H: Hidden size for GRU & size of embedding of output tokens
encoderDimensionality: Dimensionality of objects we are attending over (objects we can point to)
lexicon: list of symbols that can occur in a line of code. STARTING, ENDING, & POINTER are reserved symbols.
"""
super(LineDecoder, self).__init__()
self.encoderDimensionality = encoderDimensionality
self.model = nn.GRU(H + encoderDimensionality, H, layers)
self.specialSymbols = [
"STARTING", "ENDING", "POINTER"
]
self.lexicon = lexicon + self.specialSymbols
self.wordToIndex = {w: j for j,w in enumerate(self.lexicon) }
self.embedding = nn.Embedding(len(self.lexicon), H)
self.output = nn.Sequential(nn.Linear(H, len(self.lexicon)),
nn.LogSoftmax())
self.decoderToPointer = nn.Linear(H, H, bias=False)
self.encoderToPointer = nn.Linear(encoderDimensionality, H, bias=False)
self.attentionSelector = nn.Linear(H, 1, bias=False)
self.pointerIndex = self.wordToIndex["POINTER"]
self.finalize()
def pointerAttention(self, hiddenStates, objectEncodings, _=None,
pointerBounds=[], objectKeys=None):
"""
hiddenStates: BxH
objectEncodings: (# objects)x(encoder dimensionality); if this is set to none, expects:
objectKeys: (# objects)x(key dimensionality; this is H passed to constructor)
OUTPUT: Bx(# objects) attention matrix
"""
hiddenStates = self.decoderToPointer(hiddenStates)
if objectKeys is None:
objectKeys = self.encoderToPointer(objectEncodings)
else:
assert objectEncodings is None, "You either provide object encodings or object keys but not both"
_h = hiddenStates.unsqueeze(1).repeat(1, objectKeys.size(0), 1)
_o = objectKeys.unsqueeze(0).repeat(hiddenStates.size(0), 1, 1)
attention = self.attentionSelector(torch.tanh(_h + _o)).squeeze(2)
#attention = self.attentionSelector(torch.tanh(_h * some_bilinear * _o)).squeeze(2)
mask = np.zeros((hiddenStates.size(0), objectKeys.size(0)))
for p,b in enumerate(pointerBounds):
if b is not None:
mask[p, b:] = NEGATIVEINFINITY
return F.log_softmax(attention + self.device(torch.tensor(mask).float()), dim=1)
def logLikelihood_hidden(self, initialState, target, encodedInputs):
symbolSequence = [self.wordToIndex[t if not isinstance(t,Pointer) else "POINTER"]
for t in ["STARTING"] + target + ["ENDING"] ]
# inputSequence : L x H
inputSequence = self.tensor(symbolSequence[:-1])
outputSequence = self.tensor(symbolSequence[1:])
inputSequence = self.embedding(inputSequence)
# Concatenate the object encodings w/ the inputs
objectInputs = self.device(torch.zeros(len(symbolSequence) - 1, self.encoderDimensionality))
for t, p in enumerate(target):
if isinstance(p, Pointer):
objectInputs[t + 1] = encodedInputs[p.i]
objectInputs = objectInputs
inputSequence = torch.cat([inputSequence, objectInputs], 1).unsqueeze(1)
if initialState is not None: initialState = initialState.unsqueeze(0).unsqueeze(0)
o, h = self.model(inputSequence, initialState)
# output sequence log likelihood, ignoring pointer values
sll = -F.nll_loss(self.output(o.squeeze(1)), outputSequence, reduce=True, size_average=False)
# pointer value log likelihood
pointerTimes = [t - 1 for t,s in enumerate(symbolSequence) if self.pointerIndex == s ]
if len(pointerTimes) == 0:
pll = 0.
else:
assert encodedInputs is not None
pointerValues = [v.i for v in target if isinstance(v, Pointer) ]
pointerBounds = [v.m for v in target if isinstance(v, Pointer) ]
pointerHiddens = o[self.tensor(pointerTimes),:,:].squeeze(1)
attention = self.pointerAttention(pointerHiddens, encodedInputs,
pointerBounds=pointerBounds)
pll = -F.nll_loss(attention, self.tensor(pointerValues),
reduce=True, size_average=False)
return sll + pll, h
def logLikelihood(self, initialState, target, encodedInputs):
return self.logLikelihood_hidden(initialState, target, encodedInputs)[0]
def sample(self, initialState, encodedInputs):
sequence = ["STARTING"]
h = initialState
while len(sequence) < 100:
lastWord = sequence[-1]
if isinstance(lastWord, Pointer):
latestPointer = encodedInputs[lastWord.i]
lastWord = "POINTER"
else:
latestPointer = self.device(torch.zeros(self.encoderDimensionality))
i = self.embedding(self.tensor(self.wordToIndex[lastWord]))
i = torch.cat([i, latestPointer])
if h is not None: h = h.unsqueeze(0).unsqueeze(0)
o,h = self.model(i.unsqueeze(0).unsqueeze(0), h)
o = o.squeeze(0).squeeze(0)
h = h.squeeze(0).squeeze(0)
# Sample the next symbol
distribution = self.output(o)
next_symbol = self.lexicon[torch.multinomial(distribution.exp(), 1)[0].data.item()]
if next_symbol == "ENDING":
break
if next_symbol == "POINTER":
if encodedInputs is not None:
# Sample the next pointer
a = self.pointerAttention(h.unsqueeze(0), encodedInputs, []).squeeze(0)
next_symbol = Pointer(torch.multinomial(a.exp(),1)[0].data.item())
else:
return None
sequence.append(next_symbol)
return sequence[1:]
def beam(self, initialState, encodedObjects, B,
maximumLength=50):
"""Given an initial hidden state, of size H, and the encodings of the
objects in scope, of size Ox(self.encoderDimensionality), do a beam
search with beam width B. Returns a list of (log likelihood, sequence of tokens)"""
master = self
class Particle():
def __init__(self, h, ll, sequence):
self.h = h
self.ll = ll
self.sequence = sequence
def input(self):
lastWord = self.sequence[-1]
if isinstance(lastWord, Pointer):
latestPointer = encodedObjects[lastWord.i]
lastWord = "POINTER"
else:
latestPointer = master.device(torch.zeros(master.encoderDimensionality))
return torch.cat([master.embedding(master.tensor(master.wordToIndex[lastWord])), latestPointer])
@property
def finished(self): return self.sequence[-1] == "ENDING"
def children(self, outputDistribution, pointerDistribution, newHidden):
if self.finished: return [self]
def tokenLikelihood(token):
if isinstance(token, Pointer):
return outputDistribution[master.pointerIndex] + pointerDistribution[token.i]
return outputDistribution[master.wordToIndex[token]]
bestTokens = list(sorted([ t for t in master.lexicon if t not in ["STARTING","POINTER"] ] + \
[Pointer(i) for i in range(numberOfObjects) ],
key=tokenLikelihood, reverse=True))[:B]
return [Particle(newHidden, self.ll + tokenLikelihood(t),
self.sequence + [t])
for t in bestTokens ]
def trimmed(self):
if self.sequence[-1] == "ENDING": return self.sequence[1:-1]
return self.sequence[1:]
particles = [Particle(initialState, 0., ["STARTING"])]
if encodedObjects is not None:
objectKeys = self.encoderToPointer(encodedObjects)
numberOfObjects = objectKeys.size(0)
else:
numberOfObjects = 0
for _ in range(maximumLength):
unfinishedParticles = [p for p in particles if not p.finished ]
inputs = torch.stack([p.input() for p in unfinishedParticles]).unsqueeze(0)
if any( p.h is not None for p in unfinishedParticles ):
hs = torch.stack([p.h for p in unfinishedParticles]).unsqueeze(0)
else:
hs = None
o, h = self.model(inputs, hs)
o = o.squeeze(0)
h = h.squeeze(0)
outputDistributions = self.output(o).detach().cpu().numpy()
if encodedObjects is not None:
attention = self.pointerAttention(h, None, objectKeys=objectKeys).detach().cpu().numpy()
else:
attention = [None]*len(unfinishedParticles)
particles = [child
for j,p in enumerate(unfinishedParticles)
for child in p.children(outputDistributions[j], attention[j], h[j]) ] + \
[p for p in particles if p.finished ]
particles.sort(key=lambda p: p.ll, reverse=True)
particles = particles[:B]
if all( p.finished for p in particles ): break
return [(p.ll, p.trimmed()) for p in particles if p.finished]
def bestFirstEnumeration(self, initialState, encodedObjects):
"""Given an initial hidden state of size H and the encodings of objects in scope,
do a best first search and yield a stream of (log likelihood, sequence of tokens)"""
if encodedObjects is not None:
objectKeys = self.encoderToPointer(encodedObjects)
numberOfObjects = objectKeys.size(0)
else:
numberOfObjects = 0
class State():
def __init__(self, h, ll, sequence):
self.h = h
self.ll = ll
self.sequence = sequence
@property
def finished(self):
return self.sequence[-1] == "ENDING"
def trimmed(self):
return self.sequence[1:-1]
frontier = PQ()
def addToFrontier(s):
frontier.push(s.ll, s)
addToFrontier(State(initialState, 0., ["STARTING"]))
while len(frontier) > 0:
best = frontier.popMaximum()
if best.finished:
yield (best.ll, best.trimmed())
continue
# Calculate the input vector
lastWord = best.sequence[-1]
if isinstance(lastWord, Pointer):
latestPointer = encodedObjects[lastWord.i]
lastWord = "POINTER"
else:
latestPointer = self.device(torch.zeros(self.encoderDimensionality))
i = torch.cat([self.embedding(self.tensor(self.wordToIndex[lastWord])), latestPointer])
# Run the RNN forward
i = i.unsqueeze(0).unsqueeze(0)
o,h = self.model(i,best.h.unsqueeze(0).unsqueeze(0) if best.h is not None else None)
# incorporate successors into heap
o = self.output(o.squeeze(0).squeeze(0)).cpu().detach().numpy()
h = h.squeeze(0)
if numberOfObjects > 0:
a = self.pointerAttention(h, None, objectKeys=objectKeys).squeeze(0).cpu().detach().numpy()
h = h.squeeze(0)
for j,w in enumerate(self.lexicon):
ll = o[j]
if w == "POINTER":
for objectIndex in range(numberOfObjects):
pointer_ll = ll + a[objectIndex]
successor = State(h, best.ll + pointer_ll, best.sequence + [Pointer(objectIndex)])
addToFrontier(successor)
else:
addToFrontier(State(h, best.ll + ll, best.sequence + [w]))
class PointerNetwork(Module):
def __init__(self, encoder, lexicon, H=256):
super(PointerNetwork, self).__init__()
self.encoder = encoder
self.decoder = LineDecoder(lexicon, H=H)
self.finalize()
def gradientStep(self, optimizer, inputObjects, outputSequence,
verbose=False):
self.zero_grad()
l = -self.decoder.logLikelihood(None, outputSequence,
self.encoder(inputObjects) if inputObjects else None)
l.backward()
optimizer.step()
if verbose:
print("loss",l.data.item())
def sample(self, inputObjects):
return [ inputObjects[s.i] if isinstance(s,Pointer) else s
for s in self.decoder.sample(None,
self.encoder(inputObjects)) ]
def beam(self, inputObjects, B, maximumLength=10):
return [ (ll, [ inputObjects[s.i] if isinstance(s,Pointer) else s
for s in sequence ])
for ll, sequence in self.decoder.beam(None, self.encoder(inputObjects), B,
maximumLength=maximumLength)]
def bestFirstEnumeration(self, inputObjects):
for ll, sequence in self.decoder.bestFirstEnumeration(None, self.encoder(inputObjects)):
yield ll, [inputObjects[p.i] if isinstance(p, Pointer) else p
for p in sequence]
class ScopeEncoding():
"""A cache of the encodings of objects in scope"""
def __init__(self, owner, spec):
"""owner: a ProgramPointerNetwork that "owns" this scope encoding"""
self.spec = spec
self.owner = owner
self.object2index = {}
self.objectEncoding = None
def registerObject(self, o):
if o in self.object2index: return self
oe = self.owner.objectEncoder(self.spec, o.execute())
if self.objectEncoding is None:
self.objectEncoding = oe.view(1,-1)
else:
self.objectEncoding = torch.cat([self.objectEncoding, oe.view(1,-1)])
self.object2index[o] = len(self.object2index)
return self
def registerObjects(self, os):
os = [o for o in os if o not in self.object2index ]
if len(os) == 0: return self
encodings = self.owner.objectEncoder(self.spec, [o.execute() for o in os])
if self.objectEncoding is None:
self.objectEncoding = encodings
else:
self.objectEncoding = torch.cat([self.objectEncoding, encodings])
for o in os:
self.object2index[o] = len(self.object2index)
return self
def encoding(self, objects):
"""Takes as input O objects (as a list) and returns a OxE tensor of their encodings.
If the owner has a self attention module, also applies the attention module.
If objects is the empty list then return None"""
if len(objects) == 0: return None
self.registerObjects(objects)
preAttention = self.objectEncoding[self.owner.device(torch.tensor([self.object2index[o]
for o in objects ]))]
return self.owner.selfAttention(preAttention)
class ProgramPointerNetwork(Module):
"""A network that looks at the objects in a ProgramGraph and then predicts what to add to the graph"""
def __init__(self, objectEncoder, specEncoder, DSL, oneParent=False,
H=256, attentionRounds=1, heads=4):
"""
specEncoder: Module that encodes spec to initial hidden state of RNN
objectEncoder: Module that encodes (spec, object) to features we attend over
oneParent: Whether each node in the program graph is constrained to have no more than one parent
"""
super(ProgramPointerNetwork, self).__init__()
self.DSL = DSL
self.oneParent = oneParent
self.objectEncoder = objectEncoder
self.specEncoder = specEncoder
self.decoder = LineDecoder(DSL.lexicon + ["RETURN"],
encoderDimensionality=H, # self attention outputs size H
H=H)
self._initialHidden = nn.Sequential(
nn.Linear(H + specEncoder.outputDimensionality, H),
nn.ReLU())
self._distance = nn.Sequential(
nn.Linear(H + specEncoder.outputDimensionality, H),
nn.ReLU(),
nn.Linear(H, 1),
nn.ReLU())
self.selfAttention = nn.Sequential(
nn.Linear(objectEncoder.outputDimensionality, H),
MultiHeadAttention(heads, H, rounds=attentionRounds, residual=True))
self.H = H
self.finalize()
def initialHidden(self, objectEncodings, specEncoding):
if objectEncodings is None:
objectEncodings = self.device(torch.zeros(self.H))
else:
objectEncodings = objectEncodings.sum(0)
return self._initialHidden(torch.cat([specEncoding, objectEncodings]))
def distance(self, objectEncodings, specEncoding):
"""Returns a 1-dimensional tensor which should be the sum of (# objects to create) + (# spurious objects created)"""
if objectEncodings is None:
objectEncodings = self.device(torch.zeros(self.H))
else:
objectEncodings = objectEncodings.sum(0)
return self._distance(torch.cat([specEncoding, objectEncodings]))
def traceLogLikelihood(self, spec, trace, scopeEncoding=None):
scopeEncoding = scopeEncoding or ScopeEncoding(self, spec).registerObjects(set(trace))
currentGraph = ProgramGraph([])
specEncoding = self.specEncoder(spec)
lls = []
for obj in trace + [['RETURN']]:
finalMove = obj == ['RETURN']
# Gather together objects in scope
objectsInScope = list(currentGraph.objects(oneParent=self.oneParent))
scope = scopeEncoding.encoding(objectsInScope)
object2pointer = {o: Pointer(i)
for i, o in enumerate(objectsInScope)}
h0 = self.initialHidden(scope, specEncoding)
def substitutePointers(serialization):
return [object2pointer.get(token, token)
for token in serialization]
lls.append(self.decoder.logLikelihood(h0,
substitutePointers(obj.serialize()) if not finalMove else obj,
scope))
if not finalMove:
currentGraph = currentGraph.extend(obj)
return sum(lls), lls
def gradientStepTrace(self, optimizer, spec, trace):
"""Returns [policy losses]"""
self.zero_grad()
ll, lls = self.traceLogLikelihood(spec, trace)
(-ll).backward()
optimizer.step()
return [-l.data.item() for l in lls]
def sample(self, spec, maxMoves=None):
specEncoding = self.specEncoder(spec)
objectEncodings = ScopeEncoding(self, spec)
graph = ProgramGraph([])
while True:
# Make the encoding matrix
objectsInScope = list(graph.objects(oneParent=self.oneParent))
oe = objectEncodings.encoding(objectsInScope)
h0 = self.initialHidden(oe, specEncoding)
nextLineOfCode = self.decoder.sample(h0, oe)
if nextLineOfCode is None: return None
nextLineOfCode = [objectsInScope[t.i] if isinstance(t, Pointer) else t
for t in nextLineOfCode ]
if 'RETURN' in nextLineOfCode or len(graph) >= maxMoves: return graph
nextObject = self.DSL.parseLine(nextLineOfCode)
if nextObject is None: return None
graph = graph.extend(nextObject)
def repeatedlySample(self, specEncoding, graph, objectEncodings, n_samples):
"""Repeatedly samples a single line of code.
specEncoding: Encoding of the spec
objectEncodings: a ScopeEncoding
graph: the current graph
n_samples: how many samples to draw
returns: list of sampled DSL objects. If the sample is `RETURN` then that entry in the list is None.
"""
objectsInScope = list(graph.objects(oneParent=self.oneParent))
oe = objectEncodings.encoding(objectsInScope)
h0 = self.initialHidden(oe, specEncoding)
samples = []
for _ in range(n_samples):
nextLineOfCode = self.decoder.sample(h0, oe)
if nextLineOfCode is None: continue
nextLineOfCode = [objectsInScope[t.i] if isinstance(t, Pointer) else t
for t in nextLineOfCode ]
if 'RETURN' in nextLineOfCode:
samples.append(None)
else:
nextObject = self.DSL.parseLine(nextLineOfCode)
if nextObject is not None:
samples.append(nextObject)
return samples
def beamNextLine(self, specEncoding, graph, objectEncodings, B):
"""Does a beam search for a single line of code.
specEncoding: Encoding of the spec
objectEncodings: a ScopeEncoding
graph: the current graph
B: beam size
returns: list of (at most B) beamed (DSL object, log likelihood). None denotes `RETURN`
"""
objectsInScope = list(graph.objects(oneParent=self.oneParent))
oe = objectEncodings.encoding(objectsInScope)
h0 = self.initialHidden(oe, specEncoding)
lines = []
for ll, tokens in self.decoder.beam(h0, oe, B, maximumLength=10):
tokens = [objectsInScope[t.i] if isinstance(t, Pointer) else t
for t in tokens]
if 'RETURN' in tokens:
lines.append((None, ll))
else:
line = self.DSL.parseLine(tokens)
if line is None: continue
lines.append((line, ll))
return lines
def bestFirstEnumeration(self, specEncoding, graph, objectEncodings):
"""Does a best first search for a single line of code.
specEncoding: Encoding of the spec
objectEncodings: a ScopeEncoding
graph: current graph
yields: stream of (DSL object, log likelihood). None denotes `RETURN'"""
objectsInScope = list(graph.objects(oneParent=self.oneParent))
oe = objectEncodings.encoding(objectsInScope)
h0 = self.initialHidden(oe, specEncoding)
for ll, tokens in self.decoder.bestFirstEnumeration(h0, oe):
tokens = [objectsInScope[t.i] if isinstance(t, Pointer) else t
for t in tokens]
if 'RETURN' in tokens and len(tokens) == 0:
yield (None, ll)
else:
line = self.DSL.parseLine(tokens)
if line is None: continue
yield (line, ll)
if __name__ == "__main__":
m = PointerNetwork(SymbolEncoder([str(n) for n in range(10) ]), ["large","small"])
optimizer = torch.optim.Adam(m.parameters(), lr=0.001, eps=1e-3, amsgrad=True)
for n in range(90000):
x = str(random.choice(range(10)))
y = str(random.choice(range(10)))
if x == y: continue
large = max(x,y)
small = min(x,y)
if random.choice([False,True]):
sequence = ["large", Pointer(int(large == y)), Pointer(int(large == y)),
"small", Pointer(int(small == y))]
else:
sequence = ["small", Pointer(int(small == y)),
"large", Pointer(int(large == y))]
verbose = n%50 == 0
if random.choice([False,True]):
m.gradientStep(optimizer, [x,y], sequence, verbose=verbose)
else:
m.gradientStep(optimizer, [], ["small","small"], verbose=verbose)
if verbose:
print([x,y],"goes to",m.sample([x,y]))
print([x,y],"beams into:")
for ll, s in m.beam([x,y],10):
print(f"{s}\t(w/ ll={ll})")
print()
print([x,y],"best first into")
lines = 0
for ll, s in m.bestFirstEnumeration([x,y]):
print(f"{s}\t(w/ ll={ll})")
lines += 1
if lines > 5: break
print()