MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / maybe_stack

Function maybe_stack

rat-sql-gap/seq2struct/models/nl2code/decoder.py:41–48  ·  view source on GitHub ↗
(items, dim=None)

Source from the content-addressed store, hash-verified

39
40
41def maybe_stack(items, dim=None):
42 to_stack = [item for item in items if item is not None]
43 if not to_stack:
44 return None
45 elif len(to_stack) == 1:
46 return to_stack[0].unsqueeze(dim)
47 else:
48 return torch.stack(to_stack, dim)
49
50
51def accumulate_logprobs(d, keys_and_logprobs):

Callers 1

gen_token_lossMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected