repo
stringlengths 7
54
| path
stringlengths 4
223
| func_name
stringlengths 1
134
| original_string
stringlengths 75
104k
| language
stringclasses 1
value | code
stringlengths 75
104k
| code_tokens
listlengths 20
28.4k
| docstring
stringlengths 1
46.3k
| docstring_tokens
listlengths 1
1.66k
| sha
stringlengths 40
40
| url
stringlengths 87
315
| partition
stringclasses 1
value | summary
stringlengths 4
350
| obf_code
stringlengths 7.85k
764k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
allenai/allennlp
|
allennlp/models/semantic_role_labeler.py
|
write_to_conll_eval_file
|
def write_to_conll_eval_file(prediction_file: TextIO,
gold_file: TextIO,
verb_index: Optional[int],
sentence: List[str],
prediction: List[str],
gold_labels: List[str]):
"""
Prints predicate argument predictions and gold labels for a single verbal
predicate in a sentence to two provided file references.
Parameters
----------
prediction_file : TextIO, required.
A file reference to print predictions to.
gold_file : TextIO, required.
A file reference to print gold labels to.
verb_index : Optional[int], required.
The index of the verbal predicate in the sentence which
the gold labels are the arguments for, or None if the sentence
contains no verbal predicate.
sentence : List[str], required.
The word tokens.
prediction : List[str], required.
The predicted BIO labels.
gold_labels : List[str], required.
The gold BIO labels.
"""
verb_only_sentence = ["-"] * len(sentence)
if verb_index:
verb_only_sentence[verb_index] = sentence[verb_index]
conll_format_predictions = convert_bio_tags_to_conll_format(prediction)
conll_format_gold_labels = convert_bio_tags_to_conll_format(gold_labels)
for word, predicted, gold in zip(verb_only_sentence,
conll_format_predictions,
conll_format_gold_labels):
prediction_file.write(word.ljust(15))
prediction_file.write(predicted.rjust(15) + "\n")
gold_file.write(word.ljust(15))
gold_file.write(gold.rjust(15) + "\n")
prediction_file.write("\n")
gold_file.write("\n")
|
python
|
def write_to_conll_eval_file(prediction_file: TextIO,
gold_file: TextIO,
verb_index: Optional[int],
sentence: List[str],
prediction: List[str],
gold_labels: List[str]):
"""
Prints predicate argument predictions and gold labels for a single verbal
predicate in a sentence to two provided file references.
Parameters
----------
prediction_file : TextIO, required.
A file reference to print predictions to.
gold_file : TextIO, required.
A file reference to print gold labels to.
verb_index : Optional[int], required.
The index of the verbal predicate in the sentence which
the gold labels are the arguments for, or None if the sentence
contains no verbal predicate.
sentence : List[str], required.
The word tokens.
prediction : List[str], required.
The predicted BIO labels.
gold_labels : List[str], required.
The gold BIO labels.
"""
verb_only_sentence = ["-"] * len(sentence)
if verb_index:
verb_only_sentence[verb_index] = sentence[verb_index]
conll_format_predictions = convert_bio_tags_to_conll_format(prediction)
conll_format_gold_labels = convert_bio_tags_to_conll_format(gold_labels)
for word, predicted, gold in zip(verb_only_sentence,
conll_format_predictions,
conll_format_gold_labels):
prediction_file.write(word.ljust(15))
prediction_file.write(predicted.rjust(15) + "\n")
gold_file.write(word.ljust(15))
gold_file.write(gold.rjust(15) + "\n")
prediction_file.write("\n")
gold_file.write("\n")
|
[
"def",
"write_to_conll_eval_file",
"(",
"prediction_file",
":",
"TextIO",
",",
"gold_file",
":",
"TextIO",
",",
"verb_index",
":",
"Optional",
"[",
"int",
"]",
",",
"sentence",
":",
"List",
"[",
"str",
"]",
",",
"prediction",
":",
"List",
"[",
"str",
"]",
",",
"gold_labels",
":",
"List",
"[",
"str",
"]",
")",
":",
"verb_only_sentence",
"=",
"[",
"\"-\"",
"]",
"*",
"len",
"(",
"sentence",
")",
"if",
"verb_index",
":",
"verb_only_sentence",
"[",
"verb_index",
"]",
"=",
"sentence",
"[",
"verb_index",
"]",
"conll_format_predictions",
"=",
"convert_bio_tags_to_conll_format",
"(",
"prediction",
")",
"conll_format_gold_labels",
"=",
"convert_bio_tags_to_conll_format",
"(",
"gold_labels",
")",
"for",
"word",
",",
"predicted",
",",
"gold",
"in",
"zip",
"(",
"verb_only_sentence",
",",
"conll_format_predictions",
",",
"conll_format_gold_labels",
")",
":",
"prediction_file",
".",
"write",
"(",
"word",
".",
"ljust",
"(",
"15",
")",
")",
"prediction_file",
".",
"write",
"(",
"predicted",
".",
"rjust",
"(",
"15",
")",
"+",
"\"\\n\"",
")",
"gold_file",
".",
"write",
"(",
"word",
".",
"ljust",
"(",
"15",
")",
")",
"gold_file",
".",
"write",
"(",
"gold",
".",
"rjust",
"(",
"15",
")",
"+",
"\"\\n\"",
")",
"prediction_file",
".",
"write",
"(",
"\"\\n\"",
")",
"gold_file",
".",
"write",
"(",
"\"\\n\"",
")"
] |
Prints predicate argument predictions and gold labels for a single verbal
predicate in a sentence to two provided file references.
Parameters
----------
prediction_file : TextIO, required.
A file reference to print predictions to.
gold_file : TextIO, required.
A file reference to print gold labels to.
verb_index : Optional[int], required.
The index of the verbal predicate in the sentence which
the gold labels are the arguments for, or None if the sentence
contains no verbal predicate.
sentence : List[str], required.
The word tokens.
prediction : List[str], required.
The predicted BIO labels.
gold_labels : List[str], required.
The gold BIO labels.
|
[
"Prints",
"predicate",
"argument",
"predictions",
"and",
"gold",
"labels",
"for",
"a",
"single",
"verbal",
"predicate",
"in",
"a",
"sentence",
"to",
"two",
"provided",
"file",
"references",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_role_labeler.py#L226-L268
|
train
|
Writes predictions and gold labels for a single verbal taxonomy in a single word sentence to a two provided file references.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFn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e,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + chr(0b100010 + 0o25) + chr(0b100000 + 0o21), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(0b101100 + 0o11) + '\061', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(52) + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10336 - 10225) + chr(0b11000 + 0o33) + chr(2300 - 2248), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + '\x33' + '\x33', 9710 - 9702), ehT0Px3KOsy9(chr(48) + '\157' + chr(1832 - 1781) + chr(673 - 624) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x36' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1010001 + 0o36) + '\x33' + chr(0b1100 + 0o53) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b111101 + 0o62) + '\063' + chr(50) + '\x34', 48193 - 48185), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\x6f' + chr(0b110001) + chr(0b10011 + 0o42) + chr(206 - 152), 0o10), ehT0Px3KOsy9(chr(1071 - 1023) + chr(0b1101111) + chr(0b101111 + 0o4) + chr(0b11111 + 0o22) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b100110 + 0o111) + chr(0b110011) + chr(1273 - 1220) + chr(1418 - 1367), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b11001 + 0o31) + '\064' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b10110 + 0o131) + chr(0b101000 + 0o16) + chr(54), 8), ehT0Px3KOsy9('\x30' + '\157' + chr(1069 - 1020) + chr(0b101111 + 0o2) + chr(0b1 + 0o66), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\067' + chr(0b110000), 19959 - 19951), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b1101 + 0o43) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(0b11010 + 0o31) + chr(0b110111) + chr(0b10011 + 0o41), 8), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + chr(1918 - 1868) + '\x36' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(0b1011110 + 0o21) + chr(50) + chr(1894 - 1845) + chr(1648 - 1600), 33126 - 33118), ehT0Px3KOsy9('\x30' + chr(0b110110 + 0o71) + chr(0b1011 + 0o50) + '\061' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1000000 + 0o57) + '\x33' + chr(0b101100 + 0o7) + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1111 + 0o42) + chr(52), 43008 - 43000), ehT0Px3KOsy9('\x30' + chr(9036 - 8925) + chr(0b110111) + chr(0b110101), 20240 - 20232), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + '\060' + chr(49), 38405 - 38397), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(992 - 942) + chr(2678 - 2626) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + '\x33', 5110 - 5102), ehT0Px3KOsy9('\x30' + chr(11541 - 11430) + chr(0b110011) + chr(0b100011 + 0o20) + chr(50), 0o10), ehT0Px3KOsy9(chr(1526 - 1478) + chr(11104 - 10993) + chr(0b110011) + chr(1042 - 993) + chr(0b101100 + 0o4), 0b1000), ehT0Px3KOsy9(chr(2171 - 2123) + chr(0b1101111) + chr(0b10110 + 0o35) + chr(48) + chr(2308 - 2257), 8), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\157' + chr(2129 - 2080) + chr(51) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b110010) + chr(51), 46668 - 46660), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(0b110111) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000110 + 0o51) + chr(0b1011 + 0o46) + chr(0b100101 + 0o21) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(2140 - 2092) + '\x6f' + chr(0b10000 + 0o41) + chr(0b110000), 11323 - 11315), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110111) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(55) + chr(50), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1101111) + chr(0b110001 + 0o4) + chr(1579 - 1531), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(100) + '\145' + chr(9469 - 9370) + chr(0b1101111) + chr(9605 - 9505) + '\x65')('\165' + '\164' + chr(0b1010111 + 0o17) + chr(0b100011 + 0o12) + chr(0b110000 + 0o10)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def XPadjh64sw_r(TNd4BFiY_mxD, Mx76E4l4aZ2K, MzXciWQre8k_, pamQPTGoym5v, ys6Y0jo7ObhM, uw2pdyhFjRsY):
M2f6V0brF5FH = [xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4'), '\x64' + chr(101) + '\143' + '\157' + chr(0b1100100) + chr(0b10111 + 0o116))(chr(0b1110101) + chr(0b1111 + 0o145) + '\146' + chr(0b100001 + 0o14) + '\070')] * c2A0yzQpDQB3(pamQPTGoym5v)
if MzXciWQre8k_:
M2f6V0brF5FH[MzXciWQre8k_] = pamQPTGoym5v[MzXciWQre8k_]
BWg0wpCfuFEv = uYE82SelNY5G(ys6Y0jo7ObhM)
z6Ps2Tavg4hj = uYE82SelNY5G(uw2pdyhFjRsY)
for (CWnx52wJLqEN, zljAUjbBWUdH, engLn_Bmu8eW) in pZ0NK2y6HRbn(M2f6V0brF5FH, BWg0wpCfuFEv, z6Ps2Tavg4hj):
xafqLlk3kkUe(TNd4BFiY_mxD, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), chr(0b100011 + 0o101) + chr(0b1100101) + chr(647 - 548) + chr(0b1000010 + 0o55) + chr(1609 - 1509) + '\145')('\165' + '\x74' + chr(0b1100110) + chr(1579 - 1534) + chr(753 - 697)))(xafqLlk3kkUe(CWnx52wJLqEN, xafqLlk3kkUe(SXOLrMavuUCe(b'\x95\x03\xd5o/'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b10001 + 0o125) + '\x2d' + '\x38'))(ehT0Px3KOsy9(chr(189 - 141) + chr(7849 - 7738) + '\061' + '\x37', 0o10)))
xafqLlk3kkUe(TNd4BFiY_mxD, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), chr(0b11010 + 0o112) + chr(8020 - 7919) + chr(9586 - 9487) + chr(1994 - 1883) + '\x64' + chr(101))(chr(5185 - 5068) + '\164' + chr(102) + chr(45) + '\x38'))(xafqLlk3kkUe(zljAUjbBWUdH, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8b\x03\xd5o/'), chr(100) + '\145' + chr(0b11010 + 0o111) + '\157' + chr(0b1100100) + '\145')('\x75' + chr(116) + chr(0b1100110) + chr(0b101011 + 0o2) + chr(0b111000)))(ehT0Px3KOsy9('\060' + chr(0b111110 + 0o61) + '\x31' + chr(0b1011 + 0o54), 8)) + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(0b1100100) + '\145' + '\x63' + chr(0b1101111) + '\144' + '\x65')(chr(0b1110101) + '\164' + chr(102) + chr(0b110 + 0o47) + '\x38'))
xafqLlk3kkUe(Mx76E4l4aZ2K, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), '\x64' + chr(0b1100101) + '\x63' + chr(0b1100100 + 0o13) + chr(100) + chr(7703 - 7602))('\165' + '\164' + chr(102) + '\x2d' + '\x38'))(xafqLlk3kkUe(CWnx52wJLqEN, xafqLlk3kkUe(SXOLrMavuUCe(b'\x95\x03\xd5o/'), '\144' + chr(0b1100101) + chr(0b1000110 + 0o35) + chr(111) + chr(100) + chr(6517 - 6416))('\x75' + chr(4926 - 4810) + '\146' + '\055' + chr(56)))(ehT0Px3KOsy9('\060' + chr(0b1010110 + 0o31) + chr(49) + '\x37', 8)))
xafqLlk3kkUe(Mx76E4l4aZ2K, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), chr(3521 - 3421) + chr(0b1100101) + chr(99) + chr(6348 - 6237) + chr(100) + chr(101))('\x75' + chr(7832 - 7716) + chr(102) + chr(45) + '\070'))(xafqLlk3kkUe(engLn_Bmu8eW, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8b\x03\xd5o/'), chr(0b1000100 + 0o40) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(0b1101001 + 0o14) + chr(0b1010011 + 0o41) + chr(457 - 355) + chr(637 - 592) + '\070'))(ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + chr(55), 8)) + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(100) + chr(6609 - 6508) + '\x63' + '\x6f' + chr(0b1100100) + chr(101))(chr(6093 - 5976) + chr(0b1110100) + '\146' + chr(0b101101) + chr(56)))
xafqLlk3kkUe(TNd4BFiY_mxD, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), chr(0b1100100) + '\x65' + '\x63' + chr(111) + chr(100) + chr(4521 - 4420))('\x75' + '\164' + '\x66' + '\x2d' + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(0b11110 + 0o106) + chr(0b1100101) + '\143' + chr(0b1101111) + chr(100) + '\x65')('\165' + chr(0b1110100) + '\146' + chr(45) + '\x38'))
xafqLlk3kkUe(Mx76E4l4aZ2K, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x1b\xc9h>'), chr(0b1100100) + chr(0b1010100 + 0o21) + '\143' + chr(111) + '\x64' + chr(0b1100101))('\x75' + chr(0b111010 + 0o72) + '\x66' + chr(0b10101 + 0o30) + chr(554 - 498)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(0b100110 + 0o76) + '\145' + chr(9700 - 9601) + chr(0b11101 + 0o122) + chr(0b1100100) + chr(0b101100 + 0o71))(chr(117) + chr(0b1101110 + 0o6) + chr(102) + chr(0b10100 + 0o31) + chr(56)))
|
allenai/allennlp
|
allennlp/models/semantic_role_labeler.py
|
convert_bio_tags_to_conll_format
|
def convert_bio_tags_to_conll_format(labels: List[str]):
"""
Converts BIO formatted SRL tags to the format required for evaluation with the
official CONLL 2005 perl script. Spans are represented by bracketed labels,
with the labels of words inside spans being the same as those outside spans.
Beginning spans always have a opening bracket and a closing asterisk (e.g. "(ARG-1*" )
and closing spans always have a closing bracket (e.g. "*)" ). This applies even for
length 1 spans, (e.g "(ARG-0*)").
A full example of the conversion performed:
[B-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, O]
[ "(ARG-1*", "*", "*", "*", "*)", "*"]
Parameters
----------
labels : List[str], required.
A list of BIO tags to convert to the CONLL span based format.
Returns
-------
A list of labels in the CONLL span based format.
"""
sentence_length = len(labels)
conll_labels = []
for i, label in enumerate(labels):
if label == "O":
conll_labels.append("*")
continue
new_label = "*"
# Are we at the beginning of a new span, at the first word in the sentence,
# or is the label different from the previous one? If so, we are seeing a new label.
if label[0] == "B" or i == 0 or label[1:] != labels[i - 1][1:]:
new_label = "(" + label[2:] + new_label
# Are we at the end of the sentence, is the next word a new span, or is the next
# word not in a span? If so, we need to close the label span.
if i == sentence_length - 1 or labels[i + 1][0] == "B" or label[1:] != labels[i + 1][1:]:
new_label = new_label + ")"
conll_labels.append(new_label)
return conll_labels
|
python
|
def convert_bio_tags_to_conll_format(labels: List[str]):
"""
Converts BIO formatted SRL tags to the format required for evaluation with the
official CONLL 2005 perl script. Spans are represented by bracketed labels,
with the labels of words inside spans being the same as those outside spans.
Beginning spans always have a opening bracket and a closing asterisk (e.g. "(ARG-1*" )
and closing spans always have a closing bracket (e.g. "*)" ). This applies even for
length 1 spans, (e.g "(ARG-0*)").
A full example of the conversion performed:
[B-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, O]
[ "(ARG-1*", "*", "*", "*", "*)", "*"]
Parameters
----------
labels : List[str], required.
A list of BIO tags to convert to the CONLL span based format.
Returns
-------
A list of labels in the CONLL span based format.
"""
sentence_length = len(labels)
conll_labels = []
for i, label in enumerate(labels):
if label == "O":
conll_labels.append("*")
continue
new_label = "*"
# Are we at the beginning of a new span, at the first word in the sentence,
# or is the label different from the previous one? If so, we are seeing a new label.
if label[0] == "B" or i == 0 or label[1:] != labels[i - 1][1:]:
new_label = "(" + label[2:] + new_label
# Are we at the end of the sentence, is the next word a new span, or is the next
# word not in a span? If so, we need to close the label span.
if i == sentence_length - 1 or labels[i + 1][0] == "B" or label[1:] != labels[i + 1][1:]:
new_label = new_label + ")"
conll_labels.append(new_label)
return conll_labels
|
[
"def",
"convert_bio_tags_to_conll_format",
"(",
"labels",
":",
"List",
"[",
"str",
"]",
")",
":",
"sentence_length",
"=",
"len",
"(",
"labels",
")",
"conll_labels",
"=",
"[",
"]",
"for",
"i",
",",
"label",
"in",
"enumerate",
"(",
"labels",
")",
":",
"if",
"label",
"==",
"\"O\"",
":",
"conll_labels",
".",
"append",
"(",
"\"*\"",
")",
"continue",
"new_label",
"=",
"\"*\"",
"# Are we at the beginning of a new span, at the first word in the sentence,",
"# or is the label different from the previous one? If so, we are seeing a new label.",
"if",
"label",
"[",
"0",
"]",
"==",
"\"B\"",
"or",
"i",
"==",
"0",
"or",
"label",
"[",
"1",
":",
"]",
"!=",
"labels",
"[",
"i",
"-",
"1",
"]",
"[",
"1",
":",
"]",
":",
"new_label",
"=",
"\"(\"",
"+",
"label",
"[",
"2",
":",
"]",
"+",
"new_label",
"# Are we at the end of the sentence, is the next word a new span, or is the next",
"# word not in a span? If so, we need to close the label span.",
"if",
"i",
"==",
"sentence_length",
"-",
"1",
"or",
"labels",
"[",
"i",
"+",
"1",
"]",
"[",
"0",
"]",
"==",
"\"B\"",
"or",
"label",
"[",
"1",
":",
"]",
"!=",
"labels",
"[",
"i",
"+",
"1",
"]",
"[",
"1",
":",
"]",
":",
"new_label",
"=",
"new_label",
"+",
"\")\"",
"conll_labels",
".",
"append",
"(",
"new_label",
")",
"return",
"conll_labels"
] |
Converts BIO formatted SRL tags to the format required for evaluation with the
official CONLL 2005 perl script. Spans are represented by bracketed labels,
with the labels of words inside spans being the same as those outside spans.
Beginning spans always have a opening bracket and a closing asterisk (e.g. "(ARG-1*" )
and closing spans always have a closing bracket (e.g. "*)" ). This applies even for
length 1 spans, (e.g "(ARG-0*)").
A full example of the conversion performed:
[B-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, O]
[ "(ARG-1*", "*", "*", "*", "*)", "*"]
Parameters
----------
labels : List[str], required.
A list of BIO tags to convert to the CONLL span based format.
Returns
-------
A list of labels in the CONLL span based format.
|
[
"Converts",
"BIO",
"formatted",
"SRL",
"tags",
"to",
"the",
"format",
"required",
"for",
"evaluation",
"with",
"the",
"official",
"CONLL",
"2005",
"perl",
"script",
".",
"Spans",
"are",
"represented",
"by",
"bracketed",
"labels",
"with",
"the",
"labels",
"of",
"words",
"inside",
"spans",
"being",
"the",
"same",
"as",
"those",
"outside",
"spans",
".",
"Beginning",
"spans",
"always",
"have",
"a",
"opening",
"bracket",
"and",
"a",
"closing",
"asterisk",
"(",
"e",
".",
"g",
".",
"(",
"ARG",
"-",
"1",
"*",
")",
"and",
"closing",
"spans",
"always",
"have",
"a",
"closing",
"bracket",
"(",
"e",
".",
"g",
".",
"*",
")",
")",
".",
"This",
"applies",
"even",
"for",
"length",
"1",
"spans",
"(",
"e",
".",
"g",
"(",
"ARG",
"-",
"0",
"*",
")",
")",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_role_labeler.py#L271-L310
|
train
|
Converts a list of BIO formatted SRL tags to the CONLL format required for evaluation with the given CONLL 2005 perl script.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNIC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,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + chr(0b10 + 0o61) + chr(0b110110) + chr(1918 - 1868), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x31' + '\x37' + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(206 - 95) + chr(0b110001) + chr(0b110000) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(792 - 744) + chr(0b1101111) + chr(0b110010) + chr(49) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1110 + 0o45) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b100011 + 0o21) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x36' + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110011) + chr(51) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(0b110 + 0o60) + '\066', 0o10), ehT0Px3KOsy9(chr(1750 - 1702) + chr(0b1010 + 0o145) + chr(0b110011) + chr(49) + chr(222 - 169), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + '\061' + chr(0b110001) + chr(0b110101), 33232 - 33224), ehT0Px3KOsy9(chr(73 - 25) + chr(0b1001011 + 0o44) + '\x33' + '\067' + chr(1682 - 1634), 16454 - 16446), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100011 + 0o20) + '\x35' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + chr(10035 - 9924) + '\063' + chr(0b110000 + 0o7) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(76 - 22) + chr(0b110000), 22252 - 22244), ehT0Px3KOsy9(chr(520 - 472) + chr(12026 - 11915) + chr(0b1000 + 0o52) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(608 - 559) + chr(0b10100 + 0o41) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001011 + 0o44) + chr(0b1001 + 0o52) + '\064' + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1000010 + 0o55) + chr(0b110001) + '\061' + '\062', 23714 - 23706), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\x33' + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(862 - 812) + chr(0b110100) + '\x35', 21131 - 21123), ehT0Px3KOsy9(chr(1690 - 1642) + chr(0b1011 + 0o144) + chr(0b110011) + chr(0b110000) + chr(0b110010 + 0o3), 25716 - 25708), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b11011 + 0o31) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + '\063' + chr(49), 37893 - 37885), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b110111) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\064' + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(2278 - 2228) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(11169 - 11058) + '\x31' + chr(55) + '\066', 44140 - 44132), ehT0Px3KOsy9('\060' + chr(11972 - 11861) + chr(0b110011) + chr(0b1001 + 0o56) + chr(62 - 14), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + chr(54) + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(53) + chr(0b10110 + 0o33), ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1101111) + chr(0b110011) + '\064' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b110100 + 0o73) + chr(639 - 584) + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + '\x30' + chr(1437 - 1384), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10111 + 0o32) + chr(0b101110 + 0o5) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(48) + chr(3035 - 2924) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\157' + '\x32' + '\064' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(769 - 721) + '\x6f' + '\x32' + '\x32' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(2004 - 1956) + '\157' + '\x37' + '\067', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101111) + '\x35' + chr(0b110000), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xdc'), '\x64' + chr(0b1100101) + chr(0b110110 + 0o55) + '\157' + chr(0b10100 + 0o120) + chr(2300 - 2199))(chr(117) + '\164' + '\146' + chr(0b101101) + chr(0b10011 + 0o45)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def uYE82SelNY5G(uXMK81tmdpTM):
eSMIwHgBdyED = c2A0yzQpDQB3(uXMK81tmdpTM)
HvAxm4wp73I8 = []
for (WVxHKyX45z_L, TRUOLFLuD08x) in YlkZvXL8qwsX(uXMK81tmdpTM):
if TRUOLFLuD08x == xafqLlk3kkUe(SXOLrMavuUCe(b'\xbd'), chr(0b1100100) + chr(0b100010 + 0o103) + '\143' + chr(111) + chr(0b1100100) + chr(101))('\165' + chr(0b110110 + 0o76) + chr(10218 - 10116) + chr(45) + chr(0b111000)):
xafqLlk3kkUe(HvAxm4wp73I8, xafqLlk3kkUe(SXOLrMavuUCe(b'\x93\x0f0\xees\xc0'), chr(100) + '\145' + chr(99) + chr(111) + chr(0b1100100) + chr(8270 - 8169))(chr(0b1110101) + chr(0b0 + 0o164) + chr(0b1000000 + 0o46) + chr(1497 - 1452) + chr(0b10100 + 0o44)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8'), '\x64' + '\x65' + chr(0b1100011) + '\157' + '\x64' + chr(0b11111 + 0o106))('\165' + chr(5148 - 5032) + '\146' + chr(45) + chr(0b1011 + 0o55)))
continue
jp5pe2X662PZ = xafqLlk3kkUe(SXOLrMavuUCe(b'\xd8'), '\144' + chr(101) + '\143' + chr(111) + '\x64' + chr(101))(chr(2823 - 2706) + chr(10772 - 10656) + chr(102) + chr(0b11011 + 0o22) + chr(0b111000))
if TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + chr(0b110000), 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xb0'), '\x64' + chr(101) + chr(1710 - 1611) + chr(0b1000110 + 0o51) + chr(0b1011100 + 0o10) + chr(101))(chr(117) + chr(13387 - 13271) + chr(102) + '\x2d' + chr(0b10010 + 0o46)) or WVxHKyX45z_L == ehT0Px3KOsy9(chr(615 - 567) + '\157' + chr(0b101011 + 0o5), 8) or TRUOLFLuD08x[ehT0Px3KOsy9(chr(1521 - 1473) + chr(0b1101111) + chr(49), 0o10):] != uXMK81tmdpTM[WVxHKyX45z_L - ehT0Px3KOsy9(chr(1494 - 1446) + chr(0b1101111) + chr(0b100011 + 0o16), 8)][ehT0Px3KOsy9('\x30' + chr(0b111 + 0o150) + chr(49), 8):]:
jp5pe2X662PZ = xafqLlk3kkUe(SXOLrMavuUCe(b'\xda'), '\144' + chr(0b1100101) + chr(99) + chr(0b1011010 + 0o25) + chr(0b1100100) + chr(0b1100101))(chr(117) + '\164' + '\146' + '\x2d' + '\x38') + TRUOLFLuD08x[ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + '\062', ord("\x08")):] + jp5pe2X662PZ
if WVxHKyX45z_L == eSMIwHgBdyED - ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31', 8) or uXMK81tmdpTM[WVxHKyX45z_L + ehT0Px3KOsy9(chr(0b110000) + chr(6121 - 6010) + chr(0b10111 + 0o32), 8)][ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(48), 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xb0'), chr(0b1100100) + '\145' + chr(0b110100 + 0o57) + chr(2589 - 2478) + chr(100) + chr(0b111101 + 0o50))('\165' + '\164' + chr(102) + chr(0b101010 + 0o3) + chr(1596 - 1540)) or TRUOLFLuD08x[ehT0Px3KOsy9('\060' + chr(0b111011 + 0o64) + chr(49), 8):] != uXMK81tmdpTM[WVxHKyX45z_L + ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\157' + '\061', 8)][ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2080 - 2031), 8):]:
jp5pe2X662PZ = jp5pe2X662PZ + xafqLlk3kkUe(SXOLrMavuUCe(b'\xdb'), '\144' + chr(0b1100101) + chr(99) + chr(111) + '\144' + '\x65')(chr(0b101001 + 0o114) + '\164' + '\x66' + chr(0b1101 + 0o40) + '\x38')
xafqLlk3kkUe(HvAxm4wp73I8, xafqLlk3kkUe(SXOLrMavuUCe(b'\x93\x0f0\xees\xc0'), chr(8379 - 8279) + chr(1848 - 1747) + chr(7905 - 7806) + chr(0b111011 + 0o64) + chr(100) + chr(6526 - 6425))(chr(0b1110101) + chr(0b1110100) + chr(102) + chr(0b10000 + 0o35) + chr(2041 - 1985)))(jp5pe2X662PZ)
return HvAxm4wp73I8
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.get_agenda_for_sentence
|
def get_agenda_for_sentence(self, sentence: str) -> List[str]:
"""
Given a ``sentence``, returns a list of actions the sentence triggers as an ``agenda``. The
``agenda`` can be used while by a parser to guide the decoder. sequences as possible. This
is a simplistic mapping at this point, and can be expanded.
Parameters
----------
sentence : ``str``
The sentence for which an agenda will be produced.
"""
agenda = []
sentence = sentence.lower()
if sentence.startswith("there is a box") or sentence.startswith("there is a tower "):
agenda.append(self.terminal_productions["box_exists"])
elif sentence.startswith("there is a "):
agenda.append(self.terminal_productions["object_exists"])
if "<Set[Box]:bool> -> box_exists" not in agenda:
# These are object filters and do not apply if we have a box_exists at the top.
if "touch" in sentence:
if "top" in sentence:
agenda.append(self.terminal_productions["touch_top"])
elif "bottom" in sentence or "base" in sentence:
agenda.append(self.terminal_productions["touch_bottom"])
elif "corner" in sentence:
agenda.append(self.terminal_productions["touch_corner"])
elif "right" in sentence:
agenda.append(self.terminal_productions["touch_right"])
elif "left" in sentence:
agenda.append(self.terminal_productions["touch_left"])
elif "wall" in sentence or "edge" in sentence:
agenda.append(self.terminal_productions["touch_wall"])
else:
agenda.append(self.terminal_productions["touch_object"])
else:
# The words "top" and "bottom" may be referring to top and bottom blocks in a tower.
if "top" in sentence:
agenda.append(self.terminal_productions["top"])
elif "bottom" in sentence or "base" in sentence:
agenda.append(self.terminal_productions["bottom"])
if " not " in sentence:
agenda.append(self.terminal_productions["negate_filter"])
if " contains " in sentence or " has " in sentence:
agenda.append(self.terminal_productions["all_boxes"])
# This takes care of shapes, colors, top, bottom, big, small etc.
for constant, production in self.terminal_productions.items():
# TODO(pradeep): Deal with constant names with underscores.
if "top" in constant or "bottom" in constant:
# We already dealt with top, bottom, touch_top and touch_bottom above.
continue
if constant in sentence:
if "<Set[Object]:Set[Object]> ->" in production and "<Set[Box]:bool> -> box_exists" in agenda:
if constant in ["square", "circle", "triangle"]:
agenda.append(self.terminal_productions[f"shape_{constant}"])
elif constant in ["yellow", "blue", "black"]:
agenda.append(self.terminal_productions[f"color_{constant}"])
else:
continue
else:
agenda.append(production)
# TODO (pradeep): Rules for "member_*" productions ("tower" or "box" followed by a color,
# shape or number...)
number_productions = self._get_number_productions(sentence)
for production in number_productions:
agenda.append(production)
if not agenda:
# None of the rules above was triggered!
if "box" in sentence:
agenda.append(self.terminal_productions["all_boxes"])
else:
agenda.append(self.terminal_productions["all_objects"])
return agenda
|
python
|
def get_agenda_for_sentence(self, sentence: str) -> List[str]:
"""
Given a ``sentence``, returns a list of actions the sentence triggers as an ``agenda``. The
``agenda`` can be used while by a parser to guide the decoder. sequences as possible. This
is a simplistic mapping at this point, and can be expanded.
Parameters
----------
sentence : ``str``
The sentence for which an agenda will be produced.
"""
agenda = []
sentence = sentence.lower()
if sentence.startswith("there is a box") or sentence.startswith("there is a tower "):
agenda.append(self.terminal_productions["box_exists"])
elif sentence.startswith("there is a "):
agenda.append(self.terminal_productions["object_exists"])
if "<Set[Box]:bool> -> box_exists" not in agenda:
# These are object filters and do not apply if we have a box_exists at the top.
if "touch" in sentence:
if "top" in sentence:
agenda.append(self.terminal_productions["touch_top"])
elif "bottom" in sentence or "base" in sentence:
agenda.append(self.terminal_productions["touch_bottom"])
elif "corner" in sentence:
agenda.append(self.terminal_productions["touch_corner"])
elif "right" in sentence:
agenda.append(self.terminal_productions["touch_right"])
elif "left" in sentence:
agenda.append(self.terminal_productions["touch_left"])
elif "wall" in sentence or "edge" in sentence:
agenda.append(self.terminal_productions["touch_wall"])
else:
agenda.append(self.terminal_productions["touch_object"])
else:
# The words "top" and "bottom" may be referring to top and bottom blocks in a tower.
if "top" in sentence:
agenda.append(self.terminal_productions["top"])
elif "bottom" in sentence or "base" in sentence:
agenda.append(self.terminal_productions["bottom"])
if " not " in sentence:
agenda.append(self.terminal_productions["negate_filter"])
if " contains " in sentence or " has " in sentence:
agenda.append(self.terminal_productions["all_boxes"])
# This takes care of shapes, colors, top, bottom, big, small etc.
for constant, production in self.terminal_productions.items():
# TODO(pradeep): Deal with constant names with underscores.
if "top" in constant or "bottom" in constant:
# We already dealt with top, bottom, touch_top and touch_bottom above.
continue
if constant in sentence:
if "<Set[Object]:Set[Object]> ->" in production and "<Set[Box]:bool> -> box_exists" in agenda:
if constant in ["square", "circle", "triangle"]:
agenda.append(self.terminal_productions[f"shape_{constant}"])
elif constant in ["yellow", "blue", "black"]:
agenda.append(self.terminal_productions[f"color_{constant}"])
else:
continue
else:
agenda.append(production)
# TODO (pradeep): Rules for "member_*" productions ("tower" or "box" followed by a color,
# shape or number...)
number_productions = self._get_number_productions(sentence)
for production in number_productions:
agenda.append(production)
if not agenda:
# None of the rules above was triggered!
if "box" in sentence:
agenda.append(self.terminal_productions["all_boxes"])
else:
agenda.append(self.terminal_productions["all_objects"])
return agenda
|
[
"def",
"get_agenda_for_sentence",
"(",
"self",
",",
"sentence",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"agenda",
"=",
"[",
"]",
"sentence",
"=",
"sentence",
".",
"lower",
"(",
")",
"if",
"sentence",
".",
"startswith",
"(",
"\"there is a box\"",
")",
"or",
"sentence",
".",
"startswith",
"(",
"\"there is a tower \"",
")",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"box_exists\"",
"]",
")",
"elif",
"sentence",
".",
"startswith",
"(",
"\"there is a \"",
")",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"object_exists\"",
"]",
")",
"if",
"\"<Set[Box]:bool> -> box_exists\"",
"not",
"in",
"agenda",
":",
"# These are object filters and do not apply if we have a box_exists at the top.",
"if",
"\"touch\"",
"in",
"sentence",
":",
"if",
"\"top\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_top\"",
"]",
")",
"elif",
"\"bottom\"",
"in",
"sentence",
"or",
"\"base\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_bottom\"",
"]",
")",
"elif",
"\"corner\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_corner\"",
"]",
")",
"elif",
"\"right\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_right\"",
"]",
")",
"elif",
"\"left\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_left\"",
"]",
")",
"elif",
"\"wall\"",
"in",
"sentence",
"or",
"\"edge\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_wall\"",
"]",
")",
"else",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"touch_object\"",
"]",
")",
"else",
":",
"# The words \"top\" and \"bottom\" may be referring to top and bottom blocks in a tower.",
"if",
"\"top\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"top\"",
"]",
")",
"elif",
"\"bottom\"",
"in",
"sentence",
"or",
"\"base\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"bottom\"",
"]",
")",
"if",
"\" not \"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"negate_filter\"",
"]",
")",
"if",
"\" contains \"",
"in",
"sentence",
"or",
"\" has \"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"all_boxes\"",
"]",
")",
"# This takes care of shapes, colors, top, bottom, big, small etc.",
"for",
"constant",
",",
"production",
"in",
"self",
".",
"terminal_productions",
".",
"items",
"(",
")",
":",
"# TODO(pradeep): Deal with constant names with underscores.",
"if",
"\"top\"",
"in",
"constant",
"or",
"\"bottom\"",
"in",
"constant",
":",
"# We already dealt with top, bottom, touch_top and touch_bottom above.",
"continue",
"if",
"constant",
"in",
"sentence",
":",
"if",
"\"<Set[Object]:Set[Object]> ->\"",
"in",
"production",
"and",
"\"<Set[Box]:bool> -> box_exists\"",
"in",
"agenda",
":",
"if",
"constant",
"in",
"[",
"\"square\"",
",",
"\"circle\"",
",",
"\"triangle\"",
"]",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"f\"shape_{constant}\"",
"]",
")",
"elif",
"constant",
"in",
"[",
"\"yellow\"",
",",
"\"blue\"",
",",
"\"black\"",
"]",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"f\"color_{constant}\"",
"]",
")",
"else",
":",
"continue",
"else",
":",
"agenda",
".",
"append",
"(",
"production",
")",
"# TODO (pradeep): Rules for \"member_*\" productions (\"tower\" or \"box\" followed by a color,",
"# shape or number...)",
"number_productions",
"=",
"self",
".",
"_get_number_productions",
"(",
"sentence",
")",
"for",
"production",
"in",
"number_productions",
":",
"agenda",
".",
"append",
"(",
"production",
")",
"if",
"not",
"agenda",
":",
"# None of the rules above was triggered!",
"if",
"\"box\"",
"in",
"sentence",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"all_boxes\"",
"]",
")",
"else",
":",
"agenda",
".",
"append",
"(",
"self",
".",
"terminal_productions",
"[",
"\"all_objects\"",
"]",
")",
"return",
"agenda"
] |
Given a ``sentence``, returns a list of actions the sentence triggers as an ``agenda``. The
``agenda`` can be used while by a parser to guide the decoder. sequences as possible. This
is a simplistic mapping at this point, and can be expanded.
Parameters
----------
sentence : ``str``
The sentence for which an agenda will be produced.
|
[
"Given",
"a",
"sentence",
"returns",
"a",
"list",
"of",
"actions",
"the",
"sentence",
"triggers",
"as",
"an",
"agenda",
".",
"The",
"agenda",
"can",
"be",
"used",
"while",
"by",
"a",
"parser",
"to",
"guide",
"the",
"decoder",
".",
"sequences",
"as",
"possible",
".",
"This",
"is",
"a",
"simplistic",
"mapping",
"at",
"this",
"point",
"and",
"can",
"be",
"expanded",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L125-L199
|
train
|
Given a sentence returns a list of actions the sentence triggers as an agenda.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4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,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1850 - 1802) + chr(0b111000 + 0o67) + chr(50) + chr(82 - 33) + chr(2361 - 2306), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(3804 - 3693) + chr(0b110010) + chr(0b110001) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b101110 + 0o2) + chr(0b110011), 35308 - 35300), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110101) + chr(170 - 120), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(143 - 94) + chr(0b110000) + chr(0b110100 + 0o3), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\067' + chr(0b110011 + 0o2), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(155 - 105) + chr(0b110101), 36666 - 36658), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\060' + chr(2465 - 2415), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\065' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(543 - 495) + chr(1277 - 1166) + chr(2621 - 2566), 15890 - 15882), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + '\x33' + chr(2323 - 2271) + '\063', 0o10), ehT0Px3KOsy9('\060' + chr(818 - 707) + '\x33' + chr(1940 - 1889) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\x6f' + chr(0b101111 + 0o3) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(111) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b0 + 0o157) + '\x31' + chr(0b110011) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(4509 - 4398) + chr(0b110011) + chr(51) + chr(0b110100), 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(1918 - 1869) + chr(0b100000 + 0o25) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + chr(0b110111) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(954 - 843) + '\x32' + chr(0b111 + 0o53) + '\062', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b11 + 0o60) + '\060' + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(0b110100), 10155 - 10147), ehT0Px3KOsy9('\060' + chr(0b101010 + 0o105) + chr(0b100110 + 0o15) + chr(0b110 + 0o55) + chr(0b11101 + 0o31), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(118 - 69) + chr(0b110000) + chr(0b110001), 55851 - 55843), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(917 - 867) + chr(0b10001 + 0o43) + '\066', 25485 - 25477), ehT0Px3KOsy9(chr(1923 - 1875) + chr(3177 - 3066) + chr(588 - 539) + chr(488 - 435) + chr(2064 - 2011), 51538 - 51530), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1011 + 0o47) + chr(2762 - 2709) + chr(0b1011 + 0o52), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + '\157' + chr(0b110011) + chr(0b101111 + 0o3) + '\x32', 44111 - 44103), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11101 + 0o26) + '\064' + chr(52), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(55) + '\x37', 8), ehT0Px3KOsy9(chr(583 - 535) + chr(0b100111 + 0o110) + chr(0b11111 + 0o24) + chr(55) + chr(53), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1001 + 0o52) + chr(51) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(1341 - 1293) + '\157' + chr(0b110001) + '\x37' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + '\066' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(217 - 169) + '\157' + '\x32' + chr(54) + chr(50), 0o10), ehT0Px3KOsy9(chr(1604 - 1556) + '\x6f' + chr(0b110010) + '\x35', 0b1000), ehT0Px3KOsy9(chr(776 - 728) + chr(0b11000 + 0o127) + '\061' + '\x37' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(508 - 460) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\157' + '\061' + chr(0b11011 + 0o32) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1834 - 1783) + chr(0b110000 + 0o0) + '\066', 8), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(1802 - 1751) + chr(51) + chr(0b110010), 6215 - 6207)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110101) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), '\x64' + '\145' + chr(2061 - 1962) + '\157' + chr(7013 - 6913) + '\x65')(chr(0b1011000 + 0o35) + chr(2288 - 2172) + '\146' + chr(45) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def r_NcJX22Mi5m(oVre8I6UXc3b, pamQPTGoym5v) -> qRxF7OQ0y39T[M8_cKLkHVB2V]:
G70CqS_vp3no = []
pamQPTGoym5v = pamQPTGoym5v.lower()
if xafqLlk3kkUe(pamQPTGoym5v, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc\xfe\xe2X3\x0e"+Zo'), chr(0b1100100 + 0o0) + chr(6452 - 6351) + chr(99) + '\x6f' + chr(100) + '\x65')(chr(0b1010001 + 0o44) + chr(0b1110100 + 0o0) + chr(0b10000 + 0o126) + '\055' + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe2\xe6X"]<1\x0ef\xc3\xbeyz'), chr(0b100 + 0o140) + '\x65' + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(101))(chr(117) + chr(10020 - 9904) + '\x66' + '\x2d' + '\070')) or xafqLlk3kkUe(pamQPTGoym5v, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc\xfe\xe2X3\x0e"+Zo'), chr(100) + chr(0b111000 + 0o55) + chr(0b1010100 + 0o17) + '\157' + chr(100) + '\145')(chr(0b110100 + 0o101) + chr(1468 - 1352) + chr(0b100011 + 0o103) + '\x2d' + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe2\xe6X"]<1\x0ef\xc3\xa8yu;\xaeN'), chr(4196 - 4096) + '\x65' + chr(0b1001010 + 0o31) + '\x6f' + '\144' + chr(5145 - 5044))(chr(533 - 416) + chr(0b1110100) + '\146' + chr(0b101 + 0o50) + '\x38')):
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(100) + '\x65' + chr(0b1100011) + chr(1150 - 1039) + '\x64' + '\x65')(chr(0b1110101) + chr(8012 - 7896) + '\x66' + chr(0b10010 + 0o33) + chr(1494 - 1438)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\144' + chr(0b111011 + 0o52) + chr(0b1100011) + chr(111) + chr(100) + '\145')(chr(0b1100010 + 0o23) + chr(0b11 + 0o161) + chr(0b1100110) + chr(247 - 202) + '\070'))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xfbu"\x05<1Zt'), chr(0b1100100) + '\145' + '\143' + '\x6f' + chr(5867 - 5767) + chr(0b1100101))(chr(3472 - 3355) + '\x74' + '\x66' + '\055' + chr(0b10101 + 0o43))])
elif xafqLlk3kkUe(pamQPTGoym5v, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc\xfe\xe2X3\x0e"+Zo'), chr(100) + '\x65' + chr(0b101100 + 0o67) + chr(551 - 440) + chr(0b11110 + 0o106) + chr(101))(chr(7842 - 7725) + chr(12447 - 12331) + chr(0b1100110) + chr(0b101101) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe2\xe6X"]<1\x0ef\xc3'), chr(100) + chr(9903 - 9802) + chr(0b1100011 + 0o0) + chr(0b1101111) + chr(100) + chr(0b1100101))('\165' + '\164' + '\146' + chr(0b10101 + 0o30) + chr(2262 - 2206))):
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(100) + chr(101) + '\x63' + '\157' + chr(100) + chr(101))(chr(117) + chr(0b1110100) + chr(8375 - 8273) + chr(0b101101) + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b1000111 + 0o35) + '\x65' + chr(99) + '\157' + '\x64' + '\145')(chr(13492 - 13375) + chr(0b101 + 0o157) + '\x66' + chr(0b101101) + '\070'))[xafqLlk3kkUe(SXOLrMavuUCe(b"\xe0\xe8\xe9O$\t\n'Vn\x90\xa8e"), chr(100) + '\145' + chr(99) + '\x6f' + '\144' + chr(7403 - 7302))('\x75' + '\164' + chr(4222 - 4120) + chr(992 - 947) + chr(0b111000))])
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3\xd9\xe6^\x1c?::s=\x81\xb3yn`\xfcCA\xb2\xa2c\xa6\x1e\xc3\x15\xc4\xa1\x90\x0c'), '\x64' + chr(3992 - 3891) + chr(6395 - 6296) + chr(111) + chr(0b1 + 0o143) + '\x65')('\x75' + '\164' + '\x66' + chr(1423 - 1378) + chr(56)) not in G70CqS_vp3no:
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/'), chr(0b1100100) + chr(0b1 + 0o144) + '\x63' + chr(111) + '\144' + chr(101))(chr(0b1110101) + chr(4520 - 4404) + chr(0b1100110) + chr(0b111 + 0o46) + chr(56)) in pamQPTGoym5v:
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf3'), chr(0b1 + 0o143) + chr(101) + chr(0b1100011) + chr(0b1101111) + '\x64' + chr(0b110101 + 0o60))(chr(0b1011110 + 0o27) + chr(116) + chr(0b111001 + 0o55) + chr(187 - 142) + chr(56)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(0b110001 + 0o63) + chr(101) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(9041 - 8940))(chr(0b1110101) + '\x74' + chr(6118 - 6016) + chr(0b101101) + '\x38'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(100) + '\145' + chr(0b100111 + 0o74) + chr(111) + chr(0b1101 + 0o127) + chr(0b1000110 + 0o37))(chr(0b1111 + 0o146) + chr(7114 - 6998) + '\146' + chr(45) + '\070'))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/"!-^'), chr(100) + chr(0b1001001 + 0o34) + chr(7449 - 7350) + '\157' + chr(0b1100100) + '\145')('\165' + '\x74' + chr(0b1100110) + chr(0b101101) + chr(0b1010 + 0o56))])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xf7^(\x10'), '\x64' + chr(1676 - 1575) + chr(0b1100011) + chr(0b11 + 0o154) + chr(1194 - 1094) + '\145')('\x75' + '\x74' + chr(6250 - 6148) + chr(0b101101) + chr(0b101 + 0o63)) in pamQPTGoym5v or xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xeb\xf0O'), '\144' + chr(0b1100101) + chr(6111 - 6012) + '\x6f' + '\144' + '\145')(chr(117) + '\164' + chr(0b1100110) + '\x2d' + chr(56)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(9912 - 9812) + chr(0b1100101) + chr(6340 - 6241) + '\157' + chr(5221 - 5121) + chr(101))(chr(9178 - 9061) + chr(0b1101 + 0o147) + chr(0b110110 + 0o60) + chr(0b101101) + chr(56)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\x64' + '\145' + '\x63' + chr(0b10111 + 0o130) + chr(0b1 + 0o143) + chr(101))(chr(0b111101 + 0o70) + '\164' + chr(0b10000 + 0o126) + chr(0b101101) + chr(0b111000)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/"7-Zs\x8c\xb1'), chr(0b1100100) + '\x65' + '\143' + '\157' + '\144' + '\145')(chr(0b1110101) + '\x74' + '\146' + '\x2d' + chr(0b11101 + 0o33))])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xec\xe5\xf1D"\x0f'), chr(815 - 715) + '\145' + '\143' + chr(0b1101111) + chr(0b1100100) + '\145')('\x75' + '\164' + chr(0b1010111 + 0o17) + chr(0b10000 + 0o35) + '\070') in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\x64' + '\x65' + chr(99) + chr(0b1101111) + chr(9837 - 9737) + chr(101))(chr(0b100011 + 0o122) + chr(5400 - 5284) + chr(6320 - 6218) + '\055' + chr(1927 - 1871)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\144' + '\x65' + '\x63' + chr(0b1101111) + chr(0b1100100) + chr(4620 - 4519))('\x75' + '\x74' + chr(102) + '\055' + chr(0b11101 + 0o33)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/"6-\\i\x86\xae'), chr(0b1100100) + chr(0b1001111 + 0o26) + chr(0b1100011) + chr(3818 - 3707) + chr(100) + chr(101))(chr(0b1110101) + '\x74' + '\x66' + '\055' + '\x38')])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xfd\xe3\xe4B3'), chr(0b11100 + 0o110) + '\145' + chr(0b1100011) + chr(111) + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + chr(102) + chr(657 - 612) + '\070') in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(100) + chr(2915 - 2814) + '\143' + chr(0b1101111) + chr(6263 - 6163) + chr(101))('\165' + chr(2655 - 2539) + '\146' + chr(0b100101 + 0o10) + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\144' + '\145' + chr(0b100011 + 0o100) + '\157' + chr(0b1 + 0o143) + '\x65')(chr(7421 - 7304) + '\x74' + chr(0b1100110) + chr(0b101101 + 0o0) + chr(56)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/"\'+Io\x97'), '\x64' + chr(0b1100101) + chr(2753 - 2654) + chr(150 - 39) + chr(2415 - 2315) + chr(7447 - 7346))(chr(0b10000 + 0o145) + chr(116) + chr(0b1010 + 0o134) + chr(0b11101 + 0o20) + '\070')])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3\xef\xe5^'), '\144' + chr(10193 - 10092) + chr(99) + '\157' + '\144' + chr(101))('\x75' + chr(12778 - 12662) + chr(0b1011 + 0o133) + '\x2d' + chr(56)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\144' + chr(0b1001100 + 0o31) + chr(99) + chr(111) + '\144' + chr(101))('\x75' + '\164' + chr(102) + chr(0b11 + 0o52) + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b1100100) + '\x65' + chr(99) + '\x6f' + chr(242 - 142) + '\145')(chr(117) + chr(0b10000 + 0o144) + '\x66' + '\x2d' + chr(56)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/"9\'Hs'), chr(0b1100000 + 0o4) + '\145' + chr(0b111111 + 0o44) + chr(111) + chr(100) + chr(637 - 536))(chr(117) + chr(116) + '\146' + '\055' + chr(56))])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xf8\xeb\xefF'), chr(100) + chr(0b10111 + 0o116) + chr(0b1100011) + '\157' + chr(0b1100100) + chr(101))(chr(7830 - 7713) + chr(116) + chr(0b1100110) + chr(1021 - 976) + chr(0b111000)) in pamQPTGoym5v or xafqLlk3kkUe(SXOLrMavuUCe(b'\xea\xee\xe4O'), chr(0b1011001 + 0o13) + '\145' + chr(0b1100011) + chr(111) + chr(0b100 + 0o140) + '\x65')(chr(0b1110101) + chr(116) + '\146' + chr(0b101101) + chr(0b11100 + 0o34)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(3459 - 3359) + chr(101) + '\143' + chr(111) + chr(0b1100100) + chr(101))(chr(334 - 217) + chr(0b1110100) + chr(7522 - 7420) + '\x2d' + chr(0b10110 + 0o42)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b0 + 0o144) + chr(8668 - 8567) + chr(99) + chr(1693 - 1582) + '\144' + chr(0b1011110 + 0o7))(chr(117) + chr(0b10001 + 0o143) + '\146' + chr(0b101101) + '\x38'))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/""#Bk'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(0b111010 + 0o65) + chr(0b1100100) + '\x65')('\165' + chr(0b1110100) + '\x66' + chr(1690 - 1645) + '\x38')])
else:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\144' + chr(0b100001 + 0o104) + chr(0b1100011) + chr(6961 - 6850) + chr(0b1100100) + chr(0b1100101))(chr(0b101100 + 0o111) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\x64' + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(0b110 + 0o136) + '\145')(chr(12794 - 12677) + chr(116) + '\146' + chr(0b11000 + 0o25) + chr(0b110101 + 0o3)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf6I/": Db\x80\xa8'), chr(0b1100100) + chr(5082 - 4981) + chr(1163 - 1064) + chr(111) + '\x64' + chr(0b1100101))(chr(12157 - 12040) + '\164' + chr(5301 - 5199) + chr(0b101101) + chr(0b111000))])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf3'), chr(100) + '\x65' + chr(0b1100011) + chr(111) + '\144' + chr(0b1100101))(chr(0b11111 + 0o126) + chr(0b10 + 0o162) + chr(102) + chr(0b100011 + 0o12) + chr(1574 - 1518)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\x64' + chr(0b1010101 + 0o20) + '\143' + chr(111) + chr(9665 - 9565) + chr(0b1100010 + 0o3))(chr(0b1110101) + '\164' + chr(102) + '\x2d' + '\070'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), '\144' + chr(5778 - 5677) + chr(0b1100011) + chr(0b11000 + 0o127) + chr(0b1001001 + 0o33) + chr(101))(chr(0b10101 + 0o140) + chr(0b1110100) + chr(102) + '\055' + '\070'))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf3'), chr(0b1100100) + chr(8191 - 8090) + chr(0b101010 + 0o71) + chr(7470 - 7359) + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(10231 - 10115) + chr(7075 - 6973) + chr(0b11010 + 0o23) + '\x38')])
elif xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xf7^(\x10'), '\144' + chr(101) + chr(0b1100011) + chr(111) + chr(100) + '\x65')(chr(11785 - 11668) + chr(3168 - 3052) + '\x66' + chr(512 - 467) + chr(0b111000)) in pamQPTGoym5v or xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xeb\xf0O'), chr(738 - 638) + '\145' + chr(2062 - 1963) + '\157' + '\x64' + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + chr(1636 - 1591) + '\070') in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\144' + '\x65' + chr(0b101101 + 0o66) + chr(0b1101111) + chr(5479 - 5379) + chr(101))('\165' + chr(116) + chr(0b1001100 + 0o32) + chr(0b101001 + 0o4) + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b11001 + 0o113) + chr(0b1001111 + 0o26) + chr(99) + '\157' + chr(100) + chr(101))(chr(0b1110101) + '\164' + '\x66' + chr(0b101101) + chr(0b111000)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xf7^(\x10'), chr(0b1100100) + chr(0b1101 + 0o130) + chr(0b1001110 + 0o25) + '\157' + chr(0b1100100) + chr(101))(chr(0b1110101) + chr(0b1110100) + chr(0b1010000 + 0o26) + chr(0b100010 + 0o13) + '\x38')])
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf\xe4\xec^g'), chr(0b1000010 + 0o42) + chr(101) + chr(0b1101 + 0o126) + chr(0b110 + 0o151) + chr(0b100 + 0o140) + chr(0b111110 + 0o47))(chr(0b101101 + 0o110) + chr(116) + chr(102) + '\055' + chr(0b111000)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\144' + chr(0b1100101) + chr(0b110011 + 0o60) + '\157' + chr(0b1010100 + 0o20) + '\145')(chr(0b1110101) + chr(116) + '\146' + chr(0b101101) + '\x38'))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(100) + '\145' + chr(0b1011010 + 0o11) + chr(3310 - 3199) + chr(100) + chr(101))(chr(0b1110101) + '\x74' + '\146' + chr(0b100000 + 0o15) + chr(0b111000)))[xafqLlk3kkUe(SXOLrMavuUCe(b'\xe1\xef\xe4K3\x18\n$Gk\x97\xb9d'), chr(8724 - 8624) + chr(1625 - 1524) + chr(99) + chr(1773 - 1662) + chr(0b0 + 0o144) + '\x65')('\x75' + chr(0b1100001 + 0o23) + chr(0b1011001 + 0o15) + chr(0b101101) + '\x38')])
if xafqLlk3kkUe(SXOLrMavuUCe(b"\xaf\xe9\xecD3\x1c<,]'"), '\x64' + '\145' + '\143' + chr(11841 - 11730) + chr(0b1010101 + 0o17) + chr(0b1100101))('\165' + chr(5568 - 5452) + chr(102) + chr(0b101001 + 0o4) + chr(0b111000)) in pamQPTGoym5v or xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf\xe2\xe2Yg'), chr(0b1100100) + '\145' + chr(0b110 + 0o135) + '\x6f' + chr(6866 - 6766) + '\145')(chr(0b1110011 + 0o2) + chr(116) + chr(1528 - 1426) + '\055' + chr(331 - 275)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(1803 - 1703) + chr(7456 - 7355) + chr(99) + chr(3227 - 3116) + '\x64' + chr(101))(chr(0b1110101) + chr(12004 - 11888) + '\146' + chr(741 - 696) + chr(56)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b1011 + 0o131) + chr(2170 - 2069) + '\143' + chr(111) + '\144' + '\x65')('\x75' + chr(6744 - 6628) + '\146' + chr(960 - 915) + '\070'))[xafqLlk3kkUe(SXOLrMavuUCe(b"\xee\xe6\xefu%\x12-']"), chr(2087 - 1987) + chr(101) + chr(0b111101 + 0o46) + chr(111) + chr(0b1010101 + 0o17) + chr(0b1100101))('\165' + chr(116) + '\146' + chr(0b1000 + 0o45) + '\x38')])
for (QcnzFjzpljjk, qG4NM5kJTeVL) in xafqLlk3kkUe(oVre8I6UXc3b.terminal_productions, xafqLlk3kkUe(SXOLrMavuUCe(b"\xc1\xf0\xf5O\x0e'f\x0bBT\xab\xe5"), '\x64' + chr(0b1000101 + 0o40) + chr(0b1010010 + 0o21) + chr(9214 - 9103) + chr(0b1100100) + '\145')('\x75' + chr(116) + '\x66' + chr(0b101101) + chr(56)))():
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xe5\xf3'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(7753 - 7642) + '\144' + chr(101))(chr(0b1110101) + chr(116) + '\146' + chr(45) + '\070') in QcnzFjzpljjk or xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xf7^(\x10'), chr(7248 - 7148) + chr(0b1100101 + 0o0) + chr(99) + chr(3375 - 3264) + chr(100) + chr(101))(chr(0b111011 + 0o72) + chr(1475 - 1359) + chr(0b0 + 0o146) + chr(0b10001 + 0o34) + chr(1085 - 1029)) in QcnzFjzpljjk:
continue
if QcnzFjzpljjk in pamQPTGoym5v:
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3\xd9\xe6^\x1c27(Kd\x97\x81,Q;\xa850\xf0\xaai\xbd5\xfbS\x8d\xff\xda'), chr(100) + chr(0b10010 + 0o123) + chr(0b11000 + 0o113) + chr(0b1101111) + chr(0b1100100) + chr(5008 - 4907))('\x75' + chr(12897 - 12781) + '\146' + '\x2d' + chr(56)) in qG4NM5kJTeVL and xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3\xd9\xe6^\x1c?::s=\x81\xb3yn`\xfcCA\xb2\xa2c\xa6\x1e\xc3\x15\xc4\xa1\x90\x0c'), chr(0b1000101 + 0o37) + '\145' + '\x63' + '\x6f' + chr(7409 - 7309) + chr(7905 - 7804))(chr(7869 - 7752) + chr(0b1110100) + '\146' + chr(45) + '\070') in G70CqS_vp3no:
if QcnzFjzpljjk in [xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc\xfb\xf6K5\x18'), chr(100) + '\x65' + chr(0b1100011) + chr(0b111111 + 0o60) + chr(0b1100100) + '\145')(chr(8513 - 8396) + '\164' + chr(7854 - 7752) + chr(0b101101) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xec\xe3\xf1I+\x18'), chr(0b110100 + 0o60) + '\145' + chr(99) + chr(0b1101 + 0o142) + chr(0b1100100) + chr(0b1100010 + 0o3))(chr(8477 - 8360) + '\x74' + chr(0b1100110) + chr(45) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b"\xfb\xf8\xeaK)\x1a9'"), chr(0b1100100) + '\145' + chr(99) + chr(111) + chr(0b10101 + 0o117) + chr(1088 - 987))(chr(4928 - 4811) + '\164' + chr(102) + chr(0b100110 + 0o7) + chr(1439 - 1383))]:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), '\144' + chr(0b1100101) + chr(4395 - 4296) + '\157' + chr(0b11000 + 0o114) + chr(0b1100101))('\x75' + chr(0b100010 + 0o122) + chr(0b1010110 + 0o20) + chr(0b101101) + chr(56)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b10011 + 0o121) + chr(0b10010 + 0o123) + chr(4845 - 4746) + chr(10674 - 10563) + chr(3361 - 3261) + chr(101))(chr(117) + chr(0b100101 + 0o117) + chr(5367 - 5265) + '\055' + chr(0b111000)))[f'shape_{QcnzFjzpljjk}'])
elif QcnzFjzpljjk in [xafqLlk3kkUe(SXOLrMavuUCe(b'\xf6\xef\xefF(\n'), chr(100) + chr(1274 - 1173) + '\143' + '\x6f' + '\x64' + '\145')(chr(9424 - 9307) + '\x74' + '\x66' + '\055' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe6\xf6O'), chr(215 - 115) + chr(101) + '\143' + '\157' + chr(0b1100100) + chr(0b1100101))(chr(117) + '\164' + chr(4078 - 3976) + chr(0b100110 + 0o7) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe6\xe2I,'), chr(0b1100100) + chr(101) + chr(99) + chr(0b1010101 + 0o32) + '\144' + '\x65')('\x75' + chr(0b1011 + 0o151) + chr(0b1100110) + '\x2d' + chr(56))]:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(100) + chr(101) + '\x63' + chr(0b1101111) + chr(0b1100100) + '\x65')('\x75' + chr(11235 - 11119) + '\146' + '\055' + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b1100100) + chr(101) + chr(8401 - 8302) + chr(111) + chr(0b111001 + 0o53) + chr(3113 - 3012))(chr(0b1010001 + 0o44) + chr(116) + '\x66' + chr(0b1000 + 0o45) + '\x38'))[f'color_{QcnzFjzpljjk}'])
else:
continue
else:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(0b11001 + 0o126) + chr(3565 - 3465) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(102) + chr(0b101101) + chr(0b10111 + 0o41)))(qG4NM5kJTeVL)
xV6nG2Ka_Ng6 = oVre8I6UXc3b._get_number_productions(pamQPTGoym5v)
for qG4NM5kJTeVL in xV6nG2Ka_Ng6:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(100) + chr(4591 - 4490) + chr(0b111101 + 0o46) + chr(111) + '\x64' + chr(0b1100101))(chr(0b1111 + 0o146) + chr(0b1110100) + chr(102) + '\x2d' + '\x38'))(qG4NM5kJTeVL)
if not G70CqS_vp3no:
if xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\xe5\xfb'), chr(0b1100100) + '\145' + chr(5331 - 5232) + '\x6f' + '\x64' + '\x65')(chr(0b1110010 + 0o3) + chr(116) + chr(102) + '\x2d' + chr(56)) in pamQPTGoym5v:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(0b1100100) + chr(0b110101 + 0o60) + chr(5522 - 5423) + chr(0b110001 + 0o76) + '\x64' + chr(101))('\165' + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(7328 - 7228) + '\145' + chr(0b10010 + 0o121) + '\157' + '\x64' + chr(101))(chr(117) + chr(1265 - 1149) + chr(102) + '\x2d' + chr(56)))[xafqLlk3kkUe(SXOLrMavuUCe(b"\xee\xe6\xefu%\x12-']"), chr(0b101011 + 0o71) + '\x65' + chr(5924 - 5825) + chr(0b1101111) + chr(9996 - 9896) + chr(0b101011 + 0o72))(chr(0b1000001 + 0o64) + chr(0b111100 + 0o70) + '\x66' + chr(0b1101 + 0o40) + '\070')])
else:
xafqLlk3kkUe(G70CqS_vp3no, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee\xfa\xf3O)\x19'), chr(0b1100100) + '\x65' + chr(0b1000111 + 0o34) + chr(0b1101 + 0o142) + chr(2391 - 2291) + chr(0b1100101))(chr(1100 - 983) + chr(0b1110100) + '\146' + '\055' + chr(0b111000)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfb\xef\xf1G.\x134.qw\x91\xb3rw=\xa8\x07\x10\xfc\xb3'), chr(0b101111 + 0o65) + chr(101) + '\x63' + '\x6f' + chr(0b1100100) + chr(0b111010 + 0o53))(chr(8073 - 7956) + chr(0b1110100) + '\146' + '\x2d' + chr(0b111000)))[xafqLlk3kkUe(SXOLrMavuUCe(b"\xee\xe6\xefu(\x1f?'Ms\x90"), chr(100) + chr(0b1100101) + chr(0b10101 + 0o116) + chr(0b1101111) + chr(8897 - 8797) + chr(0b1010000 + 0o25))(chr(685 - 568) + '\164' + '\x66' + '\055' + chr(2109 - 2053))])
return G70CqS_vp3no
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage._get_number_productions
|
def _get_number_productions(sentence: str) -> List[str]:
"""
Gathers all the numbers in the sentence, and returns productions that lead to them.
"""
# The mapping here is very simple and limited, which also shouldn't be a problem
# because numbers seem to be represented fairly regularly.
number_strings = {"one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six":
"6", "seven": "7", "eight": "8", "nine": "9", "ten": "10"}
number_productions = []
tokens = sentence.split()
numbers = number_strings.values()
for token in tokens:
if token in numbers:
number_productions.append(f"int -> {token}")
elif token in number_strings:
number_productions.append(f"int -> {number_strings[token]}")
return number_productions
|
python
|
def _get_number_productions(sentence: str) -> List[str]:
"""
Gathers all the numbers in the sentence, and returns productions that lead to them.
"""
# The mapping here is very simple and limited, which also shouldn't be a problem
# because numbers seem to be represented fairly regularly.
number_strings = {"one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six":
"6", "seven": "7", "eight": "8", "nine": "9", "ten": "10"}
number_productions = []
tokens = sentence.split()
numbers = number_strings.values()
for token in tokens:
if token in numbers:
number_productions.append(f"int -> {token}")
elif token in number_strings:
number_productions.append(f"int -> {number_strings[token]}")
return number_productions
|
[
"def",
"_get_number_productions",
"(",
"sentence",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"# The mapping here is very simple and limited, which also shouldn't be a problem",
"# because numbers seem to be represented fairly regularly.",
"number_strings",
"=",
"{",
"\"one\"",
":",
"\"1\"",
",",
"\"two\"",
":",
"\"2\"",
",",
"\"three\"",
":",
"\"3\"",
",",
"\"four\"",
":",
"\"4\"",
",",
"\"five\"",
":",
"\"5\"",
",",
"\"six\"",
":",
"\"6\"",
",",
"\"seven\"",
":",
"\"7\"",
",",
"\"eight\"",
":",
"\"8\"",
",",
"\"nine\"",
":",
"\"9\"",
",",
"\"ten\"",
":",
"\"10\"",
"}",
"number_productions",
"=",
"[",
"]",
"tokens",
"=",
"sentence",
".",
"split",
"(",
")",
"numbers",
"=",
"number_strings",
".",
"values",
"(",
")",
"for",
"token",
"in",
"tokens",
":",
"if",
"token",
"in",
"numbers",
":",
"number_productions",
".",
"append",
"(",
"f\"int -> {token}\"",
")",
"elif",
"token",
"in",
"number_strings",
":",
"number_productions",
".",
"append",
"(",
"f\"int -> {number_strings[token]}\"",
")",
"return",
"number_productions"
] |
Gathers all the numbers in the sentence, and returns productions that lead to them.
|
[
"Gathers",
"all",
"the",
"numbers",
"in",
"the",
"sentence",
"and",
"returns",
"productions",
"that",
"lead",
"to",
"them",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L202-L218
|
train
|
Gathers all the numbers in the sentence and returns the productions that lead to them.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zs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,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(1967 - 1856) + '\x31' + chr(0b110111) + chr(483 - 434), 0o10), ehT0Px3KOsy9(chr(1236 - 1188) + '\x6f' + chr(0b110011) + chr(0b101000 + 0o12) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b110110) + '\x33', 44502 - 44494), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10011 + 0o37) + chr(0b10010 + 0o40) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111 + 0o0) + chr(1959 - 1908) + chr(54) + chr(0b110001 + 0o5), 45545 - 45537), ehT0Px3KOsy9('\060' + chr(10392 - 10281) + chr(1824 - 1773) + '\062' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b110100) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(834 - 786) + chr(10406 - 10295) + chr(0b110111) + chr(2359 - 2310), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(815 - 704) + '\x33' + '\x34' + chr(48), 8), ehT0Px3KOsy9(chr(0b110000) + chr(7227 - 7116) + '\061' + chr(0b101011 + 0o7) + chr(727 - 678), 4599 - 4591), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + '\x32' + '\x37', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101010 + 0o5) + chr(170 - 121) + chr(0b10001 + 0o45), 0o10), ehT0Px3KOsy9('\x30' + chr(5010 - 4899) + '\x35' + '\063', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\061' + chr(810 - 759) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1879 - 1824) + chr(1880 - 1831), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b100011 + 0o17) + chr(0b110010) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b110000) + chr(50), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(0b110000), 18336 - 18328), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(0b100101 + 0o14) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101011 + 0o104) + '\x31' + chr(0b100100 + 0o16) + chr(669 - 616), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(10453 - 10342) + chr(49) + chr(1457 - 1408) + '\061', 0b1000), ehT0Px3KOsy9(chr(2113 - 2065) + chr(1551 - 1440) + chr(0b110101) + chr(0b1101 + 0o43), 0o10), ehT0Px3KOsy9(chr(1885 - 1837) + '\x6f' + '\x31' + chr(0b111 + 0o53) + '\060', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10010 + 0o40) + '\x36' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + '\x35' + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10111 + 0o34) + chr(266 - 218) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(2062 - 2014) + chr(7897 - 7786) + chr(54) + '\066', 8934 - 8926), ehT0Px3KOsy9(chr(48) + chr(12313 - 12202) + chr(50) + chr(0b1100 + 0o47) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6782 - 6671) + chr(51) + chr(0b101 + 0o60), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(55) + '\062', 0b1000), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b1101111) + chr(1892 - 1839) + '\x33', 8), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(3982 - 3871) + '\063' + chr(55), 31233 - 31225), ehT0Px3KOsy9(chr(1053 - 1005) + chr(6780 - 6669) + chr(0b110010) + '\x36' + '\x33', 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10010 + 0o44) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b100100 + 0o113) + chr(1175 - 1124) + chr(48), 13533 - 13525), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + '\x34' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(335 - 286) + chr(0b101001 + 0o15) + '\060', 13618 - 13610), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + chr(0b10001 + 0o40) + chr(55) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + chr(5729 - 5618) + chr(876 - 826) + chr(52) + chr(54), 24626 - 24618), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111) + '\063' + chr(55) + chr(1411 - 1360), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1001110 + 0o41) + chr(0b11100 + 0o31) + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'W'), chr(0b1100100) + '\x65' + chr(99) + '\x6f' + chr(0b1100100) + chr(101))('\165' + chr(0b1110100) + chr(0b1100001 + 0o5) + '\055' + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def RI19d2wBhxi4(pamQPTGoym5v) -> qRxF7OQ0y39T[M8_cKLkHVB2V]:
UBidQHdWOYgh = {xafqLlk3kkUe(SXOLrMavuUCe(b'\x16\xba\xd6'), chr(100) + '\x65' + chr(6981 - 6882) + chr(0b1101111) + chr(2831 - 2731) + '\145')(chr(13512 - 13395) + '\x74' + chr(0b1100110) + chr(45) + chr(0b111000)): xafqLlk3kkUe(SXOLrMavuUCe(b'H'), chr(100) + '\x65' + chr(6075 - 5976) + chr(111) + chr(0b1100100) + chr(101))(chr(0b1110101) + chr(13010 - 12894) + chr(0b11101 + 0o111) + chr(45) + chr(0b11 + 0o65)), xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xa3\xdc'), chr(100) + chr(101) + '\x63' + chr(111) + chr(100) + chr(0b11011 + 0o112))('\x75' + '\164' + '\146' + chr(45) + chr(0b101 + 0o63)): xafqLlk3kkUe(SXOLrMavuUCe(b'K'), chr(3222 - 3122) + '\x65' + chr(99) + '\x6f' + '\144' + chr(0b1001111 + 0o26))(chr(0b1110101) + chr(0b1110100) + chr(5149 - 5047) + chr(45) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xbc\xc1\xf3\x93'), chr(100) + '\145' + chr(99) + chr(0b1101111) + chr(6570 - 6470) + chr(0b1011111 + 0o6))(chr(13466 - 13349) + chr(0b1000001 + 0o63) + '\x66' + chr(1806 - 1761) + chr(0b100010 + 0o26)): xafqLlk3kkUe(SXOLrMavuUCe(b'J'), '\144' + chr(0b1100101) + chr(99) + '\x6f' + '\144' + chr(5366 - 5265))('\165' + '\164' + chr(0b1100110) + '\055' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\xbb\xc6\xe4'), chr(4502 - 4402) + chr(101) + chr(99) + chr(111) + '\x64' + chr(0b11010 + 0o113))('\x75' + chr(0b100011 + 0o121) + chr(0b1011110 + 0o10) + '\055' + chr(2355 - 2299)): xafqLlk3kkUe(SXOLrMavuUCe(b'M'), chr(0b1001000 + 0o34) + chr(5009 - 4908) + '\143' + chr(1800 - 1689) + chr(100) + chr(0b1000000 + 0o45))('\x75' + chr(0b1111 + 0o145) + chr(0b1100110) + '\055' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\xbd\xc5\xf3'), '\x64' + chr(4335 - 4234) + '\x63' + '\x6f' + '\x64' + chr(9846 - 9745))('\x75' + '\x74' + chr(0b1100110) + chr(0b10010 + 0o33) + chr(0b1010 + 0o56)): xafqLlk3kkUe(SXOLrMavuUCe(b'L'), chr(0b1001110 + 0o26) + chr(2064 - 1963) + chr(0b1100011) + '\x6f' + '\x64' + '\145')(chr(117) + '\x74' + chr(0b1100110) + '\055' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\n\xbd\xcb'), '\x64' + chr(101) + chr(0b1000 + 0o133) + '\x6f' + chr(100) + chr(101))('\165' + chr(116) + '\146' + chr(45) + chr(0b111000)): xafqLlk3kkUe(SXOLrMavuUCe(b'O'), chr(100) + chr(7594 - 7493) + chr(0b1100011) + '\157' + chr(0b1000011 + 0o41) + chr(0b111100 + 0o51))(chr(0b111000 + 0o75) + chr(0b1010110 + 0o36) + '\x66' + chr(1421 - 1376) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\n\xb1\xc5\xf3\x98'), '\144' + '\x65' + chr(950 - 851) + chr(0b1101111) + '\144' + '\x65')(chr(0b1110101) + chr(116) + '\146' + chr(45) + '\x38'): xafqLlk3kkUe(SXOLrMavuUCe(b'N'), chr(100) + chr(0b1100101) + '\143' + '\x6f' + '\x64' + chr(101))('\x75' + chr(0b1110100) + chr(7450 - 7348) + chr(0b100011 + 0o12) + chr(2746 - 2690)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\xbd\xd4\xfe\x82'), chr(100) + '\x65' + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + '\145')(chr(117) + chr(116) + '\146' + '\055' + chr(0b100110 + 0o22)): xafqLlk3kkUe(SXOLrMavuUCe(b'A'), chr(0b1100100) + chr(0b1001100 + 0o31) + chr(0b1100011) + '\x6f' + chr(100) + chr(101))(chr(0b1110101) + '\164' + '\x66' + chr(0b101101) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x17\xbd\xdd\xf3'), chr(817 - 717) + '\145' + '\143' + '\157' + chr(0b1100100) + chr(0b110000 + 0o65))(chr(0b1110101) + '\x74' + chr(0b1001001 + 0o35) + chr(0b101100 + 0o1) + '\x38'): xafqLlk3kkUe(SXOLrMavuUCe(b'@'), '\144' + chr(0b1100101) + '\143' + chr(0b1011010 + 0o25) + '\144' + chr(101))(chr(6649 - 6532) + '\x74' + chr(102) + chr(0b11111 + 0o16) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xb1\xdd'), chr(0b11010 + 0o112) + chr(0b1100101) + chr(99) + '\x6f' + '\144' + '\145')('\x75' + chr(116) + chr(5516 - 5414) + chr(0b101101) + '\x38'): xafqLlk3kkUe(SXOLrMavuUCe(b'H\xe4'), '\144' + chr(101) + '\x63' + chr(111) + chr(100) + chr(3280 - 3179))(chr(0b1110101) + chr(116) + '\146' + '\x2d' + '\070')}
xV6nG2Ka_Ng6 = []
Sz7tXxaCGqJ1 = pamQPTGoym5v.split()
uU3ppLOUY_t7 = UBidQHdWOYgh.SPnCNu54H1db()
for mTy3fac_AqJ5 in Sz7tXxaCGqJ1:
if mTy3fac_AqJ5 in uU3ppLOUY_t7:
xafqLlk3kkUe(xV6nG2Ka_Ng6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18\xa4\xc3\xf3\x98\xb3'), '\144' + chr(4799 - 4698) + chr(0b1100011) + chr(0b1000100 + 0o53) + '\x64' + chr(101))(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + chr(0b101101) + chr(0b111000)))(f'int -> {mTy3fac_AqJ5}')
elif mTy3fac_AqJ5 in UBidQHdWOYgh:
xafqLlk3kkUe(xV6nG2Ka_Ng6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x18\xa4\xc3\xf3\x98\xb3'), chr(0b1011110 + 0o6) + chr(0b1100101) + chr(0b100111 + 0o74) + chr(111) + '\x64' + chr(101))(chr(7748 - 7631) + '\164' + chr(0b1100110) + '\055' + '\x38'))(f'int -> {UBidQHdWOYgh[mTy3fac_AqJ5]}')
return xV6nG2Ka_Ng6
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.same_color
|
def same_color(self, objects: Set[Object]) -> Set[Object]:
"""
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``blue`` filters objects to
those that are blue, this filters objects to those that are of the same color.
"""
return self._get_objects_with_same_attribute(objects, lambda x: x.color)
|
python
|
def same_color(self, objects: Set[Object]) -> Set[Object]:
"""
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``blue`` filters objects to
those that are blue, this filters objects to those that are of the same color.
"""
return self._get_objects_with_same_attribute(objects, lambda x: x.color)
|
[
"def",
"same_color",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"return",
"self",
".",
"_get_objects_with_same_attribute",
"(",
"objects",
",",
"lambda",
"x",
":",
"x",
".",
"color",
")"
] |
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``blue`` filters objects to
those that are blue, this filters objects to those that are of the same color.
|
[
"Filters",
"the",
"set",
"of",
"objects",
"and",
"returns",
"those",
"objects",
"whose",
"color",
"is",
"the",
"most",
"frequent",
"color",
"in",
"the",
"initial",
"set",
"of",
"objects",
"if",
"the",
"highest",
"frequency",
"is",
"greater",
"than",
"1",
"or",
"an",
"empty",
"set",
"otherwise",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L275-L284
|
train
|
Filters the set of objects and returns those objects whose color is the most frequent one.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,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lkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(111) + '\063' + chr(2535 - 2482) + chr(0b110101), 47077 - 47069), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + chr(0b100011 + 0o22) + chr(1304 - 1253), 0o10), ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + '\062' + chr(0b110010 + 0o0) + chr(0b10 + 0o63), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2592 - 2540) + chr(0b110001 + 0o2), 56467 - 56459), ehT0Px3KOsy9(chr(778 - 730) + chr(111) + chr(674 - 624) + chr(0b110101 + 0o2) + chr(0b1100 + 0o53), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110110) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + chr(0b10100 + 0o37) + chr(0b101000 + 0o15) + '\x36', 39766 - 39758), ehT0Px3KOsy9(chr(1729 - 1681) + '\157' + '\062' + chr(0b110111) + chr(0b1101 + 0o50), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(740 - 686) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(509 - 461) + chr(0b1101111) + chr(49) + chr(0b110100) + chr(0b110000), 48013 - 48005), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(2581 - 2470) + chr(0b10110 + 0o32), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\x37' + chr(52), 47627 - 47619), ehT0Px3KOsy9('\x30' + chr(0b110100 + 0o73) + chr(0b110010) + chr(51) + chr(0b110101), 29139 - 29131), ehT0Px3KOsy9(chr(1003 - 955) + chr(111) + '\x33' + '\x37' + chr(0b110010), 4459 - 4451), ehT0Px3KOsy9(chr(0b110000) + chr(0b101010 + 0o105) + '\x33' + chr(48) + '\x31', 0b1000), ehT0Px3KOsy9(chr(2123 - 2075) + '\157' + chr(0b11010 + 0o31) + '\x33' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1934 - 1884) + '\066' + chr(1968 - 1917), ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(10392 - 10281) + '\063' + chr(2026 - 1978) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b101 + 0o56) + chr(1951 - 1903) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + '\061' + '\x34' + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101000 + 0o7) + '\x31' + chr(51) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(2391 - 2280) + chr(0b10001 + 0o41) + chr(1277 - 1223) + chr(0b11011 + 0o30), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(74 - 25) + chr(51) + '\065', 11771 - 11763), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1303 - 1252) + chr(1583 - 1534) + '\060', 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + '\x36' + chr(52), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10001 + 0o43) + chr(209 - 154), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011001 + 0o26) + chr(0b110001) + '\x30' + chr(1094 - 1041), 27264 - 27256), ehT0Px3KOsy9(chr(518 - 470) + '\157' + chr(0b10001 + 0o41) + chr(2402 - 2352) + '\064', 38466 - 38458), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b11010 + 0o125) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + chr(0b101000 + 0o15), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b100111 + 0o110) + '\063' + '\060' + chr(0b100111 + 0o12), 8), ehT0Px3KOsy9('\x30' + chr(9728 - 9617) + chr(665 - 614) + chr(2184 - 2131) + chr(0b10111 + 0o37), 8), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(3613 - 3502) + '\x34' + '\x34', 0b1000), ehT0Px3KOsy9(chr(60 - 12) + '\x6f' + chr(53) + chr(0b100111 + 0o16), 0o10), ehT0Px3KOsy9('\060' + chr(8091 - 7980) + '\x36' + chr(0b110010), 4539 - 4531), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(930 - 881) + chr(2468 - 2418) + chr(1812 - 1763), 18792 - 18784), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2407 - 2357) + chr(1944 - 1889) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b110100 + 0o73) + chr(0b110010) + chr(0b110011) + chr(0b11111 + 0o22), ord("\x08")), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b100101 + 0o112) + chr(50) + chr(0b101 + 0o53) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(1107 - 1059) + chr(111) + chr(1028 - 978) + '\x37' + chr(0b110101), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(8237 - 8126) + '\065' + chr(867 - 819), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3'), chr(0b110100 + 0o60) + '\145' + chr(0b100011 + 0o100) + '\x6f' + '\x64' + chr(0b1100101))(chr(0b1110101) + '\164' + chr(0b10000 + 0o126) + chr(0b10011 + 0o32) + chr(0b10 + 0o66)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def O_eZiZUE30Cx(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2\x8c\xf0W\xe0[\x8c\xd7U\x03t\x0f\xc2\x8d\xa8\xac\xdb\x99\xb6\x035\xd6\x02\xa9@S7\xfdd`\xb5\x8b'), chr(100) + chr(101) + chr(99) + chr(0b1101111) + '\144' + '\145')(chr(3949 - 3832) + chr(0b1010101 + 0o37) + '\x66' + chr(45) + '\x38'))(SY0NIgiWrFfS, lambda OeWW0F1dBPRQ: xafqLlk3kkUe(OeWW0F1dBPRQ, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x84\xf9L\xcd'), chr(3635 - 3535) + chr(0b10100 + 0o121) + '\143' + '\157' + chr(100) + chr(4806 - 4705))('\x75' + '\x74' + '\x66' + chr(475 - 430) + chr(56))))
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.same_shape
|
def same_shape(self, objects: Set[Object]) -> Set[Object]:
"""
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``triangle`` filters objects
to those that are triangles, this filters objects to those that are of the same shape.
"""
return self._get_objects_with_same_attribute(objects, lambda x: x.shape)
|
python
|
def same_shape(self, objects: Set[Object]) -> Set[Object]:
"""
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``triangle`` filters objects
to those that are triangles, this filters objects to those that are of the same shape.
"""
return self._get_objects_with_same_attribute(objects, lambda x: x.shape)
|
[
"def",
"same_shape",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"return",
"self",
".",
"_get_objects_with_same_attribute",
"(",
"objects",
",",
"lambda",
"x",
":",
"x",
".",
"shape",
")"
] |
Filters the set of objects, and returns those objects whose color is the most frequent
color in the initial set of objects, if the highest frequency is greater than 1, or an
empty set otherwise.
This is an unusual name for what the method does, but just as ``triangle`` filters objects
to those that are triangles, this filters objects to those that are of the same shape.
|
[
"Filters",
"the",
"set",
"of",
"objects",
"and",
"returns",
"those",
"objects",
"whose",
"color",
"is",
"the",
"most",
"frequent",
"color",
"in",
"the",
"initial",
"set",
"of",
"objects",
"if",
"the",
"highest",
"frequency",
"is",
"greater",
"than",
"1",
"or",
"an",
"empty",
"set",
"otherwise",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L287-L296
|
train
|
Filters the set of objects and returns those objects whose shape is the same shape as the set of objects.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZV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ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1203 - 1155) + chr(0b1101100 + 0o3) + chr(0b101110 + 0o4) + chr(0b110100) + chr(49), 0b1000), ehT0Px3KOsy9(chr(792 - 744) + chr(7646 - 7535) + chr(0b110011) + '\x37' + chr(477 - 429), 47922 - 47914), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(1266 - 1217) + chr(1463 - 1412), 63264 - 63256), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(999 - 950) + chr(2355 - 2303) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x36' + chr(0b100110 + 0o13), 44905 - 44897), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(50) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10340 - 10229) + '\x36' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\x6f' + chr(51) + chr(1164 - 1115) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111 + 0o0) + chr(0b110011) + chr(0b101001 + 0o14) + chr(54), 1989 - 1981), ehT0Px3KOsy9(chr(1929 - 1881) + chr(0b1100101 + 0o12) + chr(0b11001 + 0o32) + chr(0b1100 + 0o52), 0o10), ehT0Px3KOsy9(chr(1110 - 1062) + chr(111) + chr(2073 - 2022) + '\064' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10010 + 0o135) + '\x31' + chr(0b110100 + 0o0) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + '\x32' + chr(1900 - 1848), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + '\x32' + chr(0b0 + 0o66), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2981 - 2870) + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(437 - 389) + chr(0b1011010 + 0o25) + chr(0b10100 + 0o36) + chr(0b1000 + 0o52) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(1285 - 1235) + chr(0b110110) + chr(53), 20567 - 20559), ehT0Px3KOsy9('\x30' + chr(0b11100 + 0o123) + chr(1791 - 1741) + chr(0b110100) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\061' + '\066', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(450 - 399) + '\x36' + chr(482 - 428), 0b1000), ehT0Px3KOsy9(chr(173 - 125) + '\x6f' + chr(0b101 + 0o55) + chr(2256 - 2204), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001111 + 0o40) + chr(1130 - 1080) + '\062' + '\x30', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(386 - 335) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + '\x36' + chr(1578 - 1529), 42610 - 42602), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(55) + chr(0b10111 + 0o36), 34474 - 34466), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x37' + chr(0b1111 + 0o41), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + '\x32', 22078 - 22070), ehT0Px3KOsy9('\x30' + chr(8171 - 8060) + chr(1188 - 1138) + '\x35', 62009 - 62001), ehT0Px3KOsy9(chr(658 - 610) + '\x6f' + chr(2032 - 1981) + chr(1362 - 1309), 8774 - 8766), ehT0Px3KOsy9(chr(2276 - 2228) + chr(0b1011001 + 0o26) + chr(0b10100 + 0o36) + chr(2936 - 2881) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10110 + 0o131) + chr(0b11111 + 0o24) + '\x37' + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(0b1001 + 0o47), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(616 - 567) + '\x33' + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + '\x34', 0o10), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(111) + chr(49) + chr(52) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(0b110010) + '\064' + chr(50), 22634 - 22626), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(0b1010 + 0o50) + '\067', 13260 - 13252), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(6384 - 6273) + '\x34' + chr(1889 - 1837), ord("\x08")), ehT0Px3KOsy9(chr(2124 - 2076) + chr(111) + chr(0b11000 + 0o33) + chr(0b100111 + 0o17) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b101010 + 0o11), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(2231 - 2178) + '\060', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f'), '\144' + chr(5827 - 5726) + chr(0b110101 + 0o56) + chr(4349 - 4238) + chr(0b1100100) + chr(0b1010000 + 0o25))(chr(0b1101010 + 0o13) + '\164' + '\146' + chr(0b1100 + 0o41) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def WiCh6Rfh1_Ac(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfe\x9f.\x13n\xfaQ\xa5\x8b}\x90\x12\xcb!d\xe4\xdd\xfb=\x97y\xf5D\xd0ILx|\x7f\xc9\x8eu'), '\x64' + chr(101) + chr(1415 - 1316) + chr(5242 - 5131) + '\144' + '\145')(chr(0b1011000 + 0o35) + chr(6952 - 6836) + chr(0b1100110) + chr(45) + chr(0b111000)))(SY0NIgiWrFfS, lambda OeWW0F1dBPRQ: xafqLlk3kkUe(OeWW0F1dBPRQ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf\x99>>W\xd9T\xa3\xban\x87\x03'), chr(0b1100100) + '\145' + '\143' + chr(111) + chr(2746 - 2646) + chr(0b100110 + 0o77))(chr(0b1110101) + chr(0b100010 + 0o122) + chr(102) + '\055' + chr(0b100000 + 0o30))))
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.touch_object
|
def touch_object(self, objects: Set[Object]) -> Set[Object]:
"""
Returns all objects that touch the given set of objects.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box, box_objects in objects_per_box.items():
candidate_objects = box.objects
for object_ in box_objects:
for candidate_object in candidate_objects:
if self._objects_touch_each_other(object_, candidate_object):
return_set.add(candidate_object)
return return_set
|
python
|
def touch_object(self, objects: Set[Object]) -> Set[Object]:
"""
Returns all objects that touch the given set of objects.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box, box_objects in objects_per_box.items():
candidate_objects = box.objects
for object_ in box_objects:
for candidate_object in candidate_objects:
if self._objects_touch_each_other(object_, candidate_object):
return_set.add(candidate_object)
return return_set
|
[
"def",
"touch_object",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_per_box",
"=",
"self",
".",
"_separate_objects_by_boxes",
"(",
"objects",
")",
"return_set",
"=",
"set",
"(",
")",
"for",
"box",
",",
"box_objects",
"in",
"objects_per_box",
".",
"items",
"(",
")",
":",
"candidate_objects",
"=",
"box",
".",
"objects",
"for",
"object_",
"in",
"box_objects",
":",
"for",
"candidate_object",
"in",
"candidate_objects",
":",
"if",
"self",
".",
"_objects_touch_each_other",
"(",
"object_",
",",
"candidate_object",
")",
":",
"return_set",
".",
"add",
"(",
"candidate_object",
")",
"return",
"return_set"
] |
Returns all objects that touch the given set of objects.
|
[
"Returns",
"all",
"objects",
"that",
"touch",
"the",
"given",
"set",
"of",
"objects",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L329-L341
|
train
|
Returns all objects that touch the given set of objects.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,Kk1hd194VKEC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Z0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\x6f' + chr(425 - 375) + '\x36' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010100 + 0o33) + chr(51) + '\x32' + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1842 - 1793) + chr(52) + chr(1420 - 1371), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000100 + 0o53) + chr(2231 - 2182) + chr(2452 - 2398) + chr(0b110001 + 0o0), 31926 - 31918), ehT0Px3KOsy9('\060' + chr(0b10 + 0o155) + chr(51) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(0b1011010 + 0o25) + chr(2145 - 2096) + chr(54) + chr(1426 - 1373), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10010 + 0o135) + chr(49) + '\x35' + chr(0b110111), 55774 - 55766), ehT0Px3KOsy9(chr(1138 - 1090) + '\x6f' + '\063' + '\x30' + chr(0b101010 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(285 - 237) + chr(0b1101111) + chr(0b101111 + 0o2) + '\066' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + chr(0b11101 + 0o25) + chr(1069 - 1014) + chr(0b10110 + 0o32), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(0b1101111) + chr(0b101000 + 0o13) + chr(51) + chr(0b110101), 27495 - 27487), ehT0Px3KOsy9(chr(787 - 739) + '\157' + '\062' + chr(0b110000) + chr(53 - 4), 0o10), ehT0Px3KOsy9(chr(1572 - 1524) + '\x6f' + chr(0b101101 + 0o10) + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b10010 + 0o45) + chr(1788 - 1739), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(53) + chr(0b110 + 0o55), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + '\x31' + chr(0b100010 + 0o16) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2394 - 2345) + chr(0b11101 + 0o31) + chr(2190 - 2138), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(1858 - 1810) + chr(0b101010 + 0o13), 0b1000), ehT0Px3KOsy9(chr(2141 - 2093) + chr(111) + chr(0b1100 + 0o45) + '\x30' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + chr(0b1101 + 0o44) + chr(1149 - 1100) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(51) + chr(0b110110), 49574 - 49566), ehT0Px3KOsy9(chr(48) + '\157' + '\063' + chr(0b110100) + chr(48), 20624 - 20616), ehT0Px3KOsy9(chr(2186 - 2138) + chr(0b1101111) + '\062' + chr(0b101000 + 0o13) + '\066', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b111101 + 0o62) + '\061' + chr(0b110110) + '\x30', 0b1000), ehT0Px3KOsy9(chr(239 - 191) + chr(111) + chr(54) + chr(0b0 + 0o62), 54782 - 54774), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(2482 - 2371) + chr(2253 - 2204) + '\x35' + chr(2133 - 2081), 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1001000 + 0o47) + chr(821 - 771) + chr(0b11011 + 0o26) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(1357 - 1309) + chr(2448 - 2337) + chr(0b100111 + 0o13) + chr(1335 - 1283) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(2264 - 2216) + '\x6f' + chr(890 - 840) + chr(53), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + chr(735 - 683) + chr(0b11001 + 0o31), 41918 - 41910), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + '\065' + chr(0b101110 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x37', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(645 - 595) + '\x32' + chr(0b11011 + 0o25), 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + chr(1759 - 1706) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(946 - 898) + chr(0b1101111) + chr(1380 - 1330) + chr(0b1101 + 0o46) + chr(50), 19637 - 19629), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(1821 - 1771) + '\063', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(1889 - 1839) + '\x37' + '\064', 0o10), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + '\x36' + chr(0b110000), 25688 - 25680), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1010 + 0o47) + '\x36' + chr(51), 8), ehT0Px3KOsy9(chr(1541 - 1493) + chr(6367 - 6256) + chr(0b110001) + chr(0b110010) + chr(1466 - 1412), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\157' + chr(53) + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x99'), chr(0b110101 + 0o57) + chr(6374 - 6273) + chr(0b1100011) + chr(111) + '\144' + chr(0b1100101))('\165' + chr(0b1110100) + chr(0b1100110) + chr(0b101101) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Xrzq7g9CQmKJ(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
dhsX2yb4nWkJ = oVre8I6UXc3b._separate_objects_by_boxes(SY0NIgiWrFfS)
qUvKSH7GzXwG = MVEN8G6CxlvR()
for (xmmLsPObAALK, RXi3oIFFuUKJ) in xafqLlk3kkUe(dhsX2yb4nWkJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf9\xac\x17\x14Q/\\\x8b\x1f\xeb\x95\xb8'), chr(4130 - 4030) + chr(0b1100101) + chr(4764 - 4665) + '\157' + '\144' + chr(0b1011101 + 0o10))('\x75' + '\164' + '\146' + chr(0b11 + 0o52) + '\070'))():
SlhK_Ie4Lg7T = xmmLsPObAALK.objects
for ICzcWFwZUAA8 in RXi3oIFFuUKJ:
for j4idnYFeYzEG in SlhK_Ie4Lg7T:
if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8\xb9\x03\x1b}\x16\x1b\xb1,\xcc\xb2\xf4K\x91\xb4$\x15&)\x16\xb1\x94\xf6\x15@'), '\144' + '\x65' + chr(0b1011000 + 0o13) + '\x6f' + '\144' + '\x65')(chr(117) + chr(1279 - 1163) + '\146' + chr(0b1101 + 0o40) + '\070'))(ICzcWFwZUAA8, j4idnYFeYzEG):
xafqLlk3kkUe(qUvKSH7GzXwG, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc2\x9cQ\x00!\x16(\xf7)\xf7\x8f\xb2'), '\x64' + chr(0b1100101) + '\143' + chr(1417 - 1306) + chr(100) + chr(2891 - 2790))(chr(117) + chr(10104 - 9988) + '\146' + chr(45) + chr(0b10011 + 0o45)))(j4idnYFeYzEG)
return qUvKSH7GzXwG
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.top
|
def top(self, objects: Set[Object]) -> Set[Object]:
"""
Return the topmost objects (i.e. minimum y_loc). The comparison is done separately for each
box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set: Set[Object] = set()
for _, box_objects in objects_per_box.items():
min_y_loc = min([obj.y_loc for obj in box_objects])
return_set.update(set([obj for obj in box_objects if obj.y_loc == min_y_loc]))
return return_set
|
python
|
def top(self, objects: Set[Object]) -> Set[Object]:
"""
Return the topmost objects (i.e. minimum y_loc). The comparison is done separately for each
box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set: Set[Object] = set()
for _, box_objects in objects_per_box.items():
min_y_loc = min([obj.y_loc for obj in box_objects])
return_set.update(set([obj for obj in box_objects if obj.y_loc == min_y_loc]))
return return_set
|
[
"def",
"top",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_per_box",
"=",
"self",
".",
"_separate_objects_by_boxes",
"(",
"objects",
")",
"return_set",
":",
"Set",
"[",
"Object",
"]",
"=",
"set",
"(",
")",
"for",
"_",
",",
"box_objects",
"in",
"objects_per_box",
".",
"items",
"(",
")",
":",
"min_y_loc",
"=",
"min",
"(",
"[",
"obj",
".",
"y_loc",
"for",
"obj",
"in",
"box_objects",
"]",
")",
"return_set",
".",
"update",
"(",
"set",
"(",
"[",
"obj",
"for",
"obj",
"in",
"box_objects",
"if",
"obj",
".",
"y_loc",
"==",
"min_y_loc",
"]",
")",
")",
"return",
"return_set"
] |
Return the topmost objects (i.e. minimum y_loc). The comparison is done separately for each
box.
|
[
"Return",
"the",
"topmost",
"objects",
"(",
"i",
".",
"e",
".",
"minimum",
"y_loc",
")",
".",
"The",
"comparison",
"is",
"done",
"separately",
"for",
"each",
"box",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L344-L354
|
train
|
Return the topmost objects in a set.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHA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kZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(2302 - 2247) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b110101) + chr(1596 - 1544), 34576 - 34568), ehT0Px3KOsy9('\060' + '\157' + chr(50) + '\065' + chr(2226 - 2172), 7918 - 7910), ehT0Px3KOsy9(chr(2102 - 2054) + chr(6295 - 6184) + chr(2108 - 2053) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1637 - 1589) + '\x6f' + '\063' + '\065' + chr(1117 - 1066), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\x32' + chr(55), 34446 - 34438), ehT0Px3KOsy9(chr(573 - 525) + chr(0b1101111) + chr(0b110011) + chr(49) + '\062', 47644 - 47636), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + '\x32' + chr(55) + chr(1105 - 1054), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(51) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b11110 + 0o25) + chr(54), 21883 - 21875), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + chr(1889 - 1840) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1100100 + 0o13) + '\063' + '\063' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b111011 + 0o64) + chr(2331 - 2281) + '\064' + chr(265 - 213), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b110100) + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(0b10000 + 0o42), 46550 - 46542), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x37', 0b1000), ehT0Px3KOsy9(chr(1580 - 1532) + '\157' + '\063' + chr(1903 - 1855) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110101 + 0o0), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + '\065' + '\x31', 20765 - 20757), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + chr(730 - 679) + chr(528 - 476) + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + chr(270 - 159) + '\065' + chr(0b110101), 30786 - 30778), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + '\067' + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b101100 + 0o103) + '\061' + '\x31' + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11010 + 0o27) + chr(0b11 + 0o62) + chr(51), 57345 - 57337), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + chr(0b101100 + 0o5), 0b1000), ehT0Px3KOsy9(chr(48) + chr(11154 - 11043) + '\061' + '\063' + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10001 + 0o40) + '\x31' + chr(1624 - 1575), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000 + 0o147) + chr(2148 - 2097) + chr(631 - 577) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(1469 - 1421) + '\x6f' + chr(51) + chr(0b11010 + 0o31) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(2617 - 2562) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(511 - 463) + '\157' + chr(0b111 + 0o54) + chr(0b101010 + 0o15) + '\x31', 43830 - 43822), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(637 - 526) + chr(0b110001 + 0o1) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + '\x32' + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101 + 0o142) + chr(2346 - 2296) + '\060' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(574 - 526) + chr(0b1001000 + 0o47) + chr(52) + chr(1644 - 1590), 48447 - 48439), ehT0Px3KOsy9(chr(48) + chr(0b101101 + 0o102) + '\x33' + chr(0b10111 + 0o33), 0b1000), ehT0Px3KOsy9(chr(2197 - 2149) + '\157' + '\x37' + chr(50), 47632 - 47624), ehT0Px3KOsy9(chr(1997 - 1949) + '\x6f' + '\063' + '\060', 0o10), ehT0Px3KOsy9(chr(2112 - 2064) + '\157' + chr(49) + chr(0b101000 + 0o12) + chr(0b110001), 4188 - 4180), ehT0Px3KOsy9(chr(284 - 236) + chr(0b1000101 + 0o52) + '\x32' + '\x37' + chr(0b100111 + 0o17), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x35' + chr(0b100011 + 0o15), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + chr(8614 - 8503) + chr(0b1100100) + chr(7820 - 7719))(chr(0b1110101) + '\164' + chr(102) + chr(0b101101) + chr(3062 - 3006)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def qxrVBjeryNEZ(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
dhsX2yb4nWkJ = oVre8I6UXc3b._separate_objects_by_boxes(SY0NIgiWrFfS)
qUvKSH7GzXwG = MVEN8G6CxlvR()
for (VNGQdHSFPrso, RXi3oIFFuUKJ) in xafqLlk3kkUe(dhsX2yb4nWkJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb1\x96\xd8Y\xa2\x8d\xf9\xf27\rC\xe7'), '\x64' + '\145' + chr(0b1100011) + chr(7049 - 6938) + '\x64' + chr(0b1000011 + 0o42))('\x75' + chr(10560 - 10444) + chr(2609 - 2507) + chr(584 - 539) + '\070'))():
dGTXJOwmrQUr = Dx22bkKPdt5d([mDuDykdz0pcm.y_loc for mDuDykdz0pcm in RXi3oIFFuUKJ])
xafqLlk3kkUe(qUvKSH7GzXwG, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5\x98\xefy\x82\x99\x80\xd5"jn\xee'), chr(3317 - 3217) + chr(0b10000 + 0o125) + '\x63' + chr(0b1100001 + 0o16) + chr(0b1100100) + chr(9086 - 8985))(chr(0b1110101) + chr(0b1000001 + 0o63) + chr(0b1100110) + '\x2d' + chr(0b111000)))(MVEN8G6CxlvR([mDuDykdz0pcm for mDuDykdz0pcm in RXi3oIFFuUKJ if xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'\x86\xb3\xc2S\x88'), chr(0b1100100) + chr(0b1100101) + chr(0b1011 + 0o130) + '\x6f' + chr(0b1000101 + 0o37) + '\x65')('\165' + chr(5058 - 4942) + chr(8092 - 7990) + chr(45) + '\070')) == dGTXJOwmrQUr]))
return qUvKSH7GzXwG
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.bottom
|
def bottom(self, objects: Set[Object]) -> Set[Object]:
"""
Return the bottom most objects(i.e. maximum y_loc). The comparison is done separately for
each box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set: Set[Object] = set()
for _, box_objects in objects_per_box.items():
max_y_loc = max([obj.y_loc for obj in box_objects])
return_set.update(set([obj for obj in box_objects if obj.y_loc == max_y_loc]))
return return_set
|
python
|
def bottom(self, objects: Set[Object]) -> Set[Object]:
"""
Return the bottom most objects(i.e. maximum y_loc). The comparison is done separately for
each box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set: Set[Object] = set()
for _, box_objects in objects_per_box.items():
max_y_loc = max([obj.y_loc for obj in box_objects])
return_set.update(set([obj for obj in box_objects if obj.y_loc == max_y_loc]))
return return_set
|
[
"def",
"bottom",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_per_box",
"=",
"self",
".",
"_separate_objects_by_boxes",
"(",
"objects",
")",
"return_set",
":",
"Set",
"[",
"Object",
"]",
"=",
"set",
"(",
")",
"for",
"_",
",",
"box_objects",
"in",
"objects_per_box",
".",
"items",
"(",
")",
":",
"max_y_loc",
"=",
"max",
"(",
"[",
"obj",
".",
"y_loc",
"for",
"obj",
"in",
"box_objects",
"]",
")",
"return_set",
".",
"update",
"(",
"set",
"(",
"[",
"obj",
"for",
"obj",
"in",
"box_objects",
"if",
"obj",
".",
"y_loc",
"==",
"max_y_loc",
"]",
")",
")",
"return",
"return_set"
] |
Return the bottom most objects(i.e. maximum y_loc). The comparison is done separately for
each box.
|
[
"Return",
"the",
"bottom",
"most",
"objects",
"(",
"i",
".",
"e",
".",
"maximum",
"y_loc",
")",
".",
"The",
"comparison",
"is",
"done",
"separately",
"for",
"each",
"box",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L357-L367
|
train
|
Return the bottom most objects in a set.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHl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RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(111) + chr(0b110011) + chr(48) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + '\065' + chr(53), 31165 - 31157), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\x6f' + '\065' + chr(53), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b110001) + chr(0b11000 + 0o37), 0o10), ehT0Px3KOsy9(chr(48) + chr(3434 - 3323) + '\062' + chr(2284 - 2235) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(0b110100) + chr(0b10001 + 0o40), 64661 - 64653), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\157' + '\063' + chr(0b101001 + 0o15) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(1806 - 1758) + '\x6f' + chr(0b100010 + 0o20) + chr(0b110000) + '\x37', 0o10), ehT0Px3KOsy9('\060' + chr(0b11100 + 0o123) + '\066' + chr(2298 - 2248), 43544 - 43536), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + '\x31' + '\x33' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(347 - 298) + chr(275 - 220) + chr(2265 - 2214), 0o10), ehT0Px3KOsy9(chr(48) + chr(7972 - 7861) + '\062' + '\067' + '\061', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + '\064' + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + '\061' + chr(0b11101 + 0o25), 0o10), ehT0Px3KOsy9('\x30' + chr(0b111001 + 0o66) + chr(49) + '\064' + '\x33', 8), ehT0Px3KOsy9(chr(0b110000) + chr(2339 - 2228) + chr(1965 - 1915) + chr(0b110000) + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(52) + chr(326 - 271), 51877 - 51869), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(1503 - 1448) + chr(0b1001 + 0o51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110100) + chr(1675 - 1627), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(676 - 627) + '\x34' + '\060', 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b1101111) + chr(51) + chr(0b1010 + 0o54) + chr(373 - 323), 5399 - 5391), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(169 - 120) + '\x30' + chr(1770 - 1720), 0o10), ehT0Px3KOsy9(chr(1334 - 1286) + '\157' + chr(0b110010) + '\065' + '\067', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\061' + chr(0b110001) + '\x32', 32802 - 32794), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1 + 0o66) + chr(0b10 + 0o61), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4187 - 4076) + chr(49) + '\065' + chr(0b11111 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011001 + 0o26) + chr(49) + chr(0b110110) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(920 - 872) + '\x6f' + chr(51) + chr(0b110110) + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x37' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1110 + 0o43) + chr(54) + chr(54), 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + '\x34' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100101 + 0o14) + '\x33' + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100010 + 0o17) + chr(1387 - 1339) + chr(51), 0o10), ehT0Px3KOsy9(chr(803 - 755) + '\157' + chr(0b110001) + '\062' + chr(1377 - 1322), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + '\067', 22220 - 22212), ehT0Px3KOsy9(chr(0b110000) + chr(0b111 + 0o150) + '\x33' + chr(53) + chr(0b110001), 42497 - 42489), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1100 + 0o45) + chr(1425 - 1375) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11 + 0o57) + '\x37', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1838 - 1786) + chr(0b1101 + 0o47), 0b1000), ehT0Px3KOsy9('\060' + chr(11519 - 11408) + chr(1817 - 1766) + '\064' + chr(0b10101 + 0o42), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + '\065' + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xee'), chr(0b100100 + 0o100) + chr(9894 - 9793) + chr(0b1010 + 0o131) + chr(4526 - 4415) + '\144' + '\145')('\165' + chr(0b1110100) + chr(5407 - 5305) + chr(0b101101) + chr(1232 - 1176)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def kXxsZxlIQUSQ(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
dhsX2yb4nWkJ = oVre8I6UXc3b._separate_objects_by_boxes(SY0NIgiWrFfS)
qUvKSH7GzXwG = MVEN8G6CxlvR()
for (VNGQdHSFPrso, RXi3oIFFuUKJ) in xafqLlk3kkUe(dhsX2yb4nWkJ, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\x17[*\xc7\xfb\xc0\xce^\x0b3\x80'), chr(0b1001111 + 0o25) + chr(0b10000 + 0o125) + chr(7269 - 7170) + chr(0b1001100 + 0o43) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(12582 - 12466) + chr(3750 - 3648) + chr(0b110 + 0o47) + '\070'))():
rj1EpAcGeozO = tsdjvlgh9gDP([mDuDykdz0pcm.y_loc for mDuDykdz0pcm in RXi3oIFFuUKJ])
xafqLlk3kkUe(qUvKSH7GzXwG, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a\x19l\n\xe7\xef\xb9\xe9Kl\x1e\x89'), chr(100) + chr(0b1100101) + '\143' + chr(10517 - 10406) + chr(100) + '\x65')(chr(0b1110101) + chr(215 - 99) + chr(0b1100110) + chr(1730 - 1685) + chr(832 - 776)))(MVEN8G6CxlvR([mDuDykdz0pcm for mDuDykdz0pcm in RXi3oIFFuUKJ if xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb92A \xed'), '\144' + chr(0b10011 + 0o122) + '\143' + '\x6f' + '\x64' + chr(0b1100101))('\x75' + chr(3210 - 3094) + '\x66' + '\055' + '\x38')) == rj1EpAcGeozO]))
return qUvKSH7GzXwG
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.above
|
def above(self, objects: Set[Object]) -> Set[Object]:
"""
Returns the set of objects in the same boxes that are above the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
above the first object in the first box, and those above the second object in the second box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box in objects_per_box:
# min_y_loc corresponds to the top-most object.
min_y_loc = min([obj.y_loc for obj in objects_per_box[box]])
for candidate_obj in box.objects:
if candidate_obj.y_loc < min_y_loc:
return_set.add(candidate_obj)
return return_set
|
python
|
def above(self, objects: Set[Object]) -> Set[Object]:
"""
Returns the set of objects in the same boxes that are above the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
above the first object in the first box, and those above the second object in the second box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box in objects_per_box:
# min_y_loc corresponds to the top-most object.
min_y_loc = min([obj.y_loc for obj in objects_per_box[box]])
for candidate_obj in box.objects:
if candidate_obj.y_loc < min_y_loc:
return_set.add(candidate_obj)
return return_set
|
[
"def",
"above",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_per_box",
"=",
"self",
".",
"_separate_objects_by_boxes",
"(",
"objects",
")",
"return_set",
"=",
"set",
"(",
")",
"for",
"box",
"in",
"objects_per_box",
":",
"# min_y_loc corresponds to the top-most object.",
"min_y_loc",
"=",
"min",
"(",
"[",
"obj",
".",
"y_loc",
"for",
"obj",
"in",
"objects_per_box",
"[",
"box",
"]",
"]",
")",
"for",
"candidate_obj",
"in",
"box",
".",
"objects",
":",
"if",
"candidate_obj",
".",
"y_loc",
"<",
"min_y_loc",
":",
"return_set",
".",
"add",
"(",
"candidate_obj",
")",
"return",
"return_set"
] |
Returns the set of objects in the same boxes that are above the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
above the first object in the first box, and those above the second object in the second box.
|
[
"Returns",
"the",
"set",
"of",
"objects",
"in",
"the",
"same",
"boxes",
"that",
"are",
"above",
"the",
"given",
"objects",
".",
"That",
"is",
"if",
"the",
"input",
"is",
"a",
"set",
"of",
"two",
"objects",
"one",
"in",
"each",
"box",
"we",
"will",
"return",
"a",
"union",
"of",
"the",
"objects",
"above",
"the",
"first",
"object",
"in",
"the",
"first",
"box",
"and",
"those",
"above",
"the",
"second",
"object",
"in",
"the",
"second",
"box",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L370-L384
|
train
|
Returns the set of objects in the same boxes that are above the given objects.
|
Pu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,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1101111) + '\x35' + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(0b101100 + 0o13) + chr(0b1011 + 0o53), 52839 - 52831), ehT0Px3KOsy9(chr(2131 - 2083) + chr(111) + chr(54) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(406 - 357) + chr(1502 - 1449), 0b1000), ehT0Px3KOsy9(chr(1166 - 1118) + '\157' + chr(0b110011) + chr(52) + chr(49), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + chr(1378 - 1328) + chr(54), 6179 - 6171), ehT0Px3KOsy9(chr(105 - 57) + chr(111) + '\x32' + chr(54) + chr(2395 - 2345), 0b1000), ehT0Px3KOsy9('\060' + chr(0b111001 + 0o66) + '\061' + chr(0b11000 + 0o30) + chr(0b11101 + 0o24), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\x6f' + chr(0b100111 + 0o13) + '\x37' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\062' + '\x34', 8471 - 8463), ehT0Px3KOsy9(chr(48) + chr(11034 - 10923) + chr(1555 - 1501) + '\x32', 8), ehT0Px3KOsy9('\060' + chr(111) + '\x37' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(12284 - 12173) + chr(0b10010 + 0o41) + '\066' + '\063', 57481 - 57473), ehT0Px3KOsy9(chr(2093 - 2045) + chr(111) + chr(0b10001 + 0o40) + '\x34' + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + '\x37' + '\063', 16578 - 16570), ehT0Px3KOsy9(chr(1423 - 1375) + chr(0b1100111 + 0o10) + chr(0b110111) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + chr(0b11010 + 0o31) + chr(0b100 + 0o60) + chr(54), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b101101 + 0o10) + '\x30', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(0b110111) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(49) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11010 + 0o27) + chr(0b100100 + 0o20) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(0b0 + 0o60) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b110100) + chr(0b10 + 0o57), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b1001 + 0o50) + chr(0b110001 + 0o4) + chr(0b1000 + 0o54), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(0b110100) + chr(832 - 782), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(48) + chr(50), 0o10), ehT0Px3KOsy9(chr(243 - 195) + '\157' + '\061' + '\x37' + '\x35', 8), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(7057 - 6946) + chr(864 - 815) + '\x32' + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\066' + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(0b100011 + 0o21) + chr(1538 - 1484), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + '\x32' + chr(0b100001 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(933 - 885) + chr(0b101100 + 0o10), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(51) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(1274 - 1226) + chr(0b1101111) + chr(51) + chr(51) + chr(1363 - 1310), 0o10), ehT0Px3KOsy9(chr(1532 - 1484) + chr(3418 - 3307) + chr(0b111 + 0o56) + chr(0b11110 + 0o25), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + chr(2679 - 2627) + '\061', 8), ehT0Px3KOsy9(chr(1479 - 1431) + chr(111) + chr(0b11 + 0o56) + chr(0b110000) + chr(48), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2108 - 2059) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1001 + 0o52) + '\x33' + chr(444 - 392), 15420 - 15412), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + '\066' + chr(0b110011), 11517 - 11509)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + '\065' + chr(0b110000), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x00'), chr(100) + chr(0b1100101) + chr(4629 - 4530) + chr(111) + chr(0b101 + 0o137) + '\x65')(chr(0b101101 + 0o110) + chr(0b1000111 + 0o55) + chr(5287 - 5185) + '\x2d' + chr(0b100100 + 0o24)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def XPalR83Jzy4N(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
dhsX2yb4nWkJ = oVre8I6UXc3b._separate_objects_by_boxes(SY0NIgiWrFfS)
qUvKSH7GzXwG = MVEN8G6CxlvR()
for xmmLsPObAALK in dhsX2yb4nWkJ:
dGTXJOwmrQUr = Dx22bkKPdt5d([mDuDykdz0pcm.y_loc for mDuDykdz0pcm in dhsX2yb4nWkJ[xmmLsPObAALK]])
for PNAbrJthTfPs in xafqLlk3kkUe(xmmLsPObAALK, xafqLlk3kkUe(SXOLrMavuUCe(b'A\xdcX\xe8\x82b\xc1'), chr(100) + '\145' + chr(0b1100011) + chr(8524 - 8413) + chr(2883 - 2783) + chr(101))(chr(117) + chr(116) + chr(102) + chr(0b101101) + '\070')):
if xafqLlk3kkUe(PNAbrJthTfPs, xafqLlk3kkUe(SXOLrMavuUCe(b'W\xe1^\xe2\x82'), chr(0b1100100) + '\145' + '\143' + '\x6f' + chr(3165 - 3065) + chr(0b1100101))(chr(5793 - 5676) + chr(116) + '\x66' + '\055' + '\070')) < dGTXJOwmrQUr:
xafqLlk3kkUe(qUvKSH7GzXwG, xafqLlk3kkUe(SXOLrMavuUCe(b'[\xf4\x02\xfc\xd8u\xf5t\xe7\xdb`\x0e'), chr(0b1100100) + '\x65' + chr(9799 - 9700) + chr(0b1000000 + 0o57) + '\x64' + chr(101))(chr(117) + '\164' + chr(102) + '\x2d' + '\x38'))(PNAbrJthTfPs)
return qUvKSH7GzXwG
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage.below
|
def below(self, objects: Set[Object]) -> Set[Object]:
"""
Returns the set of objects in the same boxes that are below the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
below the first object in the first box, and those below the second object in the second box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box in objects_per_box:
# max_y_loc corresponds to the bottom-most object.
max_y_loc = max([obj.y_loc for obj in objects_per_box[box]])
for candidate_obj in box.objects:
if candidate_obj.y_loc > max_y_loc:
return_set.add(candidate_obj)
return return_set
|
python
|
def below(self, objects: Set[Object]) -> Set[Object]:
"""
Returns the set of objects in the same boxes that are below the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
below the first object in the first box, and those below the second object in the second box.
"""
objects_per_box = self._separate_objects_by_boxes(objects)
return_set = set()
for box in objects_per_box:
# max_y_loc corresponds to the bottom-most object.
max_y_loc = max([obj.y_loc for obj in objects_per_box[box]])
for candidate_obj in box.objects:
if candidate_obj.y_loc > max_y_loc:
return_set.add(candidate_obj)
return return_set
|
[
"def",
"below",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_per_box",
"=",
"self",
".",
"_separate_objects_by_boxes",
"(",
"objects",
")",
"return_set",
"=",
"set",
"(",
")",
"for",
"box",
"in",
"objects_per_box",
":",
"# max_y_loc corresponds to the bottom-most object.",
"max_y_loc",
"=",
"max",
"(",
"[",
"obj",
".",
"y_loc",
"for",
"obj",
"in",
"objects_per_box",
"[",
"box",
"]",
"]",
")",
"for",
"candidate_obj",
"in",
"box",
".",
"objects",
":",
"if",
"candidate_obj",
".",
"y_loc",
">",
"max_y_loc",
":",
"return_set",
".",
"add",
"(",
"candidate_obj",
")",
"return",
"return_set"
] |
Returns the set of objects in the same boxes that are below the given objects. That is, if
the input is a set of two objects, one in each box, we will return a union of the objects
below the first object in the first box, and those below the second object in the second box.
|
[
"Returns",
"the",
"set",
"of",
"objects",
"in",
"the",
"same",
"boxes",
"that",
"are",
"below",
"the",
"given",
"objects",
".",
"That",
"is",
"if",
"the",
"input",
"is",
"a",
"set",
"of",
"two",
"objects",
"one",
"in",
"each",
"box",
"we",
"will",
"return",
"a",
"union",
"of",
"the",
"objects",
"below",
"the",
"first",
"object",
"in",
"the",
"first",
"box",
"and",
"those",
"below",
"the",
"second",
"object",
"in",
"the",
"second",
"box",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L387-L401
|
train
|
Returns the set of objects in the same boxes that are below the given objects.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2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sX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b111 + 0o150) + chr(1714 - 1665) + chr(53) + chr(0b110011 + 0o4), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b10010 + 0o43) + chr(306 - 258), 47038 - 47030), ehT0Px3KOsy9(chr(0b110000) + chr(0b100101 + 0o112) + '\x32' + chr(925 - 875) + chr(53), 3176 - 3168), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(111) + '\061' + '\060' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1100 + 0o143) + '\063' + chr(798 - 750) + '\067', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101010 + 0o10) + chr(51) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(882 - 833) + chr(2352 - 2299) + chr(0b110001), 46961 - 46953), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1011 + 0o46) + '\060' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(111) + chr(0b101111 + 0o3) + chr(0b101000 + 0o17) + chr(0b110110 + 0o1), 56895 - 56887), ehT0Px3KOsy9(chr(0b110000) + chr(11063 - 10952) + chr(0b110001) + chr(0b110111) + chr(48), 54728 - 54720), ehT0Px3KOsy9(chr(48) + chr(11955 - 11844) + chr(0b110101) + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001001 + 0o46) + '\062' + '\061' + chr(0b1010 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(54) + '\x36', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(0b110110) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(0b110101) + chr(0b110000), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2204 - 2154) + chr(0b100101 + 0o13) + '\065', 57443 - 57435), ehT0Px3KOsy9('\060' + chr(5869 - 5758) + '\065' + chr(0b11001 + 0o27), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b101101 + 0o102) + chr(0b110010) + '\064' + chr(0b101000 + 0o13), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(121 - 71) + '\061' + chr(1692 - 1643), 8), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\067' + chr(2367 - 2314), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11 + 0o57) + chr(55) + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(8214 - 8103) + '\x31' + chr(0b110001) + chr(0b100010 + 0o17), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110 + 0o54) + '\x37' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(655 - 607) + chr(111) + chr(2730 - 2676) + chr(0b100 + 0o62), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\x33' + chr(0b100110 + 0o14), 45495 - 45487), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1101101 + 0o2) + '\063' + chr(1192 - 1143) + chr(1455 - 1400), 3028 - 3020), ehT0Px3KOsy9(chr(48) + chr(111) + chr(50) + '\x33' + chr(243 - 188), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + '\x37' + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + chr(48) + chr(0b11100 + 0o27), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x36' + chr(52), 30656 - 30648), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(6632 - 6521) + chr(0b110010) + chr(0b110000) + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(778 - 727) + '\x30' + chr(54), 50929 - 50921), ehT0Px3KOsy9('\060' + chr(0b1010110 + 0o31) + chr(0b110101) + chr(1215 - 1166), 0o10), ehT0Px3KOsy9(chr(1885 - 1837) + chr(7215 - 7104) + chr(0b110001) + chr(2614 - 2561) + '\064', 2263 - 2255), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b100010 + 0o21) + chr(0b10111 + 0o40), 58452 - 58444), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(12182 - 12071) + chr(49) + '\067' + '\066', 6425 - 6417), ehT0Px3KOsy9(chr(0b110000) + chr(7201 - 7090) + '\x33' + chr(0b110000) + '\x37', 8), ehT0Px3KOsy9(chr(629 - 581) + '\x6f' + chr(51) + '\x34' + '\x33', 13794 - 13786), ehT0Px3KOsy9(chr(550 - 502) + '\x6f' + '\063' + chr(2685 - 2631) + chr(55), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1417 - 1369) + chr(0b1101111) + chr(53) + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'A'), '\144' + chr(0b1000000 + 0o45) + chr(0b1000101 + 0o36) + chr(0b1101111) + '\x64' + '\x65')(chr(117) + chr(0b1110100) + '\x66' + chr(0b101101) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def wL_HtxWRBx2a(oVre8I6UXc3b, SY0NIgiWrFfS) -> nRCEkXkGnMeI[JYjt13TTRebb]:
dhsX2yb4nWkJ = oVre8I6UXc3b._separate_objects_by_boxes(SY0NIgiWrFfS)
qUvKSH7GzXwG = MVEN8G6CxlvR()
for xmmLsPObAALK in dhsX2yb4nWkJ:
rj1EpAcGeozO = tsdjvlgh9gDP([mDuDykdz0pcm.y_loc for mDuDykdz0pcm in dhsX2yb4nWkJ[xmmLsPObAALK]])
for PNAbrJthTfPs in xafqLlk3kkUe(xmmLsPObAALK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x00\n\xff%\xa4\xe9\x1a'), chr(100) + chr(0b101111 + 0o66) + chr(99) + chr(0b1101111) + chr(4107 - 4007) + '\x65')(chr(117) + '\x74' + '\146' + chr(0b101101) + chr(2439 - 2383))):
if xafqLlk3kkUe(PNAbrJthTfPs, xafqLlk3kkUe(SXOLrMavuUCe(b'\x167\xf9/\xa4'), chr(8201 - 8101) + '\x65' + chr(99) + chr(0b1101111) + chr(0b1100100) + '\145')(chr(7954 - 7837) + chr(116) + chr(0b1100110) + chr(0b101101) + chr(1343 - 1287))) > rj1EpAcGeozO:
xafqLlk3kkUe(qUvKSH7GzXwG, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1a"\xa51\xfe\xfe.t\xe57y\xba'), '\x64' + chr(0b111000 + 0o55) + chr(99) + '\x6f' + chr(7521 - 7421) + chr(1490 - 1389))('\x75' + '\164' + '\146' + '\055' + '\x38'))(PNAbrJthTfPs)
return qUvKSH7GzXwG
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage._objects_touch_each_other
|
def _objects_touch_each_other(self, object1: Object, object2: Object) -> bool:
"""
Returns true iff the objects touch each other.
"""
in_vertical_range = object1.y_loc <= object2.y_loc + object2.size and \
object1.y_loc + object1.size >= object2.y_loc
in_horizantal_range = object1.x_loc <= object2.x_loc + object2.size and \
object1.x_loc + object1.size >= object2.x_loc
touch_side = object1.x_loc + object1.size == object2.x_loc or \
object2.x_loc + object2.size == object1.x_loc
touch_top_or_bottom = object1.y_loc + object1.size == object2.y_loc or \
object2.y_loc + object2.size == object1.y_loc
return (in_vertical_range and touch_side) or (in_horizantal_range and touch_top_or_bottom)
|
python
|
def _objects_touch_each_other(self, object1: Object, object2: Object) -> bool:
"""
Returns true iff the objects touch each other.
"""
in_vertical_range = object1.y_loc <= object2.y_loc + object2.size and \
object1.y_loc + object1.size >= object2.y_loc
in_horizantal_range = object1.x_loc <= object2.x_loc + object2.size and \
object1.x_loc + object1.size >= object2.x_loc
touch_side = object1.x_loc + object1.size == object2.x_loc or \
object2.x_loc + object2.size == object1.x_loc
touch_top_or_bottom = object1.y_loc + object1.size == object2.y_loc or \
object2.y_loc + object2.size == object1.y_loc
return (in_vertical_range and touch_side) or (in_horizantal_range and touch_top_or_bottom)
|
[
"def",
"_objects_touch_each_other",
"(",
"self",
",",
"object1",
":",
"Object",
",",
"object2",
":",
"Object",
")",
"->",
"bool",
":",
"in_vertical_range",
"=",
"object1",
".",
"y_loc",
"<=",
"object2",
".",
"y_loc",
"+",
"object2",
".",
"size",
"and",
"object1",
".",
"y_loc",
"+",
"object1",
".",
"size",
">=",
"object2",
".",
"y_loc",
"in_horizantal_range",
"=",
"object1",
".",
"x_loc",
"<=",
"object2",
".",
"x_loc",
"+",
"object2",
".",
"size",
"and",
"object1",
".",
"x_loc",
"+",
"object1",
".",
"size",
">=",
"object2",
".",
"x_loc",
"touch_side",
"=",
"object1",
".",
"x_loc",
"+",
"object1",
".",
"size",
"==",
"object2",
".",
"x_loc",
"or",
"object2",
".",
"x_loc",
"+",
"object2",
".",
"size",
"==",
"object1",
".",
"x_loc",
"touch_top_or_bottom",
"=",
"object1",
".",
"y_loc",
"+",
"object1",
".",
"size",
"==",
"object2",
".",
"y_loc",
"or",
"object2",
".",
"y_loc",
"+",
"object2",
".",
"size",
"==",
"object1",
".",
"y_loc",
"return",
"(",
"in_vertical_range",
"and",
"touch_side",
")",
"or",
"(",
"in_horizantal_range",
"and",
"touch_top_or_bottom",
")"
] |
Returns true iff the objects touch each other.
|
[
"Returns",
"true",
"iff",
"the",
"objects",
"touch",
"each",
"other",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L654-L666
|
train
|
Returns true iff the objects touch each other.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q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y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + '\064' + chr(0b100001 + 0o21), 36488 - 36480), ehT0Px3KOsy9(chr(1287 - 1239) + chr(0b1101111) + chr(879 - 828) + chr(2648 - 2594) + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(48) + '\x32', 0o10), ehT0Px3KOsy9(chr(232 - 184) + chr(12145 - 12034) + '\x31' + '\065' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + '\064' + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(78 - 26) + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(660 - 605) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101001 + 0o11) + chr(893 - 842) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1102 - 1053) + '\x30' + chr(0b11 + 0o57), 63634 - 63626), ehT0Px3KOsy9(chr(1152 - 1104) + '\x6f' + chr(1714 - 1664) + chr(50) + chr(2616 - 2563), 0b1000), ehT0Px3KOsy9(chr(713 - 665) + chr(0b11 + 0o154) + chr(256 - 207) + chr(1075 - 1026) + chr(1244 - 1193), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\x33' + chr(1666 - 1617), ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(111) + '\062' + chr(0b1100 + 0o44), ord("\x08")), ehT0Px3KOsy9(chr(633 - 585) + chr(0b1101111) + chr(0b110001) + '\x37' + '\x36', 54573 - 54565), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + '\061' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(637 - 589) + '\x6f' + chr(0b11110 + 0o23) + '\x35' + chr(0b11011 + 0o34), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b110101) + chr(1570 - 1519), 30525 - 30517), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b1111 + 0o43) + '\x37' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110111) + '\x32', 0o10), ehT0Px3KOsy9(chr(1036 - 988) + '\157' + chr(0b110001) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + chr(51) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(535 - 487) + '\x6f' + '\062' + chr(0b110011 + 0o0) + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1100001 + 0o16) + '\061' + '\x37' + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(1734 - 1686) + '\x6f' + chr(1113 - 1064) + chr(0b110011 + 0o3) + chr(0b11001 + 0o36), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(0b11110 + 0o25) + chr(0b111 + 0o56), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + chr(2910 - 2855) + chr(55), 11790 - 11782), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\157' + chr(0b1000 + 0o51) + chr(0b110000) + chr(0b1010 + 0o54), ord("\x08")), ehT0Px3KOsy9(chr(525 - 477) + chr(111) + chr(0b10110 + 0o37) + chr(2346 - 2297), 0o10), ehT0Px3KOsy9(chr(48) + chr(455 - 344) + chr(0b1001 + 0o50) + '\065' + chr(50), 34479 - 34471), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1411 - 1360) + chr(1680 - 1626), 8), ehT0Px3KOsy9(chr(1921 - 1873) + chr(111) + chr(1600 - 1550) + '\x34' + '\x32', 0o10), ehT0Px3KOsy9(chr(1489 - 1441) + '\x6f' + chr(0b11101 + 0o31) + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(1069 - 1015) + '\066', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10100 + 0o35) + chr(2753 - 2699) + chr(48), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2476 - 2426) + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2037 - 1986) + chr(0b100011 + 0o20) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10011 + 0o134) + chr(0b0 + 0o61) + chr(0b110010) + chr(48), 55259 - 55251), ehT0Px3KOsy9(chr(1771 - 1723) + '\x6f' + '\x34' + chr(2478 - 2428), 0b1000), ehT0Px3KOsy9('\060' + chr(4939 - 4828) + chr(54) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001000 + 0o47) + chr(753 - 702) + chr(51) + '\062', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101111) + chr(0b1001 + 0o54) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'L'), chr(1877 - 1777) + chr(0b1100101) + chr(0b1 + 0o142) + chr(0b110010 + 0o75) + chr(7096 - 6996) + chr(101))(chr(0b1110101) + chr(8496 - 8380) + chr(102) + chr(45) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def bOQd8ogY1Iti(oVre8I6UXc3b, Rh5MeOJHxsIA, A6Xxp3OKJ713) -> WbBjf8Y7v9VN:
UwWXKvkfNbet = Rh5MeOJHxsIA.y_loc <= A6Xxp3OKJ713.y_loc + A6Xxp3OKJ713.NLcc3BCJnQka and Rh5MeOJHxsIA.y_loc + Rh5MeOJHxsIA.NLcc3BCJnQka >= A6Xxp3OKJ713.y_loc
rd2v1RGnKNwU = Rh5MeOJHxsIA.x_loc <= A6Xxp3OKJ713.x_loc + A6Xxp3OKJ713.NLcc3BCJnQka and Rh5MeOJHxsIA.x_loc + Rh5MeOJHxsIA.NLcc3BCJnQka >= A6Xxp3OKJ713.x_loc
cp7q4iMlba2U = Rh5MeOJHxsIA.x_loc + Rh5MeOJHxsIA.NLcc3BCJnQka == A6Xxp3OKJ713.x_loc or A6Xxp3OKJ713.x_loc + A6Xxp3OKJ713.NLcc3BCJnQka == Rh5MeOJHxsIA.x_loc
VA7Gn9Dhi4fJ = Rh5MeOJHxsIA.y_loc + Rh5MeOJHxsIA.NLcc3BCJnQka == A6Xxp3OKJ713.y_loc or A6Xxp3OKJ713.y_loc + A6Xxp3OKJ713.NLcc3BCJnQka == Rh5MeOJHxsIA.y_loc
return UwWXKvkfNbet and cp7q4iMlba2U or (rd2v1RGnKNwU and VA7Gn9Dhi4fJ)
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage._separate_objects_by_boxes
|
def _separate_objects_by_boxes(self, objects: Set[Object]) -> Dict[Box, List[Object]]:
"""
Given a set of objects, separate them by the boxes they belong to and return a dict.
"""
objects_per_box: Dict[Box, List[Object]] = defaultdict(list)
for box in self.boxes:
for object_ in objects:
if object_ in box.objects:
objects_per_box[box].append(object_)
return objects_per_box
|
python
|
def _separate_objects_by_boxes(self, objects: Set[Object]) -> Dict[Box, List[Object]]:
"""
Given a set of objects, separate them by the boxes they belong to and return a dict.
"""
objects_per_box: Dict[Box, List[Object]] = defaultdict(list)
for box in self.boxes:
for object_ in objects:
if object_ in box.objects:
objects_per_box[box].append(object_)
return objects_per_box
|
[
"def",
"_separate_objects_by_boxes",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
")",
"->",
"Dict",
"[",
"Box",
",",
"List",
"[",
"Object",
"]",
"]",
":",
"objects_per_box",
":",
"Dict",
"[",
"Box",
",",
"List",
"[",
"Object",
"]",
"]",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"box",
"in",
"self",
".",
"boxes",
":",
"for",
"object_",
"in",
"objects",
":",
"if",
"object_",
"in",
"box",
".",
"objects",
":",
"objects_per_box",
"[",
"box",
"]",
".",
"append",
"(",
"object_",
")",
"return",
"objects_per_box"
] |
Given a set of objects, separate them by the boxes they belong to and return a dict.
|
[
"Given",
"a",
"set",
"of",
"objects",
"separate",
"them",
"by",
"the",
"boxes",
"they",
"belong",
"to",
"and",
"return",
"a",
"dict",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L668-L677
|
train
|
Given a set of objects separate them by the boxes they belong to and return a dict.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,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w8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b11001 + 0o126) + '\062' + chr(0b101100 + 0o12) + chr(0b11100 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100000 + 0o26) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(172 - 124) + chr(7572 - 7461) + chr(0b100111 + 0o14) + '\x31' + chr(747 - 693), ord("\x08")), ehT0Px3KOsy9(chr(1167 - 1119) + '\157' + chr(533 - 484) + chr(54) + chr(0b110111 + 0o0), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1110 + 0o141) + chr(55) + chr(53), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b110001 + 0o76) + '\x32' + chr(54) + chr(0b110000), 10738 - 10730), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + '\x32' + chr(1210 - 1158), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\063' + '\x35' + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x34' + '\062', 15315 - 15307), ehT0Px3KOsy9(chr(48) + '\157' + '\x35' + '\x30', 30025 - 30017), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1010 + 0o50) + chr(54) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(8811 - 8700) + '\061' + '\062' + chr(0b110010), 45615 - 45607), ehT0Px3KOsy9(chr(48) + chr(9210 - 9099) + chr(0b110011) + chr(1197 - 1149) + chr(55), 33541 - 33533), ehT0Px3KOsy9('\060' + chr(2647 - 2536) + '\066' + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110011) + chr(535 - 482) + '\x31', 33310 - 33302), ehT0Px3KOsy9(chr(902 - 854) + '\157' + chr(565 - 515) + chr(55) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + '\062' + '\061', 51578 - 51570), ehT0Px3KOsy9(chr(2214 - 2166) + chr(7811 - 7700) + chr(54) + '\060', 25251 - 25243), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(0b101111 + 0o1) + chr(0b110000), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + chr(0b100111 + 0o20) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(2454 - 2343) + chr(0b110101) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1464 - 1416) + chr(2531 - 2420) + chr(0b11101 + 0o24) + '\066' + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(3641 - 3530) + chr(1459 - 1405) + chr(48), 8), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + chr(50) + chr(48) + chr(0b110111), 55507 - 55499), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(55) + '\x35', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1011011 + 0o24) + chr(51) + '\062' + '\064', 20788 - 20780), ehT0Px3KOsy9(chr(1883 - 1835) + chr(8053 - 7942) + chr(0b110011) + '\x31' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(2191 - 2143) + '\x6f' + chr(0b110010) + '\x33' + chr(2294 - 2239), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(5627 - 5516) + chr(2310 - 2257) + chr(0b110000), 8), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b1101111) + '\x31' + chr(2546 - 2494) + '\x32', 6603 - 6595), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(783 - 672) + chr(49) + '\x35' + '\x32', 0b1000), ehT0Px3KOsy9(chr(354 - 306) + chr(111) + chr(1202 - 1152) + chr(52) + '\x30', 40132 - 40124), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11011 + 0o30) + chr(52) + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(2102 - 2051) + chr(0b100000 + 0o22) + chr(0b1101 + 0o46), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1548 - 1499), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\064' + chr(1197 - 1145), 15019 - 15011), ehT0Px3KOsy9(chr(1443 - 1395) + chr(0b1101111) + chr(0b110000 + 0o1) + chr(50) + chr(0b11110 + 0o25), 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + '\061' + chr(109 - 58) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + '\x34' + chr(53), 19173 - 19165), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + '\066' + chr(0b110101), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(2218 - 2170) + chr(0b1101111) + '\065' + chr(2154 - 2106), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a'), chr(100) + chr(101) + '\143' + '\157' + chr(100) + '\x65')('\x75' + '\x74' + chr(6600 - 6498) + '\x2d' + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def OpFSuOQqSKoZ(oVre8I6UXc3b, SY0NIgiWrFfS) -> zBnV56fc6HrA[jxoG1yIsLqiQ, qRxF7OQ0y39T[JYjt13TTRebb]]:
dhsX2yb4nWkJ = rLgqW9imlCdX(YyaZ4tpXu4lf)
for xmmLsPObAALK in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd6[\xb6\x12N'), chr(0b101110 + 0o66) + chr(0b1000011 + 0o42) + '\x63' + chr(10777 - 10666) + '\x64' + '\x65')(chr(0b1110101) + chr(10905 - 10789) + '\146' + chr(858 - 813) + chr(0b111000))):
for ICzcWFwZUAA8 in SY0NIgiWrFfS:
if ICzcWFwZUAA8 in xafqLlk3kkUe(xmmLsPObAALK, xafqLlk3kkUe(SXOLrMavuUCe(b"\xdbV\xa4\x12^\xc4'"), chr(5469 - 5369) + '\x65' + '\143' + '\157' + chr(0b1100001 + 0o3) + chr(101))('\165' + '\164' + '\x66' + chr(45) + chr(0b111000))):
xafqLlk3kkUe(dhsX2yb4nWkJ[xmmLsPObAALK], xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5D\xbe\x12S\xd4'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(111) + '\x64' + chr(2121 - 2020))('\165' + chr(0b1110100) + chr(102) + '\x2d' + '\070'))(ICzcWFwZUAA8)
return dhsX2yb4nWkJ
|
allenai/allennlp
|
allennlp/semparse/domain_languages/nlvr_language.py
|
NlvrLanguage._get_objects_with_same_attribute
|
def _get_objects_with_same_attribute(self,
objects: Set[Object],
attribute_function: Callable[[Object], str]) -> Set[Object]:
"""
Returns the set of objects for which the attribute function returns an attribute value that
is most frequent in the initial set, if the frequency is greater than 1. If not, all
objects have different attribute values, and this method returns an empty set.
"""
objects_of_attribute: Dict[str, Set[Object]] = defaultdict(set)
for entity in objects:
objects_of_attribute[attribute_function(entity)].add(entity)
if not objects_of_attribute:
return set()
most_frequent_attribute = max(objects_of_attribute, key=lambda x: len(objects_of_attribute[x]))
if len(objects_of_attribute[most_frequent_attribute]) <= 1:
return set()
return objects_of_attribute[most_frequent_attribute]
|
python
|
def _get_objects_with_same_attribute(self,
objects: Set[Object],
attribute_function: Callable[[Object], str]) -> Set[Object]:
"""
Returns the set of objects for which the attribute function returns an attribute value that
is most frequent in the initial set, if the frequency is greater than 1. If not, all
objects have different attribute values, and this method returns an empty set.
"""
objects_of_attribute: Dict[str, Set[Object]] = defaultdict(set)
for entity in objects:
objects_of_attribute[attribute_function(entity)].add(entity)
if not objects_of_attribute:
return set()
most_frequent_attribute = max(objects_of_attribute, key=lambda x: len(objects_of_attribute[x]))
if len(objects_of_attribute[most_frequent_attribute]) <= 1:
return set()
return objects_of_attribute[most_frequent_attribute]
|
[
"def",
"_get_objects_with_same_attribute",
"(",
"self",
",",
"objects",
":",
"Set",
"[",
"Object",
"]",
",",
"attribute_function",
":",
"Callable",
"[",
"[",
"Object",
"]",
",",
"str",
"]",
")",
"->",
"Set",
"[",
"Object",
"]",
":",
"objects_of_attribute",
":",
"Dict",
"[",
"str",
",",
"Set",
"[",
"Object",
"]",
"]",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"entity",
"in",
"objects",
":",
"objects_of_attribute",
"[",
"attribute_function",
"(",
"entity",
")",
"]",
".",
"add",
"(",
"entity",
")",
"if",
"not",
"objects_of_attribute",
":",
"return",
"set",
"(",
")",
"most_frequent_attribute",
"=",
"max",
"(",
"objects_of_attribute",
",",
"key",
"=",
"lambda",
"x",
":",
"len",
"(",
"objects_of_attribute",
"[",
"x",
"]",
")",
")",
"if",
"len",
"(",
"objects_of_attribute",
"[",
"most_frequent_attribute",
"]",
")",
"<=",
"1",
":",
"return",
"set",
"(",
")",
"return",
"objects_of_attribute",
"[",
"most_frequent_attribute",
"]"
] |
Returns the set of objects for which the attribute function returns an attribute value that
is most frequent in the initial set, if the frequency is greater than 1. If not, all
objects have different attribute values, and this method returns an empty set.
|
[
"Returns",
"the",
"set",
"of",
"objects",
"for",
"which",
"the",
"attribute",
"function",
"returns",
"an",
"attribute",
"value",
"that",
"is",
"most",
"frequent",
"in",
"the",
"initial",
"set",
"if",
"the",
"frequency",
"is",
"greater",
"than",
"1",
".",
"If",
"not",
"all",
"objects",
"have",
"different",
"attribute",
"values",
"and",
"this",
"method",
"returns",
"an",
"empty",
"set",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/nlvr_language.py#L679-L695
|
train
|
Returns the set of objects for which the attribute function returns an attribute value that is most frequent in the initial set.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALC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k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(111) + chr(49) + '\x30' + chr(48), 53539 - 53531), ehT0Px3KOsy9(chr(1103 - 1055) + chr(0b111100 + 0o63) + '\x32' + chr(0b110010) + '\061', 0b1000), ehT0Px3KOsy9('\060' + chr(0b101010 + 0o105) + '\063' + chr(55) + chr(49), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100101 + 0o16) + chr(49) + chr(0b101101 + 0o10), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\062', 26467 - 26459), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + '\x32', 34748 - 34740), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(2306 - 2254) + chr(0b100101 + 0o20), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(1918 - 1866) + '\063', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(221 - 171) + chr(0b10111 + 0o31) + '\x31', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + chr(4208 - 4097) + '\x32' + chr(208 - 156) + chr(55), 0b1000), ehT0Px3KOsy9(chr(394 - 346) + '\157' + chr(0b110001) + '\063' + chr(51), 21010 - 21002), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + '\060' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b111101 + 0o62) + chr(51) + '\x37' + chr(1505 - 1456), 8), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b1000011 + 0o54) + '\x32' + chr(53) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(283 - 235) + chr(111) + chr(50) + chr(2655 - 2600), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b110111 + 0o70) + chr(0b101000 + 0o11) + chr(0b110101) + chr(0b110010), 35110 - 35102), ehT0Px3KOsy9(chr(1484 - 1436) + '\157' + chr(1570 - 1519) + chr(0b110101) + chr(49), 0o10), ehT0Px3KOsy9(chr(499 - 451) + chr(0b1101111) + chr(0b110010) + chr(0b10111 + 0o36) + '\x33', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101100 + 0o3) + chr(1127 - 1077) + chr(50) + chr(0b10000 + 0o42), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10111 + 0o33) + '\x30' + chr(51), 27889 - 27881), ehT0Px3KOsy9('\060' + chr(0b1101011 + 0o4) + '\x33' + '\061' + chr(2641 - 2589), ord("\x08")), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b101110 + 0o101) + '\x31' + chr(2420 - 2365) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(379 - 331) + chr(334 - 223) + '\063' + chr(0b110001) + chr(0b10111 + 0o33), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(1867 - 1816) + '\x35' + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000011 + 0o54) + chr(0b110010) + chr(0b11101 + 0o26) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1101111) + chr(0b1011 + 0o47) + '\067' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(0b110101) + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + '\067' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(10331 - 10220) + chr(49) + chr(55) + '\x32', 156 - 148), ehT0Px3KOsy9(chr(651 - 603) + chr(111) + '\x33', 8), ehT0Px3KOsy9(chr(421 - 373) + '\x6f' + '\x33' + chr(0b110001) + chr(0b110001), 54580 - 54572), ehT0Px3KOsy9(chr(0b110000) + chr(0b1001000 + 0o47) + '\x36' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(719 - 671) + chr(0b1101111) + '\061' + chr(0b110101) + '\062', 8), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(2182 - 2071) + chr(51) + chr(0b11001 + 0o27) + chr(54), 0o10), ehT0Px3KOsy9(chr(79 - 31) + chr(111) + '\062' + chr(2542 - 2491) + chr(51), 0o10), ehT0Px3KOsy9(chr(2240 - 2192) + '\x6f' + '\067' + chr(55), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + chr(1988 - 1937) + chr(0b100011 + 0o24) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(127 - 79) + chr(0b1101111) + chr(0b110010) + chr(54) + chr(0b100011 + 0o21), ord("\x08")), ehT0Px3KOsy9(chr(1124 - 1076) + chr(0b1100101 + 0o12) + '\x32', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110101) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'n'), chr(100) + chr(101) + '\x63' + chr(0b1011111 + 0o20) + '\144' + chr(101))('\x75' + '\164' + chr(1792 - 1690) + '\x2d' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def NUp38VK6EGtR(oVre8I6UXc3b, SY0NIgiWrFfS, R2aazmV9Bena) -> nRCEkXkGnMeI[JYjt13TTRebb]:
zoGpAUQNmdlo = rLgqW9imlCdX(MVEN8G6CxlvR)
for UEy2wnap6_4C in SY0NIgiWrFfS:
xafqLlk3kkUe(zoGpAUQNmdlo[R2aazmV9Bena(UEy2wnap6_4C)], xafqLlk3kkUe(SXOLrMavuUCe(b'5\xdb\xc9\xbc+y\xe2V\xdbL\xf5h'), chr(0b1100100) + chr(0b1100101) + '\x63' + '\x6f' + chr(0b1100100) + chr(8752 - 8651))(chr(390 - 273) + '\164' + chr(10399 - 10297) + chr(0b11111 + 0o16) + '\070'))(UEy2wnap6_4C)
if not zoGpAUQNmdlo:
return MVEN8G6CxlvR()
VkuqiiBurVmJ = tsdjvlgh9gDP(zoGpAUQNmdlo, key=lambda OeWW0F1dBPRQ: c2A0yzQpDQB3(zoGpAUQNmdlo[OeWW0F1dBPRQ]))
if c2A0yzQpDQB3(zoGpAUQNmdlo[VkuqiiBurVmJ]) <= ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(49), 0o10):
return MVEN8G6CxlvR()
return zoGpAUQNmdlo[VkuqiiBurVmJ]
|
allenai/allennlp
|
allennlp/nn/util.py
|
has_tensor
|
def has_tensor(obj) -> bool:
"""
Given a possibly complex data structure,
check if it has any torch.Tensors in it.
"""
if isinstance(obj, torch.Tensor):
return True
elif isinstance(obj, dict):
return any(has_tensor(value) for value in obj.values())
elif isinstance(obj, (list, tuple)):
return any(has_tensor(item) for item in obj)
else:
return False
|
python
|
def has_tensor(obj) -> bool:
"""
Given a possibly complex data structure,
check if it has any torch.Tensors in it.
"""
if isinstance(obj, torch.Tensor):
return True
elif isinstance(obj, dict):
return any(has_tensor(value) for value in obj.values())
elif isinstance(obj, (list, tuple)):
return any(has_tensor(item) for item in obj)
else:
return False
|
[
"def",
"has_tensor",
"(",
"obj",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"obj",
",",
"torch",
".",
"Tensor",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"any",
"(",
"has_tensor",
"(",
"value",
")",
"for",
"value",
"in",
"obj",
".",
"values",
"(",
")",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"any",
"(",
"has_tensor",
"(",
"item",
")",
"for",
"item",
"in",
"obj",
")",
"else",
":",
"return",
"False"
] |
Given a possibly complex data structure,
check if it has any torch.Tensors in it.
|
[
"Given",
"a",
"possibly",
"complex",
"data",
"structure",
"check",
"if",
"it",
"has",
"any",
"torch",
".",
"Tensors",
"in",
"it",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L20-L32
|
train
|
Checks if a possibly complex data structure has any torch. Tensors in it.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjf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k3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1617 - 1569) + '\157' + '\x32' + chr(51) + chr(1109 - 1056), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10001 + 0o44) + chr(2583 - 2531), 2048 - 2040), ehT0Px3KOsy9('\060' + chr(0b110011 + 0o74) + '\x32' + '\x34' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + chr(0b110101) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + chr(6721 - 6610) + chr(2312 - 2261) + '\x30' + '\067', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + '\061' + chr(1449 - 1401), 18082 - 18074), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + chr(0b11111 + 0o23) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(53) + chr(114 - 64), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x37' + '\x32', 46164 - 46156), ehT0Px3KOsy9(chr(108 - 60) + chr(0b1101111) + '\x32' + chr(0b101110 + 0o5) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(0b110110) + chr(0b101101 + 0o5), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2092 - 2042) + chr(54) + chr(893 - 843), 0o10), ehT0Px3KOsy9(chr(1027 - 979) + chr(0b1101111) + chr(210 - 158) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(1428 - 1380) + '\x6f' + chr(2143 - 2092) + chr(0b101011 + 0o12) + '\062', 8), ehT0Px3KOsy9(chr(411 - 363) + chr(0b11 + 0o154) + '\062' + chr(0b10110 + 0o36) + chr(2333 - 2278), 8), ehT0Px3KOsy9(chr(487 - 439) + chr(0b1001101 + 0o42) + chr(2007 - 1957) + chr(49) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(111) + chr(0b110010) + '\x30' + '\x32', 56182 - 56174), ehT0Px3KOsy9(chr(48) + chr(0b100011 + 0o114) + chr(0b11000 + 0o33) + chr(50) + chr(1574 - 1523), 0b1000), ehT0Px3KOsy9('\060' + chr(0b101001 + 0o106) + chr(597 - 547) + '\x35' + '\062', 0o10), ehT0Px3KOsy9(chr(716 - 668) + chr(0b101110 + 0o101) + chr(681 - 632) + '\066' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(52) + chr(879 - 825), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(3572 - 3461) + '\x31' + chr(0b1110 + 0o51) + chr(0b10101 + 0o36), 47732 - 47724), ehT0Px3KOsy9(chr(2168 - 2120) + '\x6f' + chr(180 - 129) + chr(0b11111 + 0o22) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(55) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110100) + chr(0b100011 + 0o15), 4711 - 4703), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101111) + '\x33' + chr(51) + chr(54), 48384 - 48376), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + chr(0b1101 + 0o45) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\157' + '\x33' + chr(2060 - 2006) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + chr(0b110001) + chr(51) + chr(1073 - 1024), 49936 - 49928), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\x6f' + chr(1155 - 1104) + chr(705 - 657) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(3259 - 3148) + chr(2296 - 2243) + chr(0b101101 + 0o3), 47615 - 47607), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(693 - 644) + chr(0b10001 + 0o45), 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + '\067', 0b1000), ehT0Px3KOsy9('\060' + chr(0b0 + 0o157) + '\062' + chr(0b1000 + 0o50) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(1414 - 1366) + chr(0b1101111) + chr(0b100011 + 0o17) + chr(0b110111) + '\x36', 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(0b101100 + 0o11) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1011101 + 0o22) + chr(55) + chr(0b100111 + 0o16), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(3329 - 3218) + '\063' + chr(1669 - 1617) + '\x31', 56187 - 56179), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + chr(0b11101 + 0o24) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b111101 + 0o62) + chr(0b110011) + chr(55) + chr(0b110100), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(0b1101111) + '\x35' + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(0b10101 + 0o132) + chr(0b1100100) + chr(0b1000101 + 0o40))('\x75' + chr(0b1011011 + 0o31) + '\146' + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def xqqOdBmAXxu6(mDuDykdz0pcm) -> WbBjf8Y7v9VN:
if PlSM16l2KDPD(mDuDykdz0pcm, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9I\xc9\x9c\xa8:'), '\144' + '\x65' + chr(6655 - 6556) + chr(904 - 793) + '\x64' + '\145')(chr(0b111010 + 0o73) + '\164' + chr(4297 - 4195) + chr(45) + '\x38'))):
return ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\157' + '\x31', ord("\x08"))
elif PlSM16l2KDPD(mDuDykdz0pcm, wLqBDw8l0eIm):
return UVSi4XW7eBIM((xqqOdBmAXxu6(QmmgWUB13VCJ) for QmmgWUB13VCJ in xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xce|\xc9\xac\x89=&\xder\xa8\x16\xd0'), chr(0b100011 + 0o101) + '\145' + '\x63' + chr(1169 - 1058) + chr(100) + chr(101))(chr(0b1000010 + 0o63) + '\164' + '\x66' + chr(0b101101) + chr(0b100100 + 0o24)))()))
elif PlSM16l2KDPD(mDuDykdz0pcm, (YyaZ4tpXu4lf, KNyTy8rYcwji)):
return UVSi4XW7eBIM((xqqOdBmAXxu6(N7j7ePTXzzI0) for N7j7ePTXzzI0 in mDuDykdz0pcm))
else:
return ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(6892 - 6781) + chr(0b110000), ord("\x08"))
|
allenai/allennlp
|
allennlp/nn/util.py
|
move_to_device
|
def move_to_device(obj, cuda_device: int):
"""
Given a structure (possibly) containing Tensors on the CPU,
move all the Tensors to the specified GPU (or do nothing, if they should be on the CPU).
"""
if cuda_device < 0 or not has_tensor(obj):
return obj
elif isinstance(obj, torch.Tensor):
return obj.cuda(cuda_device)
elif isinstance(obj, dict):
return {key: move_to_device(value, cuda_device) for key, value in obj.items()}
elif isinstance(obj, list):
return [move_to_device(item, cuda_device) for item in obj]
elif isinstance(obj, tuple):
return tuple([move_to_device(item, cuda_device) for item in obj])
else:
return obj
|
python
|
def move_to_device(obj, cuda_device: int):
"""
Given a structure (possibly) containing Tensors on the CPU,
move all the Tensors to the specified GPU (or do nothing, if they should be on the CPU).
"""
if cuda_device < 0 or not has_tensor(obj):
return obj
elif isinstance(obj, torch.Tensor):
return obj.cuda(cuda_device)
elif isinstance(obj, dict):
return {key: move_to_device(value, cuda_device) for key, value in obj.items()}
elif isinstance(obj, list):
return [move_to_device(item, cuda_device) for item in obj]
elif isinstance(obj, tuple):
return tuple([move_to_device(item, cuda_device) for item in obj])
else:
return obj
|
[
"def",
"move_to_device",
"(",
"obj",
",",
"cuda_device",
":",
"int",
")",
":",
"if",
"cuda_device",
"<",
"0",
"or",
"not",
"has_tensor",
"(",
"obj",
")",
":",
"return",
"obj",
"elif",
"isinstance",
"(",
"obj",
",",
"torch",
".",
"Tensor",
")",
":",
"return",
"obj",
".",
"cuda",
"(",
"cuda_device",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"{",
"key",
":",
"move_to_device",
"(",
"value",
",",
"cuda_device",
")",
"for",
"key",
",",
"value",
"in",
"obj",
".",
"items",
"(",
")",
"}",
"elif",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"[",
"move_to_device",
"(",
"item",
",",
"cuda_device",
")",
"for",
"item",
"in",
"obj",
"]",
"elif",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
":",
"return",
"tuple",
"(",
"[",
"move_to_device",
"(",
"item",
",",
"cuda_device",
")",
"for",
"item",
"in",
"obj",
"]",
")",
"else",
":",
"return",
"obj"
] |
Given a structure (possibly) containing Tensors on the CPU,
move all the Tensors to the specified GPU (or do nothing, if they should be on the CPU).
|
[
"Given",
"a",
"structure",
"(",
"possibly",
")",
"containing",
"Tensors",
"on",
"the",
"CPU",
"move",
"all",
"the",
"Tensors",
"to",
"the",
"specified",
"GPU",
"(",
"or",
"do",
"nothing",
"if",
"they",
"should",
"be",
"on",
"the",
"CPU",
")",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L35-L51
|
train
|
Given a structure containing Tensors on the CPU move all the Tensors to the specified GPU.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,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97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1485 - 1437) + chr(11031 - 10920) + chr(51) + chr(54) + '\x31', 18199 - 18191), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(111) + chr(0b10000 + 0o42) + chr(48) + '\x36', 45218 - 45210), ehT0Px3KOsy9(chr(48) + chr(0b110 + 0o151) + '\060', 17430 - 17422), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110001) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b111111 + 0o60) + chr(1162 - 1113) + chr(0b10110 + 0o34) + chr(300 - 248), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101101 + 0o2) + chr(55) + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1011001 + 0o26) + '\061' + chr(0b11000 + 0o34) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1100111 + 0o10) + '\062' + chr(51) + chr(0b110011), 39861 - 39853), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b1101 + 0o142) + '\061' + chr(55) + chr(0b10101 + 0o40), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b110001) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + chr(3726 - 3615) + chr(1775 - 1726) + '\063' + chr(0b11001 + 0o32), 0o10), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + chr(248 - 199) + chr(0b10100 + 0o36) + chr(1470 - 1420), 61682 - 61674), ehT0Px3KOsy9(chr(250 - 202) + chr(111) + chr(0b101110 + 0o5) + chr(0b100010 + 0o21) + chr(49), 0o10), ehT0Px3KOsy9(chr(463 - 415) + chr(0b1101111) + chr(0b110010) + chr(0b100111 + 0o12) + chr(54), 11694 - 11686), ehT0Px3KOsy9(chr(1971 - 1923) + chr(2078 - 1967) + chr(49) + chr(48) + chr(0b110000 + 0o5), 48097 - 48089), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(0b110111) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b100111 + 0o17) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(5974 - 5863) + chr(0b110010) + chr(49) + chr(0b11111 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\067' + chr(0b110000), 8), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + '\x37' + chr(0b110101), 8), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b10101 + 0o36) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + '\x32' + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(1891 - 1837), 0b1000), ehT0Px3KOsy9('\060' + chr(0b101100 + 0o103) + '\x33' + chr(106 - 55) + chr(0b1110 + 0o50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010110 + 0o31) + '\x33' + chr(0b110111) + chr(1862 - 1814), 0o10), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1100001 + 0o16) + '\063' + '\060' + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(11510 - 11399) + chr(0b110 + 0o57) + chr(1705 - 1657), 0b1000), ehT0Px3KOsy9(chr(1592 - 1544) + chr(111) + chr(1794 - 1739) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011110 + 0o21) + '\062' + chr(449 - 397), 0o10), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + chr(630 - 579) + chr(0b110111) + chr(705 - 651), 44147 - 44139), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(2491 - 2438) + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(5416 - 5305) + chr(52) + chr(0b100001 + 0o26), 0o10), ehT0Px3KOsy9(chr(1255 - 1207) + chr(0b1101111) + chr(50) + '\060' + chr(1920 - 1872), 0o10), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(111) + chr(49) + chr(53) + chr(1695 - 1643), 0b1000), ehT0Px3KOsy9(chr(1282 - 1234) + '\x6f' + chr(931 - 882), 44573 - 44565), ehT0Px3KOsy9(chr(768 - 720) + chr(8521 - 8410) + chr(0b10001 + 0o42) + chr(0b101000 + 0o13) + '\x31', 8), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + '\x31' + chr(0b110111), 24184 - 24176), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\x36' + '\067', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1794 - 1743), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b100110 + 0o111) + chr(0b1111 + 0o46) + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xdf'), chr(0b1000100 + 0o40) + '\145' + chr(99) + '\157' + chr(100) + '\x65')(chr(117) + '\x74' + chr(796 - 694) + chr(769 - 724) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def k5OM8YBw7qUk(mDuDykdz0pcm, jRcTRdiVAZAp):
if jRcTRdiVAZAp < ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b10000 + 0o137) + chr(0b110000), 8) or not xqqOdBmAXxu6(mDuDykdz0pcm):
return mDuDykdz0pcm
elif PlSM16l2KDPD(mDuDykdz0pcm, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5\xe3nz;J'), chr(100) + chr(0b101 + 0o140) + chr(0b1011100 + 0o7) + '\157' + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(11781 - 11665) + chr(0b111011 + 0o53) + chr(0b101101) + chr(0b11101 + 0o33)))):
return xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'\x92\xf3dh'), chr(100) + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + chr(101))(chr(0b110100 + 0o101) + '\164' + chr(0b1100110) + chr(210 - 165) + chr(0b111000)))(jRcTRdiVAZAp)
elif PlSM16l2KDPD(mDuDykdz0pcm, wLqBDw8l0eIm):
return {K3J4ZwSlE0sT: k5OM8YBw7qUk(QmmgWUB13VCJ, jRcTRdiVAZAp) for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbf\xfcvl\x1dbV\xd2\x11\xdf\x13k'), chr(1573 - 1473) + chr(1363 - 1262) + chr(0b101000 + 0o73) + chr(1849 - 1738) + '\144' + chr(101))(chr(10560 - 10443) + chr(0b1110100) + chr(102) + chr(1115 - 1070) + chr(56)))()}
elif PlSM16l2KDPD(mDuDykdz0pcm, YyaZ4tpXu4lf):
return [k5OM8YBw7qUk(N7j7ePTXzzI0, jRcTRdiVAZAp) for N7j7ePTXzzI0 in mDuDykdz0pcm]
elif PlSM16l2KDPD(mDuDykdz0pcm, KNyTy8rYcwji):
return KNyTy8rYcwji([k5OM8YBw7qUk(N7j7ePTXzzI0, jRcTRdiVAZAp) for N7j7ePTXzzI0 in mDuDykdz0pcm])
else:
return mDuDykdz0pcm
|
allenai/allennlp
|
allennlp/nn/util.py
|
clamp_tensor
|
def clamp_tensor(tensor, minimum, maximum):
"""
Supports sparse and dense tensors.
Returns a tensor with values clamped between the provided minimum and maximum,
without modifying the original tensor.
"""
if tensor.is_sparse:
coalesced_tensor = tensor.coalesce()
# pylint: disable=protected-access
coalesced_tensor._values().clamp_(minimum, maximum)
return coalesced_tensor
else:
return tensor.clamp(minimum, maximum)
|
python
|
def clamp_tensor(tensor, minimum, maximum):
"""
Supports sparse and dense tensors.
Returns a tensor with values clamped between the provided minimum and maximum,
without modifying the original tensor.
"""
if tensor.is_sparse:
coalesced_tensor = tensor.coalesce()
# pylint: disable=protected-access
coalesced_tensor._values().clamp_(minimum, maximum)
return coalesced_tensor
else:
return tensor.clamp(minimum, maximum)
|
[
"def",
"clamp_tensor",
"(",
"tensor",
",",
"minimum",
",",
"maximum",
")",
":",
"if",
"tensor",
".",
"is_sparse",
":",
"coalesced_tensor",
"=",
"tensor",
".",
"coalesce",
"(",
")",
"# pylint: disable=protected-access",
"coalesced_tensor",
".",
"_values",
"(",
")",
".",
"clamp_",
"(",
"minimum",
",",
"maximum",
")",
"return",
"coalesced_tensor",
"else",
":",
"return",
"tensor",
".",
"clamp",
"(",
"minimum",
",",
"maximum",
")"
] |
Supports sparse and dense tensors.
Returns a tensor with values clamped between the provided minimum and maximum,
without modifying the original tensor.
|
[
"Supports",
"sparse",
"and",
"dense",
"tensors",
".",
"Returns",
"a",
"tensor",
"with",
"values",
"clamped",
"between",
"the",
"provided",
"minimum",
"and",
"maximum",
"without",
"modifying",
"the",
"original",
"tensor",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L54-L66
|
train
|
Returns a tensor with values clamped between the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v33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1511 - 1463) + chr(111) + '\x33' + '\x33' + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(2165 - 2111) + '\061', 9278 - 9270), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010 + 0o0) + '\x30' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101001 + 0o10) + chr(0b110011) + chr(53), 6249 - 6241), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + chr(0b110011 + 0o0) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b111011 + 0o64) + chr(2365 - 2315) + '\063' + chr(1060 - 1012), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10011 + 0o36) + '\064' + chr(51), 21300 - 21292), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b110010 + 0o75) + chr(0b110010) + chr(0b110010) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\062' + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(51) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1101111) + '\066' + '\x37', 12277 - 12269), ehT0Px3KOsy9('\060' + chr(0b1 + 0o156) + chr(0b110110) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(400 - 351) + '\x35' + chr(982 - 933), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + '\x31' + '\063', 53322 - 53314), ehT0Px3KOsy9(chr(2257 - 2209) + '\x6f' + chr(0b100100 + 0o17) + chr(0b110111) + chr(0b110101), 10458 - 10450), ehT0Px3KOsy9(chr(48) + chr(1698 - 1587) + chr(515 - 464) + chr(0b110000) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(1585 - 1537) + '\x6f' + chr(2869 - 2815), ord("\x08")), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(111) + chr(51) + chr(0b11011 + 0o31), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2527 - 2476) + chr(2608 - 2554) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1001111 + 0o40) + chr(0b100011 + 0o16) + chr(758 - 706), 0b1000), ehT0Px3KOsy9(chr(513 - 465) + '\157' + chr(2227 - 2178) + '\064' + '\x37', 0b1000), ehT0Px3KOsy9(chr(341 - 293) + chr(0b1101111) + chr(0b110110) + chr(259 - 206), 8), ehT0Px3KOsy9(chr(1636 - 1588) + chr(0b1101111) + chr(0b110011) + chr(0b110010) + chr(0b100100 + 0o15), 17263 - 17255), ehT0Px3KOsy9(chr(0b110000) + chr(1358 - 1247) + chr(1266 - 1216) + '\x36' + chr(50), 18373 - 18365), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(111) + chr(2308 - 2257) + chr(204 - 149) + chr(0b1010 + 0o50), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + chr(49) + '\x35' + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(1457 - 1409) + chr(0b100111 + 0o110) + '\x33' + chr(0b11101 + 0o31) + chr(0b110001), 25517 - 25509), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\x33' + chr(0b110010 + 0o3), 30260 - 30252), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\x6f' + '\x31' + '\067' + '\x36', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x35', 0o10), ehT0Px3KOsy9(chr(1449 - 1401) + '\157' + '\061' + chr(52) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(1533 - 1479) + chr(87 - 37), 2850 - 2842), ehT0Px3KOsy9(chr(193 - 145) + '\157' + chr(0b110010) + chr(55) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\061' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(674 - 563) + chr(0b110110) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b11101 + 0o122) + chr(0b110010) + '\x31' + '\x36', 6551 - 6543), ehT0Px3KOsy9(chr(2119 - 2071) + chr(0b111011 + 0o64) + chr(0b101011 + 0o10) + chr(0b11000 + 0o30) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(6548 - 6437) + chr(51) + chr(50) + chr(2150 - 2099), 0o10), ehT0Px3KOsy9(chr(273 - 225) + chr(6303 - 6192) + chr(2067 - 2016) + chr(0b10111 + 0o40) + chr(0b11001 + 0o27), 0b1000), ehT0Px3KOsy9('\x30' + chr(626 - 515) + chr(646 - 595) + '\x33' + chr(0b110001), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(857 - 809) + chr(111) + chr(1622 - 1569) + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7'), chr(100) + chr(0b1100101) + chr(5683 - 5584) + chr(0b1 + 0o156) + '\144' + '\x65')(chr(0b1001000 + 0o55) + chr(0b101 + 0o157) + chr(0b1100110) + chr(0b101101) + chr(2750 - 2694)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def U4jL4o7izL_w(LK3cpXJU3UM0, YIAZqmKHfin_, _dNSs6gxhn0f):
if xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb0\x02\xdb.\xea\xf9\x11\xe36'), '\144' + chr(101) + chr(3380 - 3281) + chr(0b1010011 + 0o34) + chr(100) + '\145')(chr(0b10 + 0o163) + '\x74' + chr(0b11111 + 0o107) + '\x2d' + '\070')):
gwvHHK6J9SvN = LK3cpXJU3UM0.coalesce()
xafqLlk3kkUe(gwvHHK6J9SvN._values(), xafqLlk3kkUe(SXOLrMavuUCe(b'\xba\x1d\xe50\xea\xc7'), '\144' + chr(101) + chr(0b101011 + 0o70) + chr(1963 - 1852) + chr(9575 - 9475) + chr(0b1000111 + 0o36))('\x75' + '\x74' + '\146' + chr(81 - 36) + chr(56)))(YIAZqmKHfin_, _dNSs6gxhn0f)
return gwvHHK6J9SvN
else:
return xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xba\x1d\xe50\xea'), chr(0b1100100) + chr(0b100010 + 0o103) + chr(6412 - 6313) + chr(0b1101111) + chr(0b1100100) + '\x65')('\165' + '\x74' + chr(0b1100110) + '\055' + '\070'))(YIAZqmKHfin_, _dNSs6gxhn0f)
|
allenai/allennlp
|
allennlp/nn/util.py
|
batch_tensor_dicts
|
def batch_tensor_dicts(tensor_dicts: List[Dict[str, torch.Tensor]],
remove_trailing_dimension: bool = False) -> Dict[str, torch.Tensor]:
"""
Takes a list of tensor dictionaries, where each dictionary is assumed to have matching keys,
and returns a single dictionary with all tensors with the same key batched together.
Parameters
----------
tensor_dicts : ``List[Dict[str, torch.Tensor]]``
The list of tensor dictionaries to batch.
remove_trailing_dimension : ``bool``
If ``True``, we will check for a trailing dimension of size 1 on the tensors that are being
batched, and remove it if we find it.
"""
key_to_tensors: Dict[str, List[torch.Tensor]] = defaultdict(list)
for tensor_dict in tensor_dicts:
for key, tensor in tensor_dict.items():
key_to_tensors[key].append(tensor)
batched_tensors = {}
for key, tensor_list in key_to_tensors.items():
batched_tensor = torch.stack(tensor_list)
if remove_trailing_dimension and all(tensor.size(-1) == 1 for tensor in tensor_list):
batched_tensor = batched_tensor.squeeze(-1)
batched_tensors[key] = batched_tensor
return batched_tensors
|
python
|
def batch_tensor_dicts(tensor_dicts: List[Dict[str, torch.Tensor]],
remove_trailing_dimension: bool = False) -> Dict[str, torch.Tensor]:
"""
Takes a list of tensor dictionaries, where each dictionary is assumed to have matching keys,
and returns a single dictionary with all tensors with the same key batched together.
Parameters
----------
tensor_dicts : ``List[Dict[str, torch.Tensor]]``
The list of tensor dictionaries to batch.
remove_trailing_dimension : ``bool``
If ``True``, we will check for a trailing dimension of size 1 on the tensors that are being
batched, and remove it if we find it.
"""
key_to_tensors: Dict[str, List[torch.Tensor]] = defaultdict(list)
for tensor_dict in tensor_dicts:
for key, tensor in tensor_dict.items():
key_to_tensors[key].append(tensor)
batched_tensors = {}
for key, tensor_list in key_to_tensors.items():
batched_tensor = torch.stack(tensor_list)
if remove_trailing_dimension and all(tensor.size(-1) == 1 for tensor in tensor_list):
batched_tensor = batched_tensor.squeeze(-1)
batched_tensors[key] = batched_tensor
return batched_tensors
|
[
"def",
"batch_tensor_dicts",
"(",
"tensor_dicts",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
"]",
",",
"remove_trailing_dimension",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"key_to_tensors",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"torch",
".",
"Tensor",
"]",
"]",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"tensor_dict",
"in",
"tensor_dicts",
":",
"for",
"key",
",",
"tensor",
"in",
"tensor_dict",
".",
"items",
"(",
")",
":",
"key_to_tensors",
"[",
"key",
"]",
".",
"append",
"(",
"tensor",
")",
"batched_tensors",
"=",
"{",
"}",
"for",
"key",
",",
"tensor_list",
"in",
"key_to_tensors",
".",
"items",
"(",
")",
":",
"batched_tensor",
"=",
"torch",
".",
"stack",
"(",
"tensor_list",
")",
"if",
"remove_trailing_dimension",
"and",
"all",
"(",
"tensor",
".",
"size",
"(",
"-",
"1",
")",
"==",
"1",
"for",
"tensor",
"in",
"tensor_list",
")",
":",
"batched_tensor",
"=",
"batched_tensor",
".",
"squeeze",
"(",
"-",
"1",
")",
"batched_tensors",
"[",
"key",
"]",
"=",
"batched_tensor",
"return",
"batched_tensors"
] |
Takes a list of tensor dictionaries, where each dictionary is assumed to have matching keys,
and returns a single dictionary with all tensors with the same key batched together.
Parameters
----------
tensor_dicts : ``List[Dict[str, torch.Tensor]]``
The list of tensor dictionaries to batch.
remove_trailing_dimension : ``bool``
If ``True``, we will check for a trailing dimension of size 1 on the tensors that are being
batched, and remove it if we find it.
|
[
"Takes",
"a",
"list",
"of",
"tensor",
"dictionaries",
"where",
"each",
"dictionary",
"is",
"assumed",
"to",
"have",
"matching",
"keys",
"and",
"returns",
"a",
"single",
"dictionary",
"with",
"all",
"tensors",
"with",
"the",
"same",
"key",
"batched",
"together",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L69-L93
|
train
|
Takes a list of tensor dictionaries where each dictionary is assumed to have matching keys and returns a single dictionary with all tensors with the same key batched together.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydD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Is,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + '\x35' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(425 - 374) + chr(1663 - 1608), ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + chr(2362 - 2308) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(1188 - 1140) + chr(111) + '\061' + chr(2093 - 2042), 47159 - 47151), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101011 + 0o10) + chr(830 - 780) + chr(399 - 348), 21966 - 21958), ehT0Px3KOsy9('\x30' + '\x6f' + chr(474 - 424), ord("\x08")), ehT0Px3KOsy9(chr(638 - 590) + '\157' + '\x31' + '\065' + chr(50), 31318 - 31310), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + chr(0b110000) + chr(51), 52552 - 52544), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + '\x31' + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(0b100111 + 0o15) + '\064', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x33' + '\061' + chr(50), 25488 - 25480), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\x6f' + chr(0b11010 + 0o27) + chr(794 - 744) + chr(540 - 487), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b10100 + 0o133) + chr(51) + chr(0b110000) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(700 - 652) + chr(10959 - 10848) + '\064' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(10618 - 10507) + chr(208 - 157) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(1060 - 1012) + chr(0b1101111) + '\x31' + chr(0b10111 + 0o40) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(49) + chr(521 - 472), 25965 - 25957), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + chr(0b0 + 0o66) + chr(0b101100 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(619 - 571) + '\x6f' + chr(0b101111 + 0o7) + chr(0b110000), 57636 - 57628), ehT0Px3KOsy9(chr(106 - 58) + chr(0b110100 + 0o73) + chr(1830 - 1776) + chr(51), 46676 - 46668), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1101111) + chr(0b100001 + 0o22) + '\x35' + '\060', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(0b110101 + 0o2) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + '\063' + chr(55) + '\x37', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(0b10100 + 0o37) + chr(52), 7968 - 7960), ehT0Px3KOsy9(chr(0b110000) + chr(7171 - 7060) + chr(0b110001) + '\066' + chr(50), 29133 - 29125), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10100 + 0o36) + chr(0b110100) + '\065', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10110 + 0o34) + '\067', 8507 - 8499), ehT0Px3KOsy9('\x30' + chr(0b11010 + 0o125) + chr(695 - 645) + chr(605 - 551) + chr(0b11111 + 0o26), 0o10), ehT0Px3KOsy9(chr(1625 - 1577) + '\x6f' + '\x32' + '\060' + chr(2177 - 2127), 20552 - 20544), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(49) + chr(198 - 144), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + chr(1244 - 1191) + chr(0b11111 + 0o21), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10001 + 0o42) + '\061' + chr(0b100 + 0o57), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b11111 + 0o22) + chr(51) + '\064', 0o10), ehT0Px3KOsy9(chr(48) + chr(4688 - 4577) + chr(0b110000 + 0o2) + chr(0b110111) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\157' + chr(0b110010) + chr(0b110010 + 0o3) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110100 + 0o1) + chr(49), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(1105 - 1057) + chr(2290 - 2238), 28597 - 28589), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(52) + '\x36', 0b1000), ehT0Px3KOsy9(chr(48) + chr(1981 - 1870) + chr(2401 - 2350) + '\x30' + chr(1172 - 1124), 8), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111) + '\062' + chr(2020 - 1970) + '\x35', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1316 - 1268) + chr(0b11000 + 0o127) + chr(1663 - 1610) + chr(421 - 373), 40697 - 40689)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4'), chr(100) + chr(0b1000110 + 0o37) + chr(99) + '\157' + '\x64' + '\145')(chr(0b1110101) + chr(0b1011111 + 0o25) + chr(102) + '\055' + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def rB6OEzZEpIJV(qVhmPzQJOav4, bE71H8X7wlKg=ehT0Px3KOsy9(chr(187 - 139) + chr(111) + '\x30', 61339 - 61331)) -> zBnV56fc6HrA[M8_cKLkHVB2V, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbe\xbaYx\xbcp'), chr(0b111110 + 0o46) + chr(0b1001100 + 0o31) + chr(2385 - 2286) + chr(111) + chr(0b1110 + 0o126) + '\x65')(chr(8270 - 8153) + '\164' + chr(102) + '\055' + '\x38'))]:
febfMxIoJ940 = rLgqW9imlCdX(YyaZ4tpXu4lf)
for M_ynUZjgsw4O in qVhmPzQJOav4:
for (K3J4ZwSlE0sT, LK3cpXJU3UM0) in xafqLlk3kkUe(M_ynUZjgsw4O, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4\xa5An\x9aXY\x8ab\xb7\x82l'), chr(0b1010000 + 0o24) + chr(101) + chr(99) + chr(0b111001 + 0o66) + '\x64' + '\x65')('\x75' + '\x74' + '\x66' + chr(0b1111 + 0o36) + '\x38'))():
xafqLlk3kkUe(febfMxIoJ940[K3J4ZwSlE0sT], xafqLlk3kkUe(SXOLrMavuUCe(b'\x8b\xafGn\xbdf'), '\x64' + chr(101) + chr(5954 - 5855) + chr(6755 - 6644) + chr(100) + chr(101))('\165' + chr(0b1110100) + '\146' + chr(45) + chr(0b11101 + 0o33)))(LK3cpXJU3UM0)
ouJ7F2O84_Ni = {}
for (K3J4ZwSlE0sT, KsYMHcMMku6X) in xafqLlk3kkUe(febfMxIoJ940, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4\xa5An\x9aXY\x8ab\xb7\x82l'), chr(0b1100100) + chr(0b11010 + 0o113) + chr(0b1011111 + 0o4) + chr(1409 - 1298) + chr(501 - 401) + '\x65')(chr(3705 - 3588) + '\x74' + chr(0b1100110) + chr(45) + '\x38'))():
Ar9KRSv3M9Er = cEkFpYktkSeK.stack(KsYMHcMMku6X)
if bE71H8X7wlKg and Dl48nj1rbi23((xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4\x93Th\xe0@)\x89`\xb5\xa14'), chr(0b10001 + 0o123) + '\145' + chr(0b1100011) + chr(5972 - 5861) + '\144' + chr(101))(chr(117) + chr(0b1110100) + chr(0b1010010 + 0o24) + chr(1607 - 1562) + '\070'))(-ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11110 + 0o23), 0b1000)) == ehT0Px3KOsy9(chr(1789 - 1741) + '\157' + chr(0b11 + 0o56), 8) for LK3cpXJU3UM0 in KsYMHcMMku6X)):
Ar9KRSv3M9Er = Ar9KRSv3M9Er.squeeze(-ehT0Px3KOsy9(chr(48) + chr(0b1000 + 0o147) + chr(49), 8))
ouJ7F2O84_Ni[K3J4ZwSlE0sT] = Ar9KRSv3M9Er
return ouJ7F2O84_Ni
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_mask_from_sequence_lengths
|
def get_mask_from_sequence_lengths(sequence_lengths: torch.Tensor, max_length: int) -> torch.Tensor:
"""
Given a variable of shape ``(batch_size,)`` that represents the sequence lengths of each batch
element, this function returns a ``(batch_size, max_length)`` mask variable. For example, if
our input was ``[2, 2, 3]``, with a ``max_length`` of 4, we'd return
``[[1, 1, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]``.
We require ``max_length`` here instead of just computing it from the input ``sequence_lengths``
because it lets us avoid finding the max, then copying that value from the GPU to the CPU so
that we can use it to construct a new tensor.
"""
# (batch_size, max_length)
ones = sequence_lengths.new_ones(sequence_lengths.size(0), max_length)
range_tensor = ones.cumsum(dim=1)
return (sequence_lengths.unsqueeze(1) >= range_tensor).long()
|
python
|
def get_mask_from_sequence_lengths(sequence_lengths: torch.Tensor, max_length: int) -> torch.Tensor:
"""
Given a variable of shape ``(batch_size,)`` that represents the sequence lengths of each batch
element, this function returns a ``(batch_size, max_length)`` mask variable. For example, if
our input was ``[2, 2, 3]``, with a ``max_length`` of 4, we'd return
``[[1, 1, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]``.
We require ``max_length`` here instead of just computing it from the input ``sequence_lengths``
because it lets us avoid finding the max, then copying that value from the GPU to the CPU so
that we can use it to construct a new tensor.
"""
# (batch_size, max_length)
ones = sequence_lengths.new_ones(sequence_lengths.size(0), max_length)
range_tensor = ones.cumsum(dim=1)
return (sequence_lengths.unsqueeze(1) >= range_tensor).long()
|
[
"def",
"get_mask_from_sequence_lengths",
"(",
"sequence_lengths",
":",
"torch",
".",
"Tensor",
",",
"max_length",
":",
"int",
")",
"->",
"torch",
".",
"Tensor",
":",
"# (batch_size, max_length)",
"ones",
"=",
"sequence_lengths",
".",
"new_ones",
"(",
"sequence_lengths",
".",
"size",
"(",
"0",
")",
",",
"max_length",
")",
"range_tensor",
"=",
"ones",
".",
"cumsum",
"(",
"dim",
"=",
"1",
")",
"return",
"(",
"sequence_lengths",
".",
"unsqueeze",
"(",
"1",
")",
">=",
"range_tensor",
")",
".",
"long",
"(",
")"
] |
Given a variable of shape ``(batch_size,)`` that represents the sequence lengths of each batch
element, this function returns a ``(batch_size, max_length)`` mask variable. For example, if
our input was ``[2, 2, 3]``, with a ``max_length`` of 4, we'd return
``[[1, 1, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]``.
We require ``max_length`` here instead of just computing it from the input ``sequence_lengths``
because it lets us avoid finding the max, then copying that value from the GPU to the CPU so
that we can use it to construct a new tensor.
|
[
"Given",
"a",
"variable",
"of",
"shape",
"(",
"batch_size",
")",
"that",
"represents",
"the",
"sequence",
"lengths",
"of",
"each",
"batch",
"element",
"this",
"function",
"returns",
"a",
"(",
"batch_size",
"max_length",
")",
"mask",
"variable",
".",
"For",
"example",
"if",
"our",
"input",
"was",
"[",
"2",
"2",
"3",
"]",
"with",
"a",
"max_length",
"of",
"4",
"we",
"d",
"return",
"[[",
"1",
"1",
"0",
"0",
"]",
"[",
"1",
"1",
"0",
"0",
"]",
"[",
"1",
"1",
"1",
"0",
"]]",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L115-L129
|
train
|
Returns a mask variable that is a tensor that is greater than or equal to the given max_length.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TL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49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\157' + '\061' + chr(1442 - 1391) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(8453 - 8342) + '\062' + chr(0b110001) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(8348 - 8237) + chr(0b110001) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(1000 - 952) + chr(3368 - 3257) + '\x31' + '\x30' + chr(0b110100), 22905 - 22897), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + chr(49) + chr(2352 - 2300) + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1488 - 1438) + '\067' + chr(0b110010), 20551 - 20543), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + '\064' + chr(0b11110 + 0o22), ord("\x08")), ehT0Px3KOsy9(chr(205 - 157) + chr(0b1000010 + 0o55) + chr(0b110010) + chr(0b1011 + 0o52) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(545 - 497) + chr(111) + '\x34' + chr(0b0 + 0o64), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1010001 + 0o36) + chr(50) + chr(2372 - 2318) + chr(965 - 912), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1085 - 1035) + '\063' + chr(2098 - 2050), 0b1000), ehT0Px3KOsy9('\060' + chr(8466 - 8355) + chr(49) + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111 + 0o0) + '\x33' + chr(0b110101) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(1025 - 977) + chr(111) + chr(50) + chr(49) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(0b1011 + 0o52) + chr(975 - 924), 38195 - 38187), ehT0Px3KOsy9(chr(2296 - 2248) + chr(111) + chr(1145 - 1094) + '\x32' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(111) + chr(51) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101010 + 0o5) + '\x32' + chr(0b110111) + chr(51), 55994 - 55986), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(7287 - 7176) + chr(0b101010 + 0o10) + chr(0b110100) + chr(0b101010 + 0o10), 38004 - 37996), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(0b110111) + '\066', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(0b1 + 0o60), 0b1000), ehT0Px3KOsy9('\x30' + chr(8508 - 8397) + '\062' + chr(0b10011 + 0o36) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b11101 + 0o25) + chr(0b110100) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(1358 - 1310) + chr(0b1101111) + chr(2187 - 2136) + chr(1794 - 1742) + chr(0b100 + 0o61), 24798 - 24790), ehT0Px3KOsy9('\060' + chr(11584 - 11473) + '\061' + '\065' + chr(777 - 723), ord("\x08")), ehT0Px3KOsy9(chr(250 - 202) + chr(111) + chr(1275 - 1225) + chr(239 - 187) + chr(1381 - 1333), 8), ehT0Px3KOsy9(chr(429 - 381) + chr(1294 - 1183) + '\063' + '\064' + chr(0b110110), 47545 - 47537), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + '\064', 63730 - 63722), ehT0Px3KOsy9(chr(725 - 677) + chr(0b1101111) + chr(0b110110) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10547 - 10436) + chr(0b110011) + '\x30' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(81 - 33) + chr(0b1101111) + chr(0b110011) + '\062', 8), ehT0Px3KOsy9(chr(0b10011 + 0o35) + '\157' + chr(0b1100 + 0o45) + '\060' + '\x34', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(199 - 147) + chr(52), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + '\x33' + '\063', 47770 - 47762), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1921 - 1872) + chr(0b11010 + 0o34), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(50) + chr(49), 38639 - 38631), ehT0Px3KOsy9('\060' + chr(0b1001010 + 0o45) + chr(49) + chr(0b101001 + 0o15) + chr(54), 22824 - 22816), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(984 - 929) + chr(0b10000 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(51) + chr(0b100100 + 0o15) + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b1010 + 0o52) + '\x35', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x35' + chr(226 - 178), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'p'), '\144' + chr(0b1001 + 0o134) + chr(0b1011110 + 0o5) + chr(5387 - 5276) + '\144' + chr(0b1011111 + 0o6))('\165' + '\164' + chr(6956 - 6854) + chr(1170 - 1125) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def M1_qs5X907IQ(JqDKXxFsMQp2, _o7pVXAdOCRy) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\n\xeeg7\x0f\xc8'), '\x64' + chr(101) + chr(5292 - 5193) + '\x6f' + chr(0b1111 + 0o125) + '\145')('\x75' + chr(0b1110100) + '\x66' + chr(45) + chr(1260 - 1204))):
Q9MMic9MQj7n = JqDKXxFsMQp2.new_ones(JqDKXxFsMQp2.NLcc3BCJnQka(ehT0Px3KOsy9(chr(48) + chr(0b0 + 0o157) + chr(48), ord("\x08"))), _o7pVXAdOCRy)
isy2f3z5pEAx = Q9MMic9MQj7n.i0lzZW3r00ue(dim=ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11110 + 0o23), 52547 - 52539))
return xafqLlk3kkUe(JqDKXxFsMQp2.unsqueeze(ehT0Px3KOsy9('\060' + chr(0b1001101 + 0o42) + chr(0b11110 + 0o23), 8)) >= isy2f3z5pEAx, xafqLlk3kkUe(SXOLrMavuUCe(b'2\xe4g#'), chr(100) + chr(0b1001000 + 0o35) + '\x63' + chr(111) + '\144' + '\x65')(chr(0b1110101) + '\164' + chr(102) + '\x2d' + chr(56)))()
|
allenai/allennlp
|
allennlp/nn/util.py
|
sort_batch_by_length
|
def sort_batch_by_length(tensor: torch.Tensor, sequence_lengths: torch.Tensor):
"""
Sort a batch first tensor by some specified lengths.
Parameters
----------
tensor : torch.FloatTensor, required.
A batch first Pytorch tensor.
sequence_lengths : torch.LongTensor, required.
A tensor representing the lengths of some dimension of the tensor which
we want to sort by.
Returns
-------
sorted_tensor : torch.FloatTensor
The original tensor sorted along the batch dimension with respect to sequence_lengths.
sorted_sequence_lengths : torch.LongTensor
The original sequence_lengths sorted by decreasing size.
restoration_indices : torch.LongTensor
Indices into the sorted_tensor such that
``sorted_tensor.index_select(0, restoration_indices) == original_tensor``
permutation_index : torch.LongTensor
The indices used to sort the tensor. This is useful if you want to sort many
tensors using the same ordering.
"""
if not isinstance(tensor, torch.Tensor) or not isinstance(sequence_lengths, torch.Tensor):
raise ConfigurationError("Both the tensor and sequence lengths must be torch.Tensors.")
sorted_sequence_lengths, permutation_index = sequence_lengths.sort(0, descending=True)
sorted_tensor = tensor.index_select(0, permutation_index)
index_range = torch.arange(0, len(sequence_lengths), device=sequence_lengths.device)
# This is the equivalent of zipping with index, sorting by the original
# sequence lengths and returning the now sorted indices.
_, reverse_mapping = permutation_index.sort(0, descending=False)
restoration_indices = index_range.index_select(0, reverse_mapping)
return sorted_tensor, sorted_sequence_lengths, restoration_indices, permutation_index
|
python
|
def sort_batch_by_length(tensor: torch.Tensor, sequence_lengths: torch.Tensor):
"""
Sort a batch first tensor by some specified lengths.
Parameters
----------
tensor : torch.FloatTensor, required.
A batch first Pytorch tensor.
sequence_lengths : torch.LongTensor, required.
A tensor representing the lengths of some dimension of the tensor which
we want to sort by.
Returns
-------
sorted_tensor : torch.FloatTensor
The original tensor sorted along the batch dimension with respect to sequence_lengths.
sorted_sequence_lengths : torch.LongTensor
The original sequence_lengths sorted by decreasing size.
restoration_indices : torch.LongTensor
Indices into the sorted_tensor such that
``sorted_tensor.index_select(0, restoration_indices) == original_tensor``
permutation_index : torch.LongTensor
The indices used to sort the tensor. This is useful if you want to sort many
tensors using the same ordering.
"""
if not isinstance(tensor, torch.Tensor) or not isinstance(sequence_lengths, torch.Tensor):
raise ConfigurationError("Both the tensor and sequence lengths must be torch.Tensors.")
sorted_sequence_lengths, permutation_index = sequence_lengths.sort(0, descending=True)
sorted_tensor = tensor.index_select(0, permutation_index)
index_range = torch.arange(0, len(sequence_lengths), device=sequence_lengths.device)
# This is the equivalent of zipping with index, sorting by the original
# sequence lengths and returning the now sorted indices.
_, reverse_mapping = permutation_index.sort(0, descending=False)
restoration_indices = index_range.index_select(0, reverse_mapping)
return sorted_tensor, sorted_sequence_lengths, restoration_indices, permutation_index
|
[
"def",
"sort_batch_by_length",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"sequence_lengths",
":",
"torch",
".",
"Tensor",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensor",
",",
"torch",
".",
"Tensor",
")",
"or",
"not",
"isinstance",
"(",
"sequence_lengths",
",",
"torch",
".",
"Tensor",
")",
":",
"raise",
"ConfigurationError",
"(",
"\"Both the tensor and sequence lengths must be torch.Tensors.\"",
")",
"sorted_sequence_lengths",
",",
"permutation_index",
"=",
"sequence_lengths",
".",
"sort",
"(",
"0",
",",
"descending",
"=",
"True",
")",
"sorted_tensor",
"=",
"tensor",
".",
"index_select",
"(",
"0",
",",
"permutation_index",
")",
"index_range",
"=",
"torch",
".",
"arange",
"(",
"0",
",",
"len",
"(",
"sequence_lengths",
")",
",",
"device",
"=",
"sequence_lengths",
".",
"device",
")",
"# This is the equivalent of zipping with index, sorting by the original",
"# sequence lengths and returning the now sorted indices.",
"_",
",",
"reverse_mapping",
"=",
"permutation_index",
".",
"sort",
"(",
"0",
",",
"descending",
"=",
"False",
")",
"restoration_indices",
"=",
"index_range",
".",
"index_select",
"(",
"0",
",",
"reverse_mapping",
")",
"return",
"sorted_tensor",
",",
"sorted_sequence_lengths",
",",
"restoration_indices",
",",
"permutation_index"
] |
Sort a batch first tensor by some specified lengths.
Parameters
----------
tensor : torch.FloatTensor, required.
A batch first Pytorch tensor.
sequence_lengths : torch.LongTensor, required.
A tensor representing the lengths of some dimension of the tensor which
we want to sort by.
Returns
-------
sorted_tensor : torch.FloatTensor
The original tensor sorted along the batch dimension with respect to sequence_lengths.
sorted_sequence_lengths : torch.LongTensor
The original sequence_lengths sorted by decreasing size.
restoration_indices : torch.LongTensor
Indices into the sorted_tensor such that
``sorted_tensor.index_select(0, restoration_indices) == original_tensor``
permutation_index : torch.LongTensor
The indices used to sort the tensor. This is useful if you want to sort many
tensors using the same ordering.
|
[
"Sort",
"a",
"batch",
"first",
"tensor",
"by",
"some",
"specified",
"lengths",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L132-L169
|
train
|
Sorts a batch first tensor by some specified length.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVM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qGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2831 - 2777) + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b0 + 0o66) + '\x37', 1135 - 1127), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + chr(3004 - 2949) + chr(490 - 437), 0o10), ehT0Px3KOsy9(chr(48) + chr(4741 - 4630) + chr(0b11111 + 0o30) + chr(55), 14502 - 14494), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10110 + 0o34) + '\x35' + '\064', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(52) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(2073 - 1962) + '\x31' + '\x34' + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(920 - 865) + chr(0b110011 + 0o0), 27948 - 27940), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111) + chr(778 - 728) + chr(49) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(436 - 325) + chr(0b110011) + '\067' + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(605 - 556) + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(882 - 829) + '\066', 11669 - 11661), ehT0Px3KOsy9(chr(1635 - 1587) + '\157' + chr(0b110011) + chr(0b110100) + '\066', 0o10), ehT0Px3KOsy9(chr(66 - 18) + chr(8884 - 8773) + chr(0b11011 + 0o26) + chr(0b110001) + chr(0b11101 + 0o25), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11101 + 0o30) + chr(0b100100 + 0o20), 42079 - 42071), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + chr(0b110 + 0o53) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11000 + 0o37) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\061' + '\063' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + '\063' + chr(1039 - 988), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + '\061' + '\x34' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1000 + 0o147) + chr(0b100011 + 0o20) + chr(52) + chr(52), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b11000 + 0o127) + chr(1544 - 1493) + '\x30' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10 + 0o60) + chr(48) + chr(1042 - 992), 32946 - 32938), ehT0Px3KOsy9(chr(1231 - 1183) + '\x6f' + chr(51) + '\060' + chr(49), 16155 - 16147), ehT0Px3KOsy9(chr(0b110000) + chr(0b101001 + 0o106) + chr(2208 - 2157) + chr(0b101 + 0o55) + chr(49), 0b1000), ehT0Px3KOsy9(chr(1054 - 1006) + chr(0b101101 + 0o102) + '\061' + '\x30' + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(10154 - 10043) + chr(707 - 656) + chr(0b110010 + 0o0) + '\066', 46073 - 46065), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(5029 - 4918) + '\062' + chr(48) + chr(255 - 202), 0o10), ehT0Px3KOsy9(chr(48) + chr(11915 - 11804) + '\063' + chr(369 - 314) + chr(0b10000 + 0o45), 0o10), ehT0Px3KOsy9(chr(1199 - 1151) + '\157' + '\x32' + chr(0b101111 + 0o3) + chr(55), 50720 - 50712), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(130 - 80) + '\065' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(0b11111 + 0o30) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(1810 - 1762) + chr(1033 - 922) + chr(54) + chr(753 - 699), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110 + 0o61), 0b1000), ehT0Px3KOsy9('\060' + chr(0b110010 + 0o75) + chr(0b1101 + 0o45) + '\063' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101101 + 0o4) + chr(383 - 335) + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(0b110000 + 0o5) + chr(1451 - 1399), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\x33' + '\x30', 0b1000), ehT0Px3KOsy9(chr(1007 - 959) + chr(0b1101000 + 0o7) + '\063' + chr(0b110010) + chr(0b10001 + 0o40), 8), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + '\x34' + chr(0b111 + 0o60), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x35' + '\x30', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c'), chr(9027 - 8927) + '\x65' + chr(99) + '\157' + chr(0b1100000 + 0o4) + chr(0b1100101))(chr(11624 - 11507) + chr(0b1110100) + '\146' + chr(1863 - 1818) + chr(0b100 + 0o64)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def CVESDMnEUQjq(LK3cpXJU3UM0, JqDKXxFsMQp2):
if not PlSM16l2KDPD(LK3cpXJU3UM0, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'fR\xd3L\xc3\xd4'), chr(0b111111 + 0o45) + chr(0b1100101) + chr(99) + '\x6f' + '\x64' + '\x65')(chr(0b1011110 + 0o27) + chr(0b1000001 + 0o63) + chr(0b1010111 + 0o17) + '\x2d' + chr(0b1010 + 0o56)))) or not PlSM16l2KDPD(JqDKXxFsMQp2, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'fR\xd3L\xc3\xd4'), chr(100) + chr(0b1100101) + chr(7919 - 7820) + '\x6f' + chr(0b1100100) + '\145')(chr(0b10110 + 0o137) + '\x74' + chr(102) + chr(45) + chr(0b111000)))):
raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'pX\xc9W\x8c\xd2\x0b\x1e\xa8\x8bj@\x95%^nY4\xffA\x97\xa5\xf3\xb4\xb4,\xb5\xe0\xdd\xfb\xc8\x10Qs\xf25\xcc5\xa4\x94F\x17\xdfZ\x8c\xd2\x0c\t\xeb\x97!z\x83$_!J)\xb5'), '\x64' + chr(6666 - 6565) + '\x63' + chr(111) + '\x64' + chr(101))('\165' + chr(0b1110100) + chr(102) + '\x2d' + '\x38'))
(QgYslqls5EKe, Hs1AoYeExFn9) = JqDKXxFsMQp2.sort(ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1101111) + chr(48), 0o10), descending=ehT0Px3KOsy9(chr(0b110000) + chr(0b1011010 + 0o25) + chr(0b110001), 0o10))
zCtn03gzliTF = LK3cpXJU3UM0.index_select(ehT0Px3KOsy9('\x30' + '\x6f' + '\x30', 8), Hs1AoYeExFn9)
JKu6Yhhxzczt = cEkFpYktkSeK.arange(ehT0Px3KOsy9('\060' + '\157' + chr(0b101001 + 0o7), 8), c2A0yzQpDQB3(JqDKXxFsMQp2), device=JqDKXxFsMQp2.device)
(VNGQdHSFPrso, jDisnJbPuATN) = Hs1AoYeExFn9.sort(ehT0Px3KOsy9('\x30' + chr(111) + '\x30', 8), descending=ehT0Px3KOsy9('\x30' + chr(111) + '\060', 8))
mx8VwdL09amQ = JKu6Yhhxzczt.index_select(ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(0b110000), 8), jDisnJbPuATN)
return (zCtn03gzliTF, QgYslqls5EKe, mx8VwdL09amQ, Hs1AoYeExFn9)
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_final_encoder_states
|
def get_final_encoder_states(encoder_outputs: torch.Tensor,
mask: torch.Tensor,
bidirectional: bool = False) -> torch.Tensor:
"""
Given the output from a ``Seq2SeqEncoder``, with shape ``(batch_size, sequence_length,
encoding_dim)``, this method returns the final hidden state for each element of the batch,
giving a tensor of shape ``(batch_size, encoding_dim)``. This is not as simple as
``encoder_outputs[:, -1]``, because the sequences could have different lengths. We use the
mask (which has shape ``(batch_size, sequence_length)``) to find the final state for each batch
instance.
Additionally, if ``bidirectional`` is ``True``, we will split the final dimension of the
``encoder_outputs`` into two and assume that the first half is for the forward direction of the
encoder and the second half is for the backward direction. We will concatenate the last state
for each encoder dimension, giving ``encoder_outputs[:, -1, :encoding_dim/2]`` concatenated with
``encoder_outputs[:, 0, encoding_dim/2:]``.
"""
# These are the indices of the last words in the sequences (i.e. length sans padding - 1). We
# are assuming sequences are right padded.
# Shape: (batch_size,)
last_word_indices = mask.sum(1).long() - 1
batch_size, _, encoder_output_dim = encoder_outputs.size()
expanded_indices = last_word_indices.view(-1, 1, 1).expand(batch_size, 1, encoder_output_dim)
# Shape: (batch_size, 1, encoder_output_dim)
final_encoder_output = encoder_outputs.gather(1, expanded_indices)
final_encoder_output = final_encoder_output.squeeze(1) # (batch_size, encoder_output_dim)
if bidirectional:
final_forward_output = final_encoder_output[:, :(encoder_output_dim // 2)]
final_backward_output = encoder_outputs[:, 0, (encoder_output_dim // 2):]
final_encoder_output = torch.cat([final_forward_output, final_backward_output], dim=-1)
return final_encoder_output
|
python
|
def get_final_encoder_states(encoder_outputs: torch.Tensor,
mask: torch.Tensor,
bidirectional: bool = False) -> torch.Tensor:
"""
Given the output from a ``Seq2SeqEncoder``, with shape ``(batch_size, sequence_length,
encoding_dim)``, this method returns the final hidden state for each element of the batch,
giving a tensor of shape ``(batch_size, encoding_dim)``. This is not as simple as
``encoder_outputs[:, -1]``, because the sequences could have different lengths. We use the
mask (which has shape ``(batch_size, sequence_length)``) to find the final state for each batch
instance.
Additionally, if ``bidirectional`` is ``True``, we will split the final dimension of the
``encoder_outputs`` into two and assume that the first half is for the forward direction of the
encoder and the second half is for the backward direction. We will concatenate the last state
for each encoder dimension, giving ``encoder_outputs[:, -1, :encoding_dim/2]`` concatenated with
``encoder_outputs[:, 0, encoding_dim/2:]``.
"""
# These are the indices of the last words in the sequences (i.e. length sans padding - 1). We
# are assuming sequences are right padded.
# Shape: (batch_size,)
last_word_indices = mask.sum(1).long() - 1
batch_size, _, encoder_output_dim = encoder_outputs.size()
expanded_indices = last_word_indices.view(-1, 1, 1).expand(batch_size, 1, encoder_output_dim)
# Shape: (batch_size, 1, encoder_output_dim)
final_encoder_output = encoder_outputs.gather(1, expanded_indices)
final_encoder_output = final_encoder_output.squeeze(1) # (batch_size, encoder_output_dim)
if bidirectional:
final_forward_output = final_encoder_output[:, :(encoder_output_dim // 2)]
final_backward_output = encoder_outputs[:, 0, (encoder_output_dim // 2):]
final_encoder_output = torch.cat([final_forward_output, final_backward_output], dim=-1)
return final_encoder_output
|
[
"def",
"get_final_encoder_states",
"(",
"encoder_outputs",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"bidirectional",
":",
"bool",
"=",
"False",
")",
"->",
"torch",
".",
"Tensor",
":",
"# These are the indices of the last words in the sequences (i.e. length sans padding - 1). We",
"# are assuming sequences are right padded.",
"# Shape: (batch_size,)",
"last_word_indices",
"=",
"mask",
".",
"sum",
"(",
"1",
")",
".",
"long",
"(",
")",
"-",
"1",
"batch_size",
",",
"_",
",",
"encoder_output_dim",
"=",
"encoder_outputs",
".",
"size",
"(",
")",
"expanded_indices",
"=",
"last_word_indices",
".",
"view",
"(",
"-",
"1",
",",
"1",
",",
"1",
")",
".",
"expand",
"(",
"batch_size",
",",
"1",
",",
"encoder_output_dim",
")",
"# Shape: (batch_size, 1, encoder_output_dim)",
"final_encoder_output",
"=",
"encoder_outputs",
".",
"gather",
"(",
"1",
",",
"expanded_indices",
")",
"final_encoder_output",
"=",
"final_encoder_output",
".",
"squeeze",
"(",
"1",
")",
"# (batch_size, encoder_output_dim)",
"if",
"bidirectional",
":",
"final_forward_output",
"=",
"final_encoder_output",
"[",
":",
",",
":",
"(",
"encoder_output_dim",
"//",
"2",
")",
"]",
"final_backward_output",
"=",
"encoder_outputs",
"[",
":",
",",
"0",
",",
"(",
"encoder_output_dim",
"//",
"2",
")",
":",
"]",
"final_encoder_output",
"=",
"torch",
".",
"cat",
"(",
"[",
"final_forward_output",
",",
"final_backward_output",
"]",
",",
"dim",
"=",
"-",
"1",
")",
"return",
"final_encoder_output"
] |
Given the output from a ``Seq2SeqEncoder``, with shape ``(batch_size, sequence_length,
encoding_dim)``, this method returns the final hidden state for each element of the batch,
giving a tensor of shape ``(batch_size, encoding_dim)``. This is not as simple as
``encoder_outputs[:, -1]``, because the sequences could have different lengths. We use the
mask (which has shape ``(batch_size, sequence_length)``) to find the final state for each batch
instance.
Additionally, if ``bidirectional`` is ``True``, we will split the final dimension of the
``encoder_outputs`` into two and assume that the first half is for the forward direction of the
encoder and the second half is for the backward direction. We will concatenate the last state
for each encoder dimension, giving ``encoder_outputs[:, -1, :encoding_dim/2]`` concatenated with
``encoder_outputs[:, 0, encoding_dim/2:]``.
|
[
"Given",
"the",
"output",
"from",
"a",
"Seq2SeqEncoder",
"with",
"shape",
"(",
"batch_size",
"sequence_length",
"encoding_dim",
")",
"this",
"method",
"returns",
"the",
"final",
"hidden",
"state",
"for",
"each",
"element",
"of",
"the",
"batch",
"giving",
"a",
"tensor",
"of",
"shape",
"(",
"batch_size",
"encoding_dim",
")",
".",
"This",
"is",
"not",
"as",
"simple",
"as",
"encoder_outputs",
"[",
":",
"-",
"1",
"]",
"because",
"the",
"sequences",
"could",
"have",
"different",
"lengths",
".",
"We",
"use",
"the",
"mask",
"(",
"which",
"has",
"shape",
"(",
"batch_size",
"sequence_length",
")",
")",
"to",
"find",
"the",
"final",
"state",
"for",
"each",
"batch",
"instance",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L172-L202
|
train
|
Given the output from a Seq2SeqEncoder this method returns the final hidden state for each encoder instance.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFG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,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(48) + chr(1664 - 1610), 0o10), ehT0Px3KOsy9('\x30' + chr(2372 - 2261) + '\063' + chr(51) + chr(0b1010 + 0o46), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1569 - 1517), 17794 - 17786), ehT0Px3KOsy9(chr(48) + chr(3216 - 3105) + chr(0b11110 + 0o23) + chr(0b10011 + 0o42) + chr(2111 - 2058), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(0b110110) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11100 + 0o123) + chr(0b101001 + 0o15) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(0b110011) + chr(1446 - 1394), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(52) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1010 + 0o50) + chr(53) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(50) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + '\060' + chr(52), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(54) + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b10100 + 0o133) + chr(1235 - 1186) + '\x35' + chr(414 - 360), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11011 + 0o30) + '\061' + chr(1171 - 1117), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010111 + 0o30) + chr(0b101 + 0o54) + chr(54) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + '\060' + chr(238 - 189), 0b1000), ehT0Px3KOsy9(chr(419 - 371) + '\157' + chr(0b1101 + 0o45) + chr(0b110000) + '\062', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b101110 + 0o3) + chr(0b101 + 0o55), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(818 - 769) + '\x37' + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + '\064' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(2289 - 2241) + chr(0b1101111) + '\062' + chr(0b0 + 0o63) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1000 + 0o147) + chr(2278 - 2223) + chr(54), 10561 - 10553), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(0b110101) + '\060', 49054 - 49046), ehT0Px3KOsy9('\060' + chr(0b0 + 0o157) + chr(0b1 + 0o64) + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b1111 + 0o42) + '\064' + chr(51), 0o10), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1101111) + '\x33' + '\063' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(51) + chr(886 - 831), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10101 + 0o34) + chr(131 - 81) + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + chr(0b100 + 0o56) + chr(0b110011), 19799 - 19791), ehT0Px3KOsy9(chr(138 - 90) + '\157' + chr(0b100010 + 0o20) + chr(51) + chr(55), 0b1000), ehT0Px3KOsy9(chr(2034 - 1986) + chr(0b1101111) + '\066' + '\061', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b110111) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(1074 - 963) + chr(0b110010 + 0o1) + chr(0b110100 + 0o1) + '\x35', 47468 - 47460), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101101 + 0o5) + chr(0b110100) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(2419 - 2308) + '\x33' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10100 + 0o133) + chr(52) + chr(49), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(55) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\x6f' + chr(0b110011) + '\064' + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101010 + 0o11) + chr(53) + chr(55), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2083 - 2030) + chr(1855 - 1807), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8'), chr(0b1100100) + chr(0b1100100 + 0o1) + chr(99) + '\157' + chr(0b1010000 + 0o24) + chr(6604 - 6503))('\165' + chr(12910 - 12794) + '\x66' + '\055' + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def RxctI36CIjUL(pw5kRZGbP7zI, Iz1jSgUKZDvt, EjNAKzMkyYQY=ehT0Px3KOsy9(chr(419 - 371) + chr(11130 - 11019) + chr(0b110000), ord("\x08"))) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x92\xbdj\x1e\x1eA'), '\x64' + chr(0b10101 + 0o120) + '\x63' + chr(111) + chr(1862 - 1762) + '\x65')(chr(2650 - 2533) + chr(116) + chr(102) + chr(1725 - 1680) + chr(0b110010 + 0o6))):
s9Yc98vu63sL = Iz1jSgUKZDvt.sum(ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + '\061', 0o10)).long() - ehT0Px3KOsy9('\060' + chr(0b1101110 + 0o1) + chr(49), 8)
(ix9dZyeAmUxY, VNGQdHSFPrso, pMkGpPemCEuW) = pw5kRZGbP7zI.NLcc3BCJnQka()
Gt1gMBGs0TX9 = s9Yc98vu63sL.view(-ehT0Px3KOsy9('\x30' + '\157' + chr(0b11001 + 0o30), 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001), 8), ehT0Px3KOsy9(chr(965 - 917) + chr(9153 - 9042) + chr(2237 - 2188), 8)).expand(ix9dZyeAmUxY, ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b10110 + 0o131) + chr(0b110001), 8), pMkGpPemCEuW)
O03uGr7CoTBH = pw5kRZGbP7zI.kGr_8mTaGpVE(ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001), 8), Gt1gMBGs0TX9)
O03uGr7CoTBH = O03uGr7CoTBH.squeeze(ehT0Px3KOsy9('\060' + chr(5163 - 5052) + chr(780 - 731), 8))
if EjNAKzMkyYQY:
PI_88WsKqwiJ = O03uGr7CoTBH[:, :pMkGpPemCEuW // ehT0Px3KOsy9('\x30' + chr(0b1101101 + 0o2) + chr(0b110010), 0b1000)]
mi90S8fX1H8K = pw5kRZGbP7zI[:, ehT0Px3KOsy9('\x30' + chr(111 - 0) + '\060', 8), pMkGpPemCEuW // ehT0Px3KOsy9(chr(0b110000) + chr(9309 - 9198) + chr(0b110010), 8):]
O03uGr7CoTBH = cEkFpYktkSeK.cat([PI_88WsKqwiJ, mi90S8fX1H8K], dim=-ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + '\x31', 8))
return O03uGr7CoTBH
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_dropout_mask
|
def get_dropout_mask(dropout_probability: float, tensor_for_masking: torch.Tensor):
"""
Computes and returns an element-wise dropout mask for a given tensor, where
each element in the mask is dropped out with probability dropout_probability.
Note that the mask is NOT applied to the tensor - the tensor is passed to retain
the correct CUDA tensor type for the mask.
Parameters
----------
dropout_probability : float, required.
Probability of dropping a dimension of the input.
tensor_for_masking : torch.Tensor, required.
Returns
-------
A torch.FloatTensor consisting of the binary mask scaled by 1/ (1 - dropout_probability).
This scaling ensures expected values and variances of the output of applying this mask
and the original tensor are the same.
"""
binary_mask = (torch.rand(tensor_for_masking.size()) > dropout_probability).to(tensor_for_masking.device)
# Scale mask by 1/keep_prob to preserve output statistics.
dropout_mask = binary_mask.float().div(1.0 - dropout_probability)
return dropout_mask
|
python
|
def get_dropout_mask(dropout_probability: float, tensor_for_masking: torch.Tensor):
"""
Computes and returns an element-wise dropout mask for a given tensor, where
each element in the mask is dropped out with probability dropout_probability.
Note that the mask is NOT applied to the tensor - the tensor is passed to retain
the correct CUDA tensor type for the mask.
Parameters
----------
dropout_probability : float, required.
Probability of dropping a dimension of the input.
tensor_for_masking : torch.Tensor, required.
Returns
-------
A torch.FloatTensor consisting of the binary mask scaled by 1/ (1 - dropout_probability).
This scaling ensures expected values and variances of the output of applying this mask
and the original tensor are the same.
"""
binary_mask = (torch.rand(tensor_for_masking.size()) > dropout_probability).to(tensor_for_masking.device)
# Scale mask by 1/keep_prob to preserve output statistics.
dropout_mask = binary_mask.float().div(1.0 - dropout_probability)
return dropout_mask
|
[
"def",
"get_dropout_mask",
"(",
"dropout_probability",
":",
"float",
",",
"tensor_for_masking",
":",
"torch",
".",
"Tensor",
")",
":",
"binary_mask",
"=",
"(",
"torch",
".",
"rand",
"(",
"tensor_for_masking",
".",
"size",
"(",
")",
")",
">",
"dropout_probability",
")",
".",
"to",
"(",
"tensor_for_masking",
".",
"device",
")",
"# Scale mask by 1/keep_prob to preserve output statistics.",
"dropout_mask",
"=",
"binary_mask",
".",
"float",
"(",
")",
".",
"div",
"(",
"1.0",
"-",
"dropout_probability",
")",
"return",
"dropout_mask"
] |
Computes and returns an element-wise dropout mask for a given tensor, where
each element in the mask is dropped out with probability dropout_probability.
Note that the mask is NOT applied to the tensor - the tensor is passed to retain
the correct CUDA tensor type for the mask.
Parameters
----------
dropout_probability : float, required.
Probability of dropping a dimension of the input.
tensor_for_masking : torch.Tensor, required.
Returns
-------
A torch.FloatTensor consisting of the binary mask scaled by 1/ (1 - dropout_probability).
This scaling ensures expected values and variances of the output of applying this mask
and the original tensor are the same.
|
[
"Computes",
"and",
"returns",
"an",
"element",
"-",
"wise",
"dropout",
"mask",
"for",
"a",
"given",
"tensor",
"where",
"each",
"element",
"in",
"the",
"mask",
"is",
"dropped",
"out",
"with",
"probability",
"dropout_probability",
".",
"Note",
"that",
"the",
"mask",
"is",
"NOT",
"applied",
"to",
"the",
"tensor",
"-",
"the",
"tensor",
"is",
"passed",
"to",
"retain",
"the",
"correct",
"CUDA",
"tensor",
"type",
"for",
"the",
"mask",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L205-L228
|
train
|
Computes and returns an element - wise dropout mask for a given tensor.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU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a,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + '\062' + '\067' + chr(0b11 + 0o57), 58939 - 58931), ehT0Px3KOsy9('\060' + chr(0b1101111 + 0o0) + chr(0b110001) + '\067' + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(2727 - 2616) + chr(0b101100 + 0o5) + chr(0b10111 + 0o36) + '\063', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(0b110111) + chr(0b110000), 6561 - 6553), ehT0Px3KOsy9(chr(0b110000) + chr(0b110100 + 0o73) + '\x31' + '\066' + chr(0b10111 + 0o31), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100101 + 0o112) + chr(0b110001) + '\x34' + '\061', 0b1000), ehT0Px3KOsy9(chr(1277 - 1229) + '\x6f' + '\x32' + chr(0b110011) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(0b110111) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(0b101100 + 0o13) + chr(1853 - 1799), 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(111) + chr(705 - 655) + chr(48) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(795 - 746) + chr(0b110010) + chr(0b110111), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101000 + 0o11) + '\064' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(1346 - 1298) + '\157' + chr(0b11001 + 0o30) + '\065' + chr(0b101010 + 0o7), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + '\062' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(240 - 192) + '\x6f' + chr(0b110001) + '\067' + '\061', 41144 - 41136), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b1000001 + 0o56) + chr(0b100111 + 0o14) + chr(0b0 + 0o65) + chr(0b1001 + 0o53), 27790 - 27782), ehT0Px3KOsy9(chr(48) + chr(0b1011101 + 0o22) + '\062' + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(0b1100001 + 0o16) + chr(0b110001) + chr(0b1111 + 0o41) + chr(2171 - 2123), 60832 - 60824), ehT0Px3KOsy9(chr(1950 - 1902) + chr(111) + '\x31' + chr(776 - 722) + chr(51), 0b1000), ehT0Px3KOsy9(chr(178 - 130) + chr(10784 - 10673) + '\061' + '\x30' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\062' + chr(53), 23666 - 23658), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + chr(0b110011) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1010100 + 0o33) + '\061' + chr(52) + chr(48), 9130 - 9122), ehT0Px3KOsy9(chr(48) + chr(7883 - 7772) + '\x32' + chr(48) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b101011 + 0o10) + chr(1306 - 1258) + chr(895 - 845), 18301 - 18293), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1643 - 1592) + chr(49) + '\x30', 133 - 125), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(49) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + chr(51) + chr(50) + chr(52), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(50) + chr(55) + chr(0b110010), 8), ehT0Px3KOsy9(chr(0b1 + 0o57) + '\157' + '\x32' + chr(0b110001 + 0o1) + chr(296 - 243), 0b1000), ehT0Px3KOsy9('\x30' + chr(5494 - 5383) + chr(0b10100 + 0o36) + chr(0b110111) + chr(706 - 651), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100010 + 0o17) + chr(58 - 7), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101111 + 0o4) + chr(71 - 20) + chr(0b101000 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(1898 - 1850) + '\157' + chr(682 - 631) + chr(0b110100) + '\065', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(786 - 736) + '\x30' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x37' + chr(321 - 266), 8737 - 8729), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b1110 + 0o51) + chr(573 - 522), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(0b1101 + 0o43) + chr(0b11 + 0o57), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b110000) + chr(10001 - 9890) + chr(53) + chr(1384 - 1335), 688 - 680)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1010 + 0o53) + chr(0b100 + 0o54), 43645 - 43637)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x94'), chr(8649 - 8549) + chr(6953 - 6852) + chr(0b1100011) + chr(0b11000 + 0o127) + chr(100) + '\x65')(chr(117) + chr(0b1010100 + 0o40) + '\146' + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def ffcOrBIpzppG(FHuHo8ytBekd, Y0nBb94ddEJ3):
Xs_xHKIVXy2P = (cEkFpYktkSeK.rand(Y0nBb94ddEJ3.size()) > FHuHo8ytBekd).to(Y0nBb94ddEJ3.device)
HyMmWPuGKzDp = Xs_xHKIVXy2P.float().div(1.0 - FHuHo8ytBekd)
return HyMmWPuGKzDp
|
allenai/allennlp
|
allennlp/nn/util.py
|
masked_softmax
|
def masked_softmax(vector: torch.Tensor,
mask: torch.Tensor,
dim: int = -1,
memory_efficient: bool = False,
mask_fill_value: float = -1e32) -> torch.Tensor:
"""
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
If ``memory_efficient`` is set to true, we will simply use a very large negative number for those
masked positions so that the probabilities of those positions would be approximately 0.
This is not accurate in math, but works for most cases and consumes less memory.
In the case that the input vector is completely masked and ``memory_efficient`` is false, this function
returns an array of ``0.0``. This behavior may cause ``NaN`` if this is used as the last layer of
a model that uses categorical cross-entropy loss. Instead, if ``memory_efficient`` is true, this function
will treat every element as equal, and do softmax over equal numbers.
"""
if mask is None:
result = torch.nn.functional.softmax(vector, dim=dim)
else:
mask = mask.float()
while mask.dim() < vector.dim():
mask = mask.unsqueeze(1)
if not memory_efficient:
# To limit numerical errors from large vector elements outside the mask, we zero these out.
result = torch.nn.functional.softmax(vector * mask, dim=dim)
result = result * mask
result = result / (result.sum(dim=dim, keepdim=True) + 1e-13)
else:
masked_vector = vector.masked_fill((1 - mask).byte(), mask_fill_value)
result = torch.nn.functional.softmax(masked_vector, dim=dim)
return result
|
python
|
def masked_softmax(vector: torch.Tensor,
mask: torch.Tensor,
dim: int = -1,
memory_efficient: bool = False,
mask_fill_value: float = -1e32) -> torch.Tensor:
"""
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
If ``memory_efficient`` is set to true, we will simply use a very large negative number for those
masked positions so that the probabilities of those positions would be approximately 0.
This is not accurate in math, but works for most cases and consumes less memory.
In the case that the input vector is completely masked and ``memory_efficient`` is false, this function
returns an array of ``0.0``. This behavior may cause ``NaN`` if this is used as the last layer of
a model that uses categorical cross-entropy loss. Instead, if ``memory_efficient`` is true, this function
will treat every element as equal, and do softmax over equal numbers.
"""
if mask is None:
result = torch.nn.functional.softmax(vector, dim=dim)
else:
mask = mask.float()
while mask.dim() < vector.dim():
mask = mask.unsqueeze(1)
if not memory_efficient:
# To limit numerical errors from large vector elements outside the mask, we zero these out.
result = torch.nn.functional.softmax(vector * mask, dim=dim)
result = result * mask
result = result / (result.sum(dim=dim, keepdim=True) + 1e-13)
else:
masked_vector = vector.masked_fill((1 - mask).byte(), mask_fill_value)
result = torch.nn.functional.softmax(masked_vector, dim=dim)
return result
|
[
"def",
"masked_softmax",
"(",
"vector",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dim",
":",
"int",
"=",
"-",
"1",
",",
"memory_efficient",
":",
"bool",
"=",
"False",
",",
"mask_fill_value",
":",
"float",
"=",
"-",
"1e32",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"mask",
"is",
"None",
":",
"result",
"=",
"torch",
".",
"nn",
".",
"functional",
".",
"softmax",
"(",
"vector",
",",
"dim",
"=",
"dim",
")",
"else",
":",
"mask",
"=",
"mask",
".",
"float",
"(",
")",
"while",
"mask",
".",
"dim",
"(",
")",
"<",
"vector",
".",
"dim",
"(",
")",
":",
"mask",
"=",
"mask",
".",
"unsqueeze",
"(",
"1",
")",
"if",
"not",
"memory_efficient",
":",
"# To limit numerical errors from large vector elements outside the mask, we zero these out.",
"result",
"=",
"torch",
".",
"nn",
".",
"functional",
".",
"softmax",
"(",
"vector",
"*",
"mask",
",",
"dim",
"=",
"dim",
")",
"result",
"=",
"result",
"*",
"mask",
"result",
"=",
"result",
"/",
"(",
"result",
".",
"sum",
"(",
"dim",
"=",
"dim",
",",
"keepdim",
"=",
"True",
")",
"+",
"1e-13",
")",
"else",
":",
"masked_vector",
"=",
"vector",
".",
"masked_fill",
"(",
"(",
"1",
"-",
"mask",
")",
".",
"byte",
"(",
")",
",",
"mask_fill_value",
")",
"result",
"=",
"torch",
".",
"nn",
".",
"functional",
".",
"softmax",
"(",
"masked_vector",
",",
"dim",
"=",
"dim",
")",
"return",
"result"
] |
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
If ``memory_efficient`` is set to true, we will simply use a very large negative number for those
masked positions so that the probabilities of those positions would be approximately 0.
This is not accurate in math, but works for most cases and consumes less memory.
In the case that the input vector is completely masked and ``memory_efficient`` is false, this function
returns an array of ``0.0``. This behavior may cause ``NaN`` if this is used as the last layer of
a model that uses categorical cross-entropy loss. Instead, if ``memory_efficient`` is true, this function
will treat every element as equal, and do softmax over equal numbers.
|
[
"torch",
".",
"nn",
".",
"functional",
".",
"softmax",
"(",
"vector",
")",
"does",
"not",
"work",
"if",
"some",
"elements",
"of",
"vector",
"should",
"be",
"masked",
".",
"This",
"performs",
"a",
"softmax",
"on",
"just",
"the",
"non",
"-",
"masked",
"portions",
"of",
"vector",
".",
"Passing",
"None",
"in",
"for",
"the",
"mask",
"is",
"also",
"acceptable",
";",
"you",
"ll",
"just",
"get",
"a",
"regular",
"softmax",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db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ByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b11100 + 0o123) + '\x33' + chr(48), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1011111 + 0o20) + chr(1491 - 1442) + chr(127 - 78) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + '\065' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + '\x32' + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(2242 - 2190) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(1277 - 1223) + chr(0b11 + 0o60), ord("\x08")), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1100011 + 0o14) + chr(0b100000 + 0o23) + chr(50) + '\x36', 0o10), ehT0Px3KOsy9(chr(1028 - 980) + chr(0b11101 + 0o122) + chr(49) + chr(0b1000 + 0o53) + chr(0b110011), 24863 - 24855), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(52) + chr(0b110101), 45508 - 45500), ehT0Px3KOsy9('\x30' + chr(0b110010 + 0o75) + chr(0b110110 + 0o1) + chr(1731 - 1676), 13266 - 13258), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(0b1100 + 0o51) + '\x36', 43763 - 43755), ehT0Px3KOsy9('\060' + chr(3114 - 3003) + '\062' + chr(0b11 + 0o56) + chr(476 - 422), 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(111) + chr(0b100111 + 0o13) + chr(55) + chr(48), 61594 - 61586), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(0b110010) + chr(333 - 278) + chr(53), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\066' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101011 + 0o4) + '\x31' + '\065' + chr(0b10011 + 0o44), 46328 - 46320), ehT0Px3KOsy9(chr(985 - 937) + chr(0b111001 + 0o66) + '\061' + chr(48) + chr(0b110100 + 0o3), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b10 + 0o61) + chr(0b110101) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(4933 - 4822) + '\x32' + chr(2326 - 2271), 39710 - 39702), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(0b110011) + chr(0b110010 + 0o5) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(5340 - 5229) + chr(0b110001) + '\063' + '\x31', 0o10), ehT0Px3KOsy9('\060' + chr(4562 - 4451) + chr(0b10110 + 0o41) + chr(1414 - 1365), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(967 - 913) + chr(53), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1111 + 0o140) + chr(0b110001) + chr(0b11000 + 0o32) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\066' + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + '\062' + '\062' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101110 + 0o3) + chr(0b10111 + 0o36) + chr(0b1110 + 0o51), 8), ehT0Px3KOsy9('\060' + chr(5581 - 5470) + '\062' + chr(1176 - 1127) + chr(0b1111 + 0o46), 54906 - 54898), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(0b110001) + chr(632 - 578), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2218 - 2168) + '\x31' + '\x37', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x36' + '\060', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11010 + 0o27) + chr(0b110111) + '\063', 54963 - 54955), ehT0Px3KOsy9('\060' + chr(9788 - 9677) + '\x33' + chr(51) + chr(0b101100 + 0o12), 0b1000), ehT0Px3KOsy9(chr(589 - 541) + '\x6f' + chr(0b110001) + '\067' + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(521 - 471) + chr(48) + chr(0b101110 + 0o11), 43319 - 43311), ehT0Px3KOsy9(chr(48) + '\157' + chr(207 - 158) + chr(0b110001) + chr(54), 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + '\x33' + chr(0b11 + 0o57), 34127 - 34119), ehT0Px3KOsy9('\060' + chr(0b100011 + 0o114) + chr(0b110001) + chr(0b100100 + 0o15) + chr(2651 - 2596), 12151 - 12143), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + chr(0b110110) + chr(0b110010), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(2126 - 2015) + '\x35' + chr(0b10000 + 0o40), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'6'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(111) + chr(100) + '\x65')(chr(5547 - 5430) + '\x74' + chr(4787 - 4685) + chr(0b101101) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Q5AuhKlbKe1m(_TN4tZmqvFR4, Iz1jSgUKZDvt, Nl_JhL3qUwSN=-ehT0Px3KOsy9(chr(0b10 + 0o56) + '\157' + '\061', ord("\x08")), wzsMPfM2076j=ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + '\060', 0o10), UXWLPJKOGSWq=-1e+32) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'Lw#\x9b9\xd5'), chr(0b1100100) + '\x65' + chr(0b1100011) + chr(111) + '\144' + chr(0b1101 + 0o130))(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(2004 - 1959) + '\x38')):
if Iz1jSgUKZDvt is None:
ShZmEKfTkAOZ = cEkFpYktkSeK.nn.functional.softmax(_TN4tZmqvFR4, dim=Nl_JhL3qUwSN)
else:
Iz1jSgUKZDvt = Iz1jSgUKZDvt.float()
while xafqLlk3kkUe(Iz1jSgUKZDvt, xafqLlk3kkUe(SXOLrMavuUCe(b'|{ '), '\144' + chr(0b11 + 0o142) + '\143' + chr(111) + chr(100) + chr(10154 - 10053))('\x75' + chr(116) + '\146' + '\055' + '\070'))() < xafqLlk3kkUe(_TN4tZmqvFR4, xafqLlk3kkUe(SXOLrMavuUCe(b'|{ '), chr(0b1000010 + 0o42) + chr(7327 - 7226) + chr(0b1001 + 0o132) + '\157' + chr(0b1001011 + 0o31) + chr(0b1100101))(chr(0b110110 + 0o77) + chr(116) + chr(102) + chr(45) + '\x38'))():
Iz1jSgUKZDvt = Iz1jSgUKZDvt.unsqueeze(ehT0Px3KOsy9('\x30' + chr(0b11000 + 0o127) + chr(0b110001), 8))
if not wzsMPfM2076j:
ShZmEKfTkAOZ = cEkFpYktkSeK.nn.functional.softmax(_TN4tZmqvFR4 * Iz1jSgUKZDvt, dim=Nl_JhL3qUwSN)
ShZmEKfTkAOZ = ShZmEKfTkAOZ * Iz1jSgUKZDvt
ShZmEKfTkAOZ = ShZmEKfTkAOZ / (ShZmEKfTkAOZ.xkxBmo49x2An(dim=Nl_JhL3qUwSN, keepdim=ehT0Px3KOsy9(chr(48) + '\157' + '\x31', 8)) + 1e-13)
else:
V1w8bFsl6A8R = _TN4tZmqvFR4.masked_fill((ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1460 - 1411), 8) - Iz1jSgUKZDvt).byte(), UXWLPJKOGSWq)
ShZmEKfTkAOZ = cEkFpYktkSeK.nn.functional.softmax(V1w8bFsl6A8R, dim=Nl_JhL3qUwSN)
return ShZmEKfTkAOZ
|
allenai/allennlp
|
allennlp/nn/util.py
|
masked_log_softmax
|
def masked_log_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1) -> torch.Tensor:
"""
``torch.nn.functional.log_softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a log_softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular log_softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
In the case that the input vector is completely masked, the return value of this function is
arbitrary, but not ``nan``. You should be masking the result of whatever computation comes out
of this in that case, anyway, so the specific values returned shouldn't matter. Also, the way
that we deal with this case relies on having single-precision floats; mixing half-precision
floats with fully-masked vectors will likely give you ``nans``.
If your logits are all extremely negative (i.e., the max value in your logit vector is -50 or
lower), the way we handle masking here could mess you up. But if you've got logit values that
extreme, you've got bigger problems than this.
"""
if mask is not None:
mask = mask.float()
while mask.dim() < vector.dim():
mask = mask.unsqueeze(1)
# vector + mask.log() is an easy way to zero out masked elements in logspace, but it
# results in nans when the whole vector is masked. We need a very small value instead of a
# zero in the mask for these cases. log(1 + 1e-45) is still basically 0, so we can safely
# just add 1e-45 before calling mask.log(). We use 1e-45 because 1e-46 is so small it
# becomes 0 - this is just the smallest value we can actually use.
vector = vector + (mask + 1e-45).log()
return torch.nn.functional.log_softmax(vector, dim=dim)
|
python
|
def masked_log_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1) -> torch.Tensor:
"""
``torch.nn.functional.log_softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a log_softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular log_softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
In the case that the input vector is completely masked, the return value of this function is
arbitrary, but not ``nan``. You should be masking the result of whatever computation comes out
of this in that case, anyway, so the specific values returned shouldn't matter. Also, the way
that we deal with this case relies on having single-precision floats; mixing half-precision
floats with fully-masked vectors will likely give you ``nans``.
If your logits are all extremely negative (i.e., the max value in your logit vector is -50 or
lower), the way we handle masking here could mess you up. But if you've got logit values that
extreme, you've got bigger problems than this.
"""
if mask is not None:
mask = mask.float()
while mask.dim() < vector.dim():
mask = mask.unsqueeze(1)
# vector + mask.log() is an easy way to zero out masked elements in logspace, but it
# results in nans when the whole vector is masked. We need a very small value instead of a
# zero in the mask for these cases. log(1 + 1e-45) is still basically 0, so we can safely
# just add 1e-45 before calling mask.log(). We use 1e-45 because 1e-46 is so small it
# becomes 0 - this is just the smallest value we can actually use.
vector = vector + (mask + 1e-45).log()
return torch.nn.functional.log_softmax(vector, dim=dim)
|
[
"def",
"masked_log_softmax",
"(",
"vector",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dim",
":",
"int",
"=",
"-",
"1",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"mask",
"is",
"not",
"None",
":",
"mask",
"=",
"mask",
".",
"float",
"(",
")",
"while",
"mask",
".",
"dim",
"(",
")",
"<",
"vector",
".",
"dim",
"(",
")",
":",
"mask",
"=",
"mask",
".",
"unsqueeze",
"(",
"1",
")",
"# vector + mask.log() is an easy way to zero out masked elements in logspace, but it",
"# results in nans when the whole vector is masked. We need a very small value instead of a",
"# zero in the mask for these cases. log(1 + 1e-45) is still basically 0, so we can safely",
"# just add 1e-45 before calling mask.log(). We use 1e-45 because 1e-46 is so small it",
"# becomes 0 - this is just the smallest value we can actually use.",
"vector",
"=",
"vector",
"+",
"(",
"mask",
"+",
"1e-45",
")",
".",
"log",
"(",
")",
"return",
"torch",
".",
"nn",
".",
"functional",
".",
"log_softmax",
"(",
"vector",
",",
"dim",
"=",
"dim",
")"
] |
``torch.nn.functional.log_softmax(vector)`` does not work if some elements of ``vector`` should be
masked. This performs a log_softmax on just the non-masked portions of ``vector``. Passing
``None`` in for the mask is also acceptable; you'll just get a regular log_softmax.
``vector`` can have an arbitrary number of dimensions; the only requirement is that ``mask`` is
broadcastable to ``vector's`` shape. If ``mask`` has fewer dimensions than ``vector``, we will
unsqueeze on dimension 1 until they match. If you need a different unsqueezing of your mask,
do it yourself before passing the mask into this function.
In the case that the input vector is completely masked, the return value of this function is
arbitrary, but not ``nan``. You should be masking the result of whatever computation comes out
of this in that case, anyway, so the specific values returned shouldn't matter. Also, the way
that we deal with this case relies on having single-precision floats; mixing half-precision
floats with fully-masked vectors will likely give you ``nans``.
If your logits are all extremely negative (i.e., the max value in your logit vector is -50 or
lower), the way we handle masking here could mess you up. But if you've got logit values that
extreme, you've got bigger problems than this.
|
[
"torch",
".",
"nn",
".",
"functional",
".",
"log_softmax",
"(",
"vector",
")",
"does",
"not",
"work",
"if",
"some",
"elements",
"of",
"vector",
"should",
"be",
"masked",
".",
"This",
"performs",
"a",
"log_softmax",
"on",
"just",
"the",
"non",
"-",
"masked",
"portions",
"of",
"vector",
".",
"Passing",
"None",
"in",
"for",
"the",
"mask",
"is",
"also",
"acceptable",
";",
"you",
"ll",
"just",
"get",
"a",
"regular",
"log_softmax",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L272-L303
|
train
|
This function performs a log_softmax on the given vector and returns the result of the log_softmax function.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv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Dw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1528 - 1480) + '\x6f' + chr(51) + chr(53) + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + chr(2116 - 2065) + chr(0b0 + 0o60), 42105 - 42097), ehT0Px3KOsy9('\x30' + chr(4770 - 4659) + '\x31' + '\067' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\157' + chr(726 - 674) + chr(1207 - 1156), 21027 - 21019), ehT0Px3KOsy9(chr(817 - 769) + '\x6f' + '\x33' + chr(430 - 380) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b110000) + '\x32', 46465 - 46457), ehT0Px3KOsy9(chr(2037 - 1989) + chr(0b1011111 + 0o20) + '\x31' + chr(0b0 + 0o62) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(383 - 335) + '\x6f' + '\062' + '\x31', 19463 - 19455), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b11110 + 0o23) + '\067' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(2124 - 2076) + chr(5887 - 5776) + '\x32' + chr(1776 - 1725) + chr(0b100 + 0o57), 43592 - 43584), ehT0Px3KOsy9(chr(1603 - 1555) + chr(0b1101111) + chr(0b10011 + 0o40) + chr(55) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(0b101011 + 0o6) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(0b100 + 0o56) + chr(0b110100 + 0o2), 30574 - 30566), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(0b111 + 0o51) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(1965 - 1916) + chr(0b10001 + 0o43) + chr(55), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(1913 - 1863) + chr(0b110010 + 0o1) + chr(1212 - 1163), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(194 - 143) + '\x30' + '\063', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001111 + 0o40) + chr(0b110001) + chr(2357 - 2306) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(0b11001 + 0o126) + chr(892 - 841) + chr(0b101 + 0o55) + chr(0b100000 + 0o26), 8), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + '\x31' + '\x31', 524 - 516), ehT0Px3KOsy9(chr(1337 - 1289) + '\157' + chr(560 - 511) + chr(54) + chr(0b11001 + 0o35), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1006 - 956) + chr(0b110100) + chr(729 - 674), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(54) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b110000 + 0o77) + '\062' + chr(0b11010 + 0o32) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\157' + chr(123 - 73) + chr(855 - 806) + chr(49), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b10010 + 0o45), 0o10), ehT0Px3KOsy9(chr(2039 - 1991) + chr(0b111 + 0o150) + '\x32' + chr(0b11 + 0o57) + '\x30', 41365 - 41357), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2191 - 2138) + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(2288 - 2237) + '\067' + chr(0b10000 + 0o43), 0b1000), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + '\066' + '\x37', 23966 - 23958), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b1101111 + 0o0) + chr(0b110011) + chr(49) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011001 + 0o26) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + chr(48) + chr(1522 - 1469), 45249 - 45241), ehT0Px3KOsy9('\060' + chr(111) + '\063' + '\x35' + '\x33', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b100101 + 0o15), ord("\x08")), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(10199 - 10088) + '\061' + chr(546 - 492) + chr(0b110010 + 0o3), 0o10), ehT0Px3KOsy9(chr(1673 - 1625) + chr(111) + chr(50) + chr(0b101100 + 0o11) + chr(0b11101 + 0o26), 50502 - 50494), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\x6f' + chr(0b110001) + '\x33' + chr(0b110011), 23845 - 23837), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1100 + 0o47) + chr(48) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010 + 0o0) + chr(48), 17164 - 17156)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + chr(0b110101) + chr(0b100001 + 0o17), 63260 - 63252)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4'), '\x64' + '\x65' + chr(0b1100011) + chr(0b111111 + 0o60) + '\144' + chr(0b100011 + 0o102))('\x75' + chr(0b101110 + 0o106) + '\x66' + chr(0b11010 + 0o23) + chr(198 - 142)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def JjeadZLAgm0n(_TN4tZmqvFR4, Iz1jSgUKZDvt, Nl_JhL3qUwSN=-ehT0Px3KOsy9('\060' + '\157' + '\x31', 56026 - 56018)) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbe\xbd\x10P\xba\xf0'), '\144' + chr(0b1100101) + chr(99) + chr(0b1101111) + '\144' + chr(101))('\165' + chr(7915 - 7799) + chr(7864 - 7762) + chr(45) + chr(0b10 + 0o66))):
if Iz1jSgUKZDvt is not None:
Iz1jSgUKZDvt = Iz1jSgUKZDvt.float()
while xafqLlk3kkUe(Iz1jSgUKZDvt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xb1\x13'), chr(0b1100100) + '\145' + '\143' + '\157' + chr(0b1100100) + chr(1530 - 1429))('\x75' + '\164' + chr(102) + '\055' + chr(56)))() < xafqLlk3kkUe(_TN4tZmqvFR4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xb1\x13'), '\144' + '\x65' + chr(331 - 232) + '\x6f' + '\144' + '\x65')(chr(117) + chr(9197 - 9081) + chr(102) + '\055' + '\x38'))():
Iz1jSgUKZDvt = Iz1jSgUKZDvt.unsqueeze(ehT0Px3KOsy9('\x30' + '\157' + chr(0b1110 + 0o43), 8))
_TN4tZmqvFR4 = _TN4tZmqvFR4 + (Iz1jSgUKZDvt + 1e-45).log()
return xafqLlk3kkUe(cEkFpYktkSeK.nn.functional, xafqLlk3kkUe(SXOLrMavuUCe(b'\x86\xb7\x19|\xa6\xed5e\x10\xfa\x87'), chr(4074 - 3974) + chr(8459 - 8358) + '\143' + chr(0b1101111) + '\x64' + chr(0b1100101))(chr(117) + '\x74' + chr(0b11000 + 0o116) + '\x2d' + chr(0b100001 + 0o27)))(_TN4tZmqvFR4, dim=Nl_JhL3qUwSN)
|
allenai/allennlp
|
allennlp/nn/util.py
|
masked_max
|
def masked_max(vector: torch.Tensor,
mask: torch.Tensor,
dim: int,
keepdim: bool = False,
min_val: float = -1e7) -> torch.Tensor:
"""
To calculate max along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate max, assume unmasked parts are already zeros
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate max
keepdim : ``bool``
Whether to keep dimension
min_val : ``float``
The minimal value for paddings
Returns
-------
A ``torch.Tensor`` of including the maximum values.
"""
one_minus_mask = (1.0 - mask).byte()
replaced_vector = vector.masked_fill(one_minus_mask, min_val)
max_value, _ = replaced_vector.max(dim=dim, keepdim=keepdim)
return max_value
|
python
|
def masked_max(vector: torch.Tensor,
mask: torch.Tensor,
dim: int,
keepdim: bool = False,
min_val: float = -1e7) -> torch.Tensor:
"""
To calculate max along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate max, assume unmasked parts are already zeros
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate max
keepdim : ``bool``
Whether to keep dimension
min_val : ``float``
The minimal value for paddings
Returns
-------
A ``torch.Tensor`` of including the maximum values.
"""
one_minus_mask = (1.0 - mask).byte()
replaced_vector = vector.masked_fill(one_minus_mask, min_val)
max_value, _ = replaced_vector.max(dim=dim, keepdim=keepdim)
return max_value
|
[
"def",
"masked_max",
"(",
"vector",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dim",
":",
"int",
",",
"keepdim",
":",
"bool",
"=",
"False",
",",
"min_val",
":",
"float",
"=",
"-",
"1e7",
")",
"->",
"torch",
".",
"Tensor",
":",
"one_minus_mask",
"=",
"(",
"1.0",
"-",
"mask",
")",
".",
"byte",
"(",
")",
"replaced_vector",
"=",
"vector",
".",
"masked_fill",
"(",
"one_minus_mask",
",",
"min_val",
")",
"max_value",
",",
"_",
"=",
"replaced_vector",
".",
"max",
"(",
"dim",
"=",
"dim",
",",
"keepdim",
"=",
"keepdim",
")",
"return",
"max_value"
] |
To calculate max along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate max, assume unmasked parts are already zeros
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate max
keepdim : ``bool``
Whether to keep dimension
min_val : ``float``
The minimal value for paddings
Returns
-------
A ``torch.Tensor`` of including the maximum values.
|
[
"To",
"calculate",
"max",
"along",
"certain",
"dimensions",
"on",
"masked",
"values"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L306-L334
|
train
|
Returns the maximum value of a set of unmasked parts along certain dimensions.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsD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,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(9205 - 9094) + chr(1089 - 1038) + '\062' + chr(0b110010), 122 - 114), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b101000 + 0o107) + '\061' + '\x30' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101111) + chr(0b10001 + 0o46) + '\064', 38084 - 38076), ehT0Px3KOsy9('\060' + chr(1674 - 1563) + chr(0b110011) + chr(0b11010 + 0o35) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(719 - 668) + chr(0b1010 + 0o47) + chr(866 - 818), 0b1000), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(9408 - 9297) + chr(0b1101 + 0o45) + chr(1318 - 1264) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + chr(51) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + chr(55) + chr(0b101001 + 0o11), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11 + 0o57) + chr(2048 - 1997) + '\x30', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + chr(2092 - 2038) + chr(0b1000 + 0o50), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(54) + chr(0b101000 + 0o12), 0o10), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(8209 - 8098) + chr(1673 - 1623) + chr(0b110010) + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(1826 - 1777) + '\x34' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(2074 - 2026) + '\x6f' + chr(0b110111 + 0o0) + '\x35', 13137 - 13129), ehT0Px3KOsy9(chr(1373 - 1325) + chr(0b110111 + 0o70) + chr(0b11111 + 0o23) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b110011 + 0o74) + chr(0b110010) + chr(0b110001) + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\062' + '\x30', 8), ehT0Px3KOsy9(chr(1416 - 1368) + chr(0b100111 + 0o110) + chr(51) + '\062' + chr(0b11100 + 0o30), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011000 + 0o27) + chr(2336 - 2286) + chr(0b1000 + 0o50), 8), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b110001 + 0o76) + '\063' + chr(0b11111 + 0o21) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(882 - 829) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + '\060' + chr(57 - 8), 0o10), ehT0Px3KOsy9(chr(1224 - 1176) + chr(0b1100101 + 0o12) + chr(50) + chr(2598 - 2546) + chr(49), 17190 - 17182), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(48) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(111) + chr(783 - 734) + chr(573 - 522) + chr(0b110001), 18049 - 18041), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(6927 - 6816) + chr(0b110001) + '\066' + '\067', 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1011011 + 0o24) + chr(973 - 924) + '\066', 49804 - 49796), ehT0Px3KOsy9(chr(982 - 934) + '\x6f' + chr(0b110010) + chr(51) + chr(2655 - 2600), 7057 - 7049), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + '\x32' + chr(0b111 + 0o51), 45678 - 45670), ehT0Px3KOsy9(chr(363 - 315) + chr(9058 - 8947) + '\x33' + chr(0b110101) + chr(471 - 423), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + '\x31' + chr(0b100100 + 0o14), 13195 - 13187), ehT0Px3KOsy9('\060' + chr(1513 - 1402) + '\061' + chr(0b110011) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(62 - 14) + '\x6f' + chr(0b11110 + 0o23) + '\066' + '\x30', 64717 - 64709), ehT0Px3KOsy9(chr(48) + chr(0b1010 + 0o145) + '\061' + chr(55) + '\063', 0o10), ehT0Px3KOsy9(chr(2122 - 2074) + chr(111) + chr(0b110001) + '\063' + chr(0b100001 + 0o21), 50314 - 50306), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(0b11011 + 0o27) + chr(0b111 + 0o51) + chr(49), 8), ehT0Px3KOsy9(chr(48) + chr(0b101000 + 0o107) + '\063' + chr(0b1111 + 0o50) + chr(51), 56699 - 56691), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + '\060' + chr(1497 - 1447), 0o10), ehT0Px3KOsy9('\x30' + chr(4733 - 4622) + chr(52) + chr(0b111 + 0o51), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110101) + '\x30', 46305 - 46297)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc'), chr(1634 - 1534) + chr(0b1011110 + 0o7) + chr(8225 - 8126) + '\x6f' + '\144' + '\x65')(chr(0b10001 + 0o144) + chr(0b1110100) + '\x66' + chr(45) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def G3c3M4OZXIHF(_TN4tZmqvFR4, Iz1jSgUKZDvt, Nl_JhL3qUwSN, JV7aKBs7fw38=ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11 + 0o55), 0b1000), YdK7JvoxMQgh=-10000000.0) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x86m-O\x90\xba'), chr(0b101 + 0o137) + '\x65' + chr(99) + chr(111) + chr(100) + chr(0b1100101))(chr(0b1001011 + 0o52) + '\x74' + chr(0b11 + 0o143) + chr(1942 - 1897) + chr(56))):
V9HcH9b3iQTB = (1.0 - Iz1jSgUKZDvt).byte()
aaj0pxejExa9 = _TN4tZmqvFR4.masked_fill(V9HcH9b3iQTB, YdK7JvoxMQgh)
(ZfankSVgk_nH, VNGQdHSFPrso) = aaj0pxejExa9.tsdjvlgh9gDP(dim=Nl_JhL3qUwSN, keepdim=JV7aKBs7fw38)
return ZfankSVgk_nH
|
allenai/allennlp
|
allennlp/nn/util.py
|
masked_mean
|
def masked_mean(vector: torch.Tensor,
mask: torch.Tensor,
dim: int,
keepdim: bool = False,
eps: float = 1e-8) -> torch.Tensor:
"""
To calculate mean along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate mean.
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate mean
keepdim : ``bool``
Whether to keep dimension
eps : ``float``
A small value to avoid zero division problem.
Returns
-------
A ``torch.Tensor`` of including the mean values.
"""
one_minus_mask = (1.0 - mask).byte()
replaced_vector = vector.masked_fill(one_minus_mask, 0.0)
value_sum = torch.sum(replaced_vector, dim=dim, keepdim=keepdim)
value_count = torch.sum(mask.float(), dim=dim, keepdim=keepdim)
return value_sum / value_count.clamp(min=eps)
|
python
|
def masked_mean(vector: torch.Tensor,
mask: torch.Tensor,
dim: int,
keepdim: bool = False,
eps: float = 1e-8) -> torch.Tensor:
"""
To calculate mean along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate mean.
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate mean
keepdim : ``bool``
Whether to keep dimension
eps : ``float``
A small value to avoid zero division problem.
Returns
-------
A ``torch.Tensor`` of including the mean values.
"""
one_minus_mask = (1.0 - mask).byte()
replaced_vector = vector.masked_fill(one_minus_mask, 0.0)
value_sum = torch.sum(replaced_vector, dim=dim, keepdim=keepdim)
value_count = torch.sum(mask.float(), dim=dim, keepdim=keepdim)
return value_sum / value_count.clamp(min=eps)
|
[
"def",
"masked_mean",
"(",
"vector",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dim",
":",
"int",
",",
"keepdim",
":",
"bool",
"=",
"False",
",",
"eps",
":",
"float",
"=",
"1e-8",
")",
"->",
"torch",
".",
"Tensor",
":",
"one_minus_mask",
"=",
"(",
"1.0",
"-",
"mask",
")",
".",
"byte",
"(",
")",
"replaced_vector",
"=",
"vector",
".",
"masked_fill",
"(",
"one_minus_mask",
",",
"0.0",
")",
"value_sum",
"=",
"torch",
".",
"sum",
"(",
"replaced_vector",
",",
"dim",
"=",
"dim",
",",
"keepdim",
"=",
"keepdim",
")",
"value_count",
"=",
"torch",
".",
"sum",
"(",
"mask",
".",
"float",
"(",
")",
",",
"dim",
"=",
"dim",
",",
"keepdim",
"=",
"keepdim",
")",
"return",
"value_sum",
"/",
"value_count",
".",
"clamp",
"(",
"min",
"=",
"eps",
")"
] |
To calculate mean along certain dimensions on masked values
Parameters
----------
vector : ``torch.Tensor``
The vector to calculate mean.
mask : ``torch.Tensor``
The mask of the vector. It must be broadcastable with vector.
dim : ``int``
The dimension to calculate mean
keepdim : ``bool``
Whether to keep dimension
eps : ``float``
A small value to avoid zero division problem.
Returns
-------
A ``torch.Tensor`` of including the mean values.
|
[
"To",
"calculate",
"mean",
"along",
"certain",
"dimensions",
"on",
"masked",
"values"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L337-L367
|
train
|
Calculates the mean along certain dimensions on masked values.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco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9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + chr(1604 - 1551) + chr(1541 - 1488), 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(0b110111) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + '\x32' + chr(49) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + '\x36' + chr(0b1100 + 0o51), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(1378 - 1267) + '\062' + chr(958 - 908) + '\x35', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100110 + 0o17) + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b1001 + 0o55) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110110) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(1135 - 1087) + chr(111) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(300 - 252) + chr(0b1101111) + '\063' + '\064' + '\x32', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101001 + 0o12) + chr(52) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(2260 - 2212) + chr(688 - 577) + '\x32' + chr(1642 - 1592) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\157' + chr(0b10101 + 0o40), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\060' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b110101) + '\x32', 24466 - 24458), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(536 - 486) + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(0b100100 + 0o21) + chr(234 - 181), 8), ehT0Px3KOsy9('\x30' + chr(8094 - 7983) + '\x31' + chr(0b101001 + 0o12) + chr(0b11011 + 0o25), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(1459 - 1348) + chr(0b110001) + chr(50) + chr(382 - 330), 34858 - 34850), ehT0Px3KOsy9(chr(48) + '\157' + '\x34' + '\x36', 61203 - 61195), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1101 + 0o44) + chr(529 - 480), 0o10), ehT0Px3KOsy9(chr(1624 - 1576) + chr(0b1000110 + 0o51) + '\061' + chr(0b10110 + 0o36) + chr(2145 - 2094), ord("\x08")), ehT0Px3KOsy9('\060' + chr(6358 - 6247) + chr(1304 - 1253) + '\x36' + '\067', 43510 - 43502), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101001 + 0o12) + '\x34' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + '\x34' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(2530 - 2477) + '\066', 0o10), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + '\063' + chr(0b110101) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\067' + '\x35', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(0b110011) + chr(0b11 + 0o61), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100001 + 0o16) + '\063' + chr(0b110000) + chr(0b101110 + 0o4), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101101 + 0o102) + '\x32' + chr(1919 - 1867) + chr(250 - 200), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10011 + 0o37) + chr(1929 - 1878), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(52) + '\x31', 8), ehT0Px3KOsy9('\x30' + chr(5187 - 5076) + chr(0b110011) + chr(554 - 502) + '\062', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(579 - 528) + chr(0b110001) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(853 - 805) + chr(111) + chr(778 - 729) + '\063' + chr(48), 8), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b111 + 0o150) + '\x33' + chr(0b10100 + 0o40) + '\061', 8), ehT0Px3KOsy9('\x30' + chr(5663 - 5552) + chr(0b110110) + chr(0b110010), 63538 - 63530), ehT0Px3KOsy9('\060' + '\157' + chr(1253 - 1202) + chr(1964 - 1913) + chr(1635 - 1583), 8), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(5522 - 5411) + '\062' + chr(0b110100) + chr(54), 44225 - 44217)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + chr(355 - 302) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x83'), '\144' + '\145' + chr(2321 - 2222) + '\x6f' + chr(100) + chr(101))(chr(13066 - 12949) + '\164' + chr(2128 - 2026) + chr(0b101101) + chr(2447 - 2391)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def cw_lit_0tgaI(_TN4tZmqvFR4, Iz1jSgUKZDvt, Nl_JhL3qUwSN, JV7aKBs7fw38=ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x30', ord("\x08")), ANx8zFubz7L8=1e-08) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf9Y\xe7\x86\xfa^'), chr(8384 - 8284) + chr(0b100001 + 0o104) + '\x63' + chr(111) + '\144' + chr(101))(chr(117) + chr(116) + chr(102) + chr(45) + chr(0b111000))):
V9HcH9b3iQTB = (1.0 - Iz1jSgUKZDvt).byte()
aaj0pxejExa9 = _TN4tZmqvFR4.masked_fill(V9HcH9b3iQTB, 0.0)
WjbmpLZuxbao = cEkFpYktkSeK.xkxBmo49x2An(aaj0pxejExa9, dim=Nl_JhL3qUwSN, keepdim=JV7aKBs7fw38)
uqx97zsZGdir = cEkFpYktkSeK.xkxBmo49x2An(Iz1jSgUKZDvt.float(), dim=Nl_JhL3qUwSN, keepdim=JV7aKBs7fw38)
return WjbmpLZuxbao / xafqLlk3kkUe(uqx97zsZGdir, xafqLlk3kkUe(SXOLrMavuUCe(b'\xceP\xe8\x98\xe5'), chr(100) + chr(101) + '\143' + '\157' + '\x64' + '\x65')(chr(117) + chr(0b10000 + 0o144) + '\x66' + chr(45) + '\x38'))(min=ANx8zFubz7L8)
|
allenai/allennlp
|
allennlp/nn/util.py
|
masked_flip
|
def masked_flip(padded_sequence: torch.Tensor,
sequence_lengths: List[int]) -> torch.Tensor:
"""
Flips a padded tensor along the time dimension without affecting masked entries.
Parameters
----------
padded_sequence : ``torch.Tensor``
The tensor to flip along the time dimension.
Assumed to be of dimensions (batch size, num timesteps, ...)
sequence_lengths : ``torch.Tensor``
A list containing the lengths of each unpadded sequence in the batch.
Returns
-------
A ``torch.Tensor`` of the same shape as padded_sequence.
"""
assert padded_sequence.size(0) == len(sequence_lengths), \
f'sequence_lengths length ${len(sequence_lengths)} does not match batch size ${padded_sequence.size(0)}'
num_timesteps = padded_sequence.size(1)
flipped_padded_sequence = torch.flip(padded_sequence, [1])
sequences = [flipped_padded_sequence[i, num_timesteps - length:] for i, length in enumerate(sequence_lengths)]
return torch.nn.utils.rnn.pad_sequence(sequences, batch_first=True)
|
python
|
def masked_flip(padded_sequence: torch.Tensor,
sequence_lengths: List[int]) -> torch.Tensor:
"""
Flips a padded tensor along the time dimension without affecting masked entries.
Parameters
----------
padded_sequence : ``torch.Tensor``
The tensor to flip along the time dimension.
Assumed to be of dimensions (batch size, num timesteps, ...)
sequence_lengths : ``torch.Tensor``
A list containing the lengths of each unpadded sequence in the batch.
Returns
-------
A ``torch.Tensor`` of the same shape as padded_sequence.
"""
assert padded_sequence.size(0) == len(sequence_lengths), \
f'sequence_lengths length ${len(sequence_lengths)} does not match batch size ${padded_sequence.size(0)}'
num_timesteps = padded_sequence.size(1)
flipped_padded_sequence = torch.flip(padded_sequence, [1])
sequences = [flipped_padded_sequence[i, num_timesteps - length:] for i, length in enumerate(sequence_lengths)]
return torch.nn.utils.rnn.pad_sequence(sequences, batch_first=True)
|
[
"def",
"masked_flip",
"(",
"padded_sequence",
":",
"torch",
".",
"Tensor",
",",
"sequence_lengths",
":",
"List",
"[",
"int",
"]",
")",
"->",
"torch",
".",
"Tensor",
":",
"assert",
"padded_sequence",
".",
"size",
"(",
"0",
")",
"==",
"len",
"(",
"sequence_lengths",
")",
",",
"f'sequence_lengths length ${len(sequence_lengths)} does not match batch size ${padded_sequence.size(0)}'",
"num_timesteps",
"=",
"padded_sequence",
".",
"size",
"(",
"1",
")",
"flipped_padded_sequence",
"=",
"torch",
".",
"flip",
"(",
"padded_sequence",
",",
"[",
"1",
"]",
")",
"sequences",
"=",
"[",
"flipped_padded_sequence",
"[",
"i",
",",
"num_timesteps",
"-",
"length",
":",
"]",
"for",
"i",
",",
"length",
"in",
"enumerate",
"(",
"sequence_lengths",
")",
"]",
"return",
"torch",
".",
"nn",
".",
"utils",
".",
"rnn",
".",
"pad_sequence",
"(",
"sequences",
",",
"batch_first",
"=",
"True",
")"
] |
Flips a padded tensor along the time dimension without affecting masked entries.
Parameters
----------
padded_sequence : ``torch.Tensor``
The tensor to flip along the time dimension.
Assumed to be of dimensions (batch size, num timesteps, ...)
sequence_lengths : ``torch.Tensor``
A list containing the lengths of each unpadded sequence in the batch.
Returns
-------
A ``torch.Tensor`` of the same shape as padded_sequence.
|
[
"Flips",
"a",
"padded",
"tensor",
"along",
"the",
"time",
"dimension",
"without",
"affecting",
"masked",
"entries",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L370-L392
|
train
|
Flips a padded tensor along the time dimension without affecting masked entries.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ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b,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10100 + 0o36) + chr(0b10001 + 0o37) + '\x35', 34410 - 34402), ehT0Px3KOsy9(chr(48) + chr(111) + chr(54) + chr(1505 - 1456), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(2150 - 2097) + '\066', 0b1000), ehT0Px3KOsy9(chr(48) + chr(7039 - 6928) + chr(51) + chr(1464 - 1412) + chr(0b110 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(0b110111) + '\065', 0b1000), ehT0Px3KOsy9(chr(1370 - 1322) + '\157' + chr(0b110001) + chr(0b100000 + 0o22) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(52) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1209 - 1161) + chr(3994 - 3883) + chr(0b11 + 0o63), 38421 - 38413), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1101 + 0o45) + '\062' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + '\064' + '\x35', 23256 - 23248), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(205 - 154) + chr(0b10111 + 0o32) + chr(0b110000), 51864 - 51856), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(341 - 291) + chr(55) + chr(1895 - 1844), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(111) + '\x31' + chr(50) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(0b100101 + 0o14) + chr(51), 0o10), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + chr(0b110010) + '\x35' + '\067', 18075 - 18067), ehT0Px3KOsy9('\x30' + chr(111) + chr(1726 - 1676) + chr(0b10001 + 0o40) + chr(53), 58015 - 58007), ehT0Px3KOsy9(chr(48) + chr(5228 - 5117) + '\063' + chr(1902 - 1854), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11101 + 0o25) + chr(0b110000) + chr(365 - 315), 56941 - 56933), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + '\067' + chr(2006 - 1956), 0o10), ehT0Px3KOsy9(chr(2213 - 2165) + chr(0b111101 + 0o62) + '\x33' + chr(2438 - 2386) + '\065', 53403 - 53395), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(0b110111) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x34' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(1851 - 1796) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + '\063' + '\x31' + chr(53), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(736 - 687) + chr(0b1100 + 0o52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10199 - 10088) + '\x31' + chr(0b111 + 0o55) + '\063', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(52) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\x6f' + chr(50) + chr(0b110010) + chr(0b100111 + 0o16), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + chr(48) + chr(163 - 109), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + '\x34' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(1385 - 1274) + '\065' + chr(0b11100 + 0o30), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(1337 - 1226) + chr(163 - 109) + chr(0b111 + 0o53), 29331 - 29323), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(1140 - 1090), 32111 - 32103), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11101 + 0o24) + chr(0b100001 + 0o20) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10001 + 0o41) + chr(0b101110 + 0o11) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + chr(138 - 86) + chr(49), 7091 - 7083), ehT0Px3KOsy9(chr(48) + chr(1094 - 983) + '\063' + chr(0b110110) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\062' + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(418 - 367) + chr(1812 - 1758) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1100111 + 0o10) + chr(0b100110 + 0o13) + chr(0b110110) + '\061', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(0b101001 + 0o14) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xab'), '\144' + chr(0b1100101) + chr(0b1100011) + '\157' + chr(0b1110 + 0o126) + '\x65')('\x75' + chr(0b110110 + 0o76) + chr(1577 - 1475) + chr(604 - 559) + chr(2431 - 2375)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def gRE2a5PUmcZp(EKbgCDKoPwnL, JqDKXxFsMQp2) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1T\x00\x92\x92"'), '\x64' + chr(101) + chr(99) + chr(0b1101111) + '\144' + '\x65')(chr(1815 - 1698) + '\164' + '\146' + chr(600 - 555) + chr(56))):
assert xafqLlk3kkUe(EKbgCDKoPwnL, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcb}\r\x82\xce\x12"L\xfb4\xa3\xda'), '\144' + '\x65' + '\143' + chr(0b1101111) + chr(100) + chr(5944 - 5843))(chr(0b1110101) + chr(116) + chr(0b101001 + 0o75) + chr(0b101101) + '\070'))(ehT0Px3KOsy9(chr(268 - 220) + '\157' + '\060', 0o10)) == c2A0yzQpDQB3(JqDKXxFsMQp2), f"sequence_lengths length ${c2A0yzQpDQB3(JqDKXxFsMQp2)} does not match batch size ${xafqLlk3kkUe(EKbgCDKoPwnL, chr(0b1001110) + chr(2458 - 2382) + chr(0b1100011) + chr(0b1100011) + chr(51) + chr(0b1000010) + chr(0b1000011) + chr(2589 - 2515) + chr(10563 - 10453) + chr(1797 - 1716) + chr(7060 - 6953) + chr(8212 - 8115))(0)}"
Vh9spPt2FTTv = EKbgCDKoPwnL.NLcc3BCJnQka(ehT0Px3KOsy9('\x30' + '\x6f' + chr(49), ord("\x08")))
PJ0hlqvHy63F = cEkFpYktkSeK.mFx6gsZ1V8KW(EKbgCDKoPwnL, [ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31', 8)])
wsAG9QSgV2xG = [PJ0hlqvHy63F[WVxHKyX45z_L, Vh9spPt2FTTv - CHAOgk5VCHH_:] for (WVxHKyX45z_L, CHAOgk5VCHH_) in YlkZvXL8qwsX(JqDKXxFsMQp2)]
return xafqLlk3kkUe(cEkFpYktkSeK.nn.utils.rnn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5P\n\xbe\x8e5\x10s\xf0\x0b\xab\xde'), '\x64' + '\x65' + '\x63' + chr(0b1001110 + 0o41) + '\x64' + chr(7963 - 7862))(chr(117) + '\x74' + chr(0b11001 + 0o115) + chr(0b101101) + '\070'))(wsAG9QSgV2xG, batch_first=ehT0Px3KOsy9('\060' + chr(111) + '\x31', 8))
|
allenai/allennlp
|
allennlp/nn/util.py
|
viterbi_decode
|
def viterbi_decode(tag_sequence: torch.Tensor,
transition_matrix: torch.Tensor,
tag_observations: Optional[List[int]] = None):
"""
Perform Viterbi decoding in log space over a sequence given a transition matrix
specifying pairwise (transition) potentials between tags and a matrix of shape
(sequence_length, num_tags) specifying unary potentials for possible tags per
timestep.
Parameters
----------
tag_sequence : torch.Tensor, required.
A tensor of shape (sequence_length, num_tags) representing scores for
a set of tags over a given sequence.
transition_matrix : torch.Tensor, required.
A tensor of shape (num_tags, num_tags) representing the binary potentials
for transitioning between a given pair of tags.
tag_observations : Optional[List[int]], optional, (default = None)
A list of length ``sequence_length`` containing the class ids of observed
elements in the sequence, with unobserved elements being set to -1. Note that
it is possible to provide evidence which results in degenerate labelings if
the sequences of tags you provide as evidence cannot transition between each
other, or those transitions are extremely unlikely. In this situation we log a
warning, but the responsibility for providing self-consistent evidence ultimately
lies with the user.
Returns
-------
viterbi_path : List[int]
The tag indices of the maximum likelihood tag sequence.
viterbi_score : torch.Tensor
The score of the viterbi path.
"""
sequence_length, num_tags = list(tag_sequence.size())
if tag_observations:
if len(tag_observations) != sequence_length:
raise ConfigurationError("Observations were provided, but they were not the same length "
"as the sequence. Found sequence of length: {} and evidence: {}"
.format(sequence_length, tag_observations))
else:
tag_observations = [-1 for _ in range(sequence_length)]
path_scores = []
path_indices = []
if tag_observations[0] != -1:
one_hot = torch.zeros(num_tags)
one_hot[tag_observations[0]] = 100000.
path_scores.append(one_hot)
else:
path_scores.append(tag_sequence[0, :])
# Evaluate the scores for all possible paths.
for timestep in range(1, sequence_length):
# Add pairwise potentials to current scores.
summed_potentials = path_scores[timestep - 1].unsqueeze(-1) + transition_matrix
scores, paths = torch.max(summed_potentials, 0)
# If we have an observation for this timestep, use it
# instead of the distribution over tags.
observation = tag_observations[timestep]
# Warn the user if they have passed
# invalid/extremely unlikely evidence.
if tag_observations[timestep - 1] != -1:
if transition_matrix[tag_observations[timestep - 1], observation] < -10000:
logger.warning("The pairwise potential between tags you have passed as "
"observations is extremely unlikely. Double check your evidence "
"or transition potentials!")
if observation != -1:
one_hot = torch.zeros(num_tags)
one_hot[observation] = 100000.
path_scores.append(one_hot)
else:
path_scores.append(tag_sequence[timestep, :] + scores.squeeze())
path_indices.append(paths.squeeze())
# Construct the most likely sequence backwards.
viterbi_score, best_path = torch.max(path_scores[-1], 0)
viterbi_path = [int(best_path.numpy())]
for backward_timestep in reversed(path_indices):
viterbi_path.append(int(backward_timestep[viterbi_path[-1]]))
# Reverse the backward path.
viterbi_path.reverse()
return viterbi_path, viterbi_score
|
python
|
def viterbi_decode(tag_sequence: torch.Tensor,
transition_matrix: torch.Tensor,
tag_observations: Optional[List[int]] = None):
"""
Perform Viterbi decoding in log space over a sequence given a transition matrix
specifying pairwise (transition) potentials between tags and a matrix of shape
(sequence_length, num_tags) specifying unary potentials for possible tags per
timestep.
Parameters
----------
tag_sequence : torch.Tensor, required.
A tensor of shape (sequence_length, num_tags) representing scores for
a set of tags over a given sequence.
transition_matrix : torch.Tensor, required.
A tensor of shape (num_tags, num_tags) representing the binary potentials
for transitioning between a given pair of tags.
tag_observations : Optional[List[int]], optional, (default = None)
A list of length ``sequence_length`` containing the class ids of observed
elements in the sequence, with unobserved elements being set to -1. Note that
it is possible to provide evidence which results in degenerate labelings if
the sequences of tags you provide as evidence cannot transition between each
other, or those transitions are extremely unlikely. In this situation we log a
warning, but the responsibility for providing self-consistent evidence ultimately
lies with the user.
Returns
-------
viterbi_path : List[int]
The tag indices of the maximum likelihood tag sequence.
viterbi_score : torch.Tensor
The score of the viterbi path.
"""
sequence_length, num_tags = list(tag_sequence.size())
if tag_observations:
if len(tag_observations) != sequence_length:
raise ConfigurationError("Observations were provided, but they were not the same length "
"as the sequence. Found sequence of length: {} and evidence: {}"
.format(sequence_length, tag_observations))
else:
tag_observations = [-1 for _ in range(sequence_length)]
path_scores = []
path_indices = []
if tag_observations[0] != -1:
one_hot = torch.zeros(num_tags)
one_hot[tag_observations[0]] = 100000.
path_scores.append(one_hot)
else:
path_scores.append(tag_sequence[0, :])
# Evaluate the scores for all possible paths.
for timestep in range(1, sequence_length):
# Add pairwise potentials to current scores.
summed_potentials = path_scores[timestep - 1].unsqueeze(-1) + transition_matrix
scores, paths = torch.max(summed_potentials, 0)
# If we have an observation for this timestep, use it
# instead of the distribution over tags.
observation = tag_observations[timestep]
# Warn the user if they have passed
# invalid/extremely unlikely evidence.
if tag_observations[timestep - 1] != -1:
if transition_matrix[tag_observations[timestep - 1], observation] < -10000:
logger.warning("The pairwise potential between tags you have passed as "
"observations is extremely unlikely. Double check your evidence "
"or transition potentials!")
if observation != -1:
one_hot = torch.zeros(num_tags)
one_hot[observation] = 100000.
path_scores.append(one_hot)
else:
path_scores.append(tag_sequence[timestep, :] + scores.squeeze())
path_indices.append(paths.squeeze())
# Construct the most likely sequence backwards.
viterbi_score, best_path = torch.max(path_scores[-1], 0)
viterbi_path = [int(best_path.numpy())]
for backward_timestep in reversed(path_indices):
viterbi_path.append(int(backward_timestep[viterbi_path[-1]]))
# Reverse the backward path.
viterbi_path.reverse()
return viterbi_path, viterbi_score
|
[
"def",
"viterbi_decode",
"(",
"tag_sequence",
":",
"torch",
".",
"Tensor",
",",
"transition_matrix",
":",
"torch",
".",
"Tensor",
",",
"tag_observations",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
":",
"sequence_length",
",",
"num_tags",
"=",
"list",
"(",
"tag_sequence",
".",
"size",
"(",
")",
")",
"if",
"tag_observations",
":",
"if",
"len",
"(",
"tag_observations",
")",
"!=",
"sequence_length",
":",
"raise",
"ConfigurationError",
"(",
"\"Observations were provided, but they were not the same length \"",
"\"as the sequence. Found sequence of length: {} and evidence: {}\"",
".",
"format",
"(",
"sequence_length",
",",
"tag_observations",
")",
")",
"else",
":",
"tag_observations",
"=",
"[",
"-",
"1",
"for",
"_",
"in",
"range",
"(",
"sequence_length",
")",
"]",
"path_scores",
"=",
"[",
"]",
"path_indices",
"=",
"[",
"]",
"if",
"tag_observations",
"[",
"0",
"]",
"!=",
"-",
"1",
":",
"one_hot",
"=",
"torch",
".",
"zeros",
"(",
"num_tags",
")",
"one_hot",
"[",
"tag_observations",
"[",
"0",
"]",
"]",
"=",
"100000.",
"path_scores",
".",
"append",
"(",
"one_hot",
")",
"else",
":",
"path_scores",
".",
"append",
"(",
"tag_sequence",
"[",
"0",
",",
":",
"]",
")",
"# Evaluate the scores for all possible paths.",
"for",
"timestep",
"in",
"range",
"(",
"1",
",",
"sequence_length",
")",
":",
"# Add pairwise potentials to current scores.",
"summed_potentials",
"=",
"path_scores",
"[",
"timestep",
"-",
"1",
"]",
".",
"unsqueeze",
"(",
"-",
"1",
")",
"+",
"transition_matrix",
"scores",
",",
"paths",
"=",
"torch",
".",
"max",
"(",
"summed_potentials",
",",
"0",
")",
"# If we have an observation for this timestep, use it",
"# instead of the distribution over tags.",
"observation",
"=",
"tag_observations",
"[",
"timestep",
"]",
"# Warn the user if they have passed",
"# invalid/extremely unlikely evidence.",
"if",
"tag_observations",
"[",
"timestep",
"-",
"1",
"]",
"!=",
"-",
"1",
":",
"if",
"transition_matrix",
"[",
"tag_observations",
"[",
"timestep",
"-",
"1",
"]",
",",
"observation",
"]",
"<",
"-",
"10000",
":",
"logger",
".",
"warning",
"(",
"\"The pairwise potential between tags you have passed as \"",
"\"observations is extremely unlikely. Double check your evidence \"",
"\"or transition potentials!\"",
")",
"if",
"observation",
"!=",
"-",
"1",
":",
"one_hot",
"=",
"torch",
".",
"zeros",
"(",
"num_tags",
")",
"one_hot",
"[",
"observation",
"]",
"=",
"100000.",
"path_scores",
".",
"append",
"(",
"one_hot",
")",
"else",
":",
"path_scores",
".",
"append",
"(",
"tag_sequence",
"[",
"timestep",
",",
":",
"]",
"+",
"scores",
".",
"squeeze",
"(",
")",
")",
"path_indices",
".",
"append",
"(",
"paths",
".",
"squeeze",
"(",
")",
")",
"# Construct the most likely sequence backwards.",
"viterbi_score",
",",
"best_path",
"=",
"torch",
".",
"max",
"(",
"path_scores",
"[",
"-",
"1",
"]",
",",
"0",
")",
"viterbi_path",
"=",
"[",
"int",
"(",
"best_path",
".",
"numpy",
"(",
")",
")",
"]",
"for",
"backward_timestep",
"in",
"reversed",
"(",
"path_indices",
")",
":",
"viterbi_path",
".",
"append",
"(",
"int",
"(",
"backward_timestep",
"[",
"viterbi_path",
"[",
"-",
"1",
"]",
"]",
")",
")",
"# Reverse the backward path.",
"viterbi_path",
".",
"reverse",
"(",
")",
"return",
"viterbi_path",
",",
"viterbi_score"
] |
Perform Viterbi decoding in log space over a sequence given a transition matrix
specifying pairwise (transition) potentials between tags and a matrix of shape
(sequence_length, num_tags) specifying unary potentials for possible tags per
timestep.
Parameters
----------
tag_sequence : torch.Tensor, required.
A tensor of shape (sequence_length, num_tags) representing scores for
a set of tags over a given sequence.
transition_matrix : torch.Tensor, required.
A tensor of shape (num_tags, num_tags) representing the binary potentials
for transitioning between a given pair of tags.
tag_observations : Optional[List[int]], optional, (default = None)
A list of length ``sequence_length`` containing the class ids of observed
elements in the sequence, with unobserved elements being set to -1. Note that
it is possible to provide evidence which results in degenerate labelings if
the sequences of tags you provide as evidence cannot transition between each
other, or those transitions are extremely unlikely. In this situation we log a
warning, but the responsibility for providing self-consistent evidence ultimately
lies with the user.
Returns
-------
viterbi_path : List[int]
The tag indices of the maximum likelihood tag sequence.
viterbi_score : torch.Tensor
The score of the viterbi path.
|
[
"Perform",
"Viterbi",
"decoding",
"in",
"log",
"space",
"over",
"a",
"sequence",
"given",
"a",
"transition",
"matrix",
"specifying",
"pairwise",
"(",
"transition",
")",
"potentials",
"between",
"tags",
"and",
"a",
"matrix",
"of",
"shape",
"(",
"sequence_length",
"num_tags",
")",
"specifying",
"unary",
"potentials",
"for",
"possible",
"tags",
"per",
"timestep",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L395-L478
|
train
|
This function performs Viterbi decoding in log space over a sequence given a transition matrix and a list of unobserved tags.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3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B_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\x35' + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(592 - 544) + chr(0b11110 + 0o121) + chr(0b110011) + '\067' + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\157' + chr(49) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + chr(3496 - 3385) + chr(0b100010 + 0o20) + chr(938 - 885) + '\066', 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b101011 + 0o104) + chr(51) + chr(0b101100 + 0o6) + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(1831 - 1781) + chr(0b100111 + 0o13), 0b1000), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + '\x35' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b1101 + 0o46) + chr(563 - 510), 3194 - 3186), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\x34' + chr(0b101111 + 0o4), 33635 - 33627), ehT0Px3KOsy9(chr(48) + chr(0b1011000 + 0o27) + chr(49) + chr(625 - 572) + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1956 - 1906) + chr(0b110111) + chr(50), 0b1000), ehT0Px3KOsy9(chr(1697 - 1649) + '\x6f' + chr(0b11011 + 0o26) + chr(49) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x35' + '\061', 59350 - 59342), ehT0Px3KOsy9(chr(263 - 215) + chr(0b110111 + 0o70) + '\062' + chr(0b11101 + 0o27) + chr(51), 8), ehT0Px3KOsy9('\060' + '\x6f' + '\x35' + chr(0b110110), 56703 - 56695), ehT0Px3KOsy9(chr(48) + chr(0b1000000 + 0o57) + chr(0b110010) + chr(0b110000) + chr(48), 48683 - 48675), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(8271 - 8160) + chr(0b1111 + 0o42) + '\x31' + chr(0b100011 + 0o20), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b100101 + 0o15) + '\x34' + '\064', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x32' + '\x33' + chr(798 - 745), 8), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(48), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101010 + 0o105) + chr(393 - 344) + chr(77 - 24) + chr(0b110101), 3997 - 3989), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(1242 - 1187) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(111) + '\067' + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\064' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2487 - 2376) + '\066' + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(111) + chr(0b110001) + '\064' + chr(0b100001 + 0o25), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(50) + chr(0b1111 + 0o47) + chr(2299 - 2244), 0o10), ehT0Px3KOsy9('\x30' + chr(0b110000 + 0o77) + chr(0b110011) + chr(0b110001) + '\067', 0o10), ehT0Px3KOsy9('\x30' + chr(5326 - 5215) + chr(49) + chr(51) + '\063', 34412 - 34404), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110 + 0o55) + chr(0b10100 + 0o40) + chr(53), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(0b110010) + '\x35', 31147 - 31139), ehT0Px3KOsy9('\x30' + chr(111) + '\x30', 8), ehT0Px3KOsy9(chr(645 - 597) + chr(0b1101111) + chr(318 - 267) + chr(53), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(55) + chr(50), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x33' + chr(0b110010 + 0o1) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(5972 - 5861) + chr(0b110001) + chr(1918 - 1866) + chr(0b1111 + 0o50), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1138 - 1089) + chr(0b100000 + 0o26) + chr(0b101000 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(0b100100 + 0o14) + '\157' + chr(49) + chr(2806 - 2751) + chr(0b110110), 58587 - 58579), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\157' + chr(51) + '\061' + chr(0b110001), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1954 - 1906) + '\x6f' + '\065' + chr(48), 15203 - 15195)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'G'), chr(4081 - 3981) + '\145' + chr(0b1100011) + chr(7375 - 7264) + '\x64' + chr(0b1100101))('\x75' + '\x74' + '\x66' + chr(0b101101) + chr(0b110100 + 0o4)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def o9qQgoUKyjED(utunRCPj8Imk, VLlDuMFEemoe, O5xdP4M9uPVU=None):
(KpLkLOIdDwiZ, M0rEC8NHAN9l) = YyaZ4tpXu4lf(utunRCPj8Imk.NLcc3BCJnQka())
if O5xdP4M9uPVU:
if c2A0yzQpDQB3(O5xdP4M9uPVU) != KpLkLOIdDwiZ:
raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"&z\x8bo\xdc\xa63_\xf4\xcc\x07\xc9k^\xc6\\\xe5k\xd4\xefo\x1bSX\x82QJ\x97\xad.\x91\xf5tu\x9f\xa6G\x00\x1b\xbb\x0c8\x96e\xda\xf0&C\xf8\x83\x1a\xdb&L\x83B\xe5%\xc3\xe9hM[O\xc7A\x0e\xd2\xef(\x80\xa4ux\x94\xbc\x02Y^\x8f\x06m\x96n\x8e\xa37Z\xe8\xc6\x07\xd9.\t\xccH\xa0'\xc1\xf3g\x19R\x06\xc7N\x1b\x97\xae5\x81\xf5ek\x93\xbb\x02\x19\x1d\xacS8\x83w"), '\144' + chr(101) + chr(0b1001011 + 0o30) + chr(111) + chr(0b1100100) + chr(101))(chr(117) + chr(0b1110100) + chr(102) + chr(994 - 949) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'?,\x8ae\xe6\xb1\x01\x18\xcd\xd3\x0c\xd0'), chr(100) + '\x65' + '\x63' + '\x6f' + '\x64' + chr(2988 - 2887))(chr(117) + chr(2412 - 2296) + chr(102) + chr(1078 - 1033) + chr(1585 - 1529)))(KpLkLOIdDwiZ, O5xdP4M9uPVU))
else:
O5xdP4M9uPVU = [-ehT0Px3KOsy9('\060' + '\x6f' + '\061', 0b1000) for VNGQdHSFPrso in vQr8gNKaIaWE(KpLkLOIdDwiZ)]
SFKqa_JlmBit = []
s95gBb44VmuM = []
if O5xdP4M9uPVU[ehT0Px3KOsy9('\x30' + '\157' + '\060', 8)] != -ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b1101111) + chr(0b101101 + 0o4), 8):
Hq3fv4Yp0EhD = cEkFpYktkSeK.zeros(M0rEC8NHAN9l)
Hq3fv4Yp0EhD[O5xdP4M9uPVU[ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + chr(0b110000), 8)]] = 100000.0
xafqLlk3kkUe(SFKqa_JlmBit, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(100) + chr(101) + chr(0b1100011) + chr(6327 - 6216) + '\x64' + chr(101))(chr(0b1110101) + chr(0b1110100) + '\146' + '\x2d' + chr(0b111000)))(Hq3fv4Yp0EhD)
else:
xafqLlk3kkUe(SFKqa_JlmBit, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(0b1100100) + chr(9040 - 8939) + chr(0b100111 + 0o74) + chr(0b100000 + 0o117) + chr(9896 - 9796) + chr(0b1000011 + 0o42))('\x75' + '\x74' + chr(0b101111 + 0o67) + chr(0b101101) + chr(0b10000 + 0o50)))(utunRCPj8Imk[ehT0Px3KOsy9('\060' + chr(2864 - 2753) + chr(1065 - 1017), 8), :])
for Z8vqoCLJ58in in vQr8gNKaIaWE(ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(49), 8), KpLkLOIdDwiZ):
qA3oUjP2hhp5 = SFKqa_JlmBit[Z8vqoCLJ58in - ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001), 8)].unsqueeze(-ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(111) + chr(1697 - 1648), 8)) + VLlDuMFEemoe
(b8rpGniBNUPr, L5ghGbOkzBG7) = cEkFpYktkSeK.tsdjvlgh9gDP(qA3oUjP2hhp5, ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110000), 8))
mKQm526a9xSD = O5xdP4M9uPVU[Z8vqoCLJ58in]
if O5xdP4M9uPVU[Z8vqoCLJ58in - ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001), 8)] != -ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1773 - 1724), 8):
if VLlDuMFEemoe[O5xdP4M9uPVU[Z8vqoCLJ58in - ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(745 - 696), 8)], mKQm526a9xSD] < -ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + '\x33' + chr(2440 - 2388) + chr(0b110010) + '\x30', 0o10):
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1ey\x8ad\xc7\xbe5'), chr(7688 - 7588) + chr(0b1100101) + '\143' + chr(0b100101 + 0o112) + chr(100) + chr(101))(chr(0b101001 + 0o114) + '\164' + '\146' + chr(0b10100 + 0o31) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'=p\x9d*\xde\xb1;Y\xea\xca\x1a\xdfkY\xccZ\xe5%\xd0\xf4a\x01\x1a^\x82A\x11\xd2\xaa5\xc5\xa1az\x89\xff\x1e\x18\x0b\xe9\x01y\x8eo\x8e\xa03X\xee\xc6\r\x9a*Z\x83A\xe28\xc1\xefv\x0cNU\x88[\x15\x97\xa6(\xc5\xb0xi\x88\xba\n\x12\x12\xb0Im\x96f\xc7\xbb7G\xe4\x8dI\xfe$\\\xc1B\xe5k\xc7\xf5e\x0eQ\x1c\x9eZ\x13\xc5\xef>\x93\xbcdx\x94\xbc\x02W\x11\xbbIl\x8ak\xc0\xa3;_\xf4\xcc\x07\x9a;F\xd7K\xee?\xcd\xfcl\x1e\x1b'), chr(100) + '\x65' + '\x63' + chr(11401 - 11290) + chr(0b1100100) + chr(9803 - 9702))(chr(117) + chr(400 - 284) + chr(0b1100110) + '\x2d' + '\x38'))
if mKQm526a9xSD != -ehT0Px3KOsy9('\x30' + chr(111) + '\x31', 8):
Hq3fv4Yp0EhD = cEkFpYktkSeK.zeros(M0rEC8NHAN9l)
Hq3fv4Yp0EhD[mKQm526a9xSD] = 100000.0
xafqLlk3kkUe(SFKqa_JlmBit, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(0b1100100) + chr(2675 - 2574) + '\143' + chr(0b11000 + 0o127) + chr(100) + chr(1894 - 1793))(chr(117) + chr(5561 - 5445) + chr(0b1100110) + chr(559 - 514) + '\070'))(Hq3fv4Yp0EhD)
else:
xafqLlk3kkUe(SFKqa_JlmBit, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(100) + '\x65' + chr(0b1100011) + '\157' + '\x64' + chr(0b11100 + 0o111))(chr(117) + '\x74' + chr(0b110001 + 0o65) + chr(0b101101) + chr(56)))(utunRCPj8Imk[Z8vqoCLJ58in, :] + xafqLlk3kkUe(b8rpGniBNUPr, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1ai\x8do\xcb\xaa7'), '\x64' + chr(2501 - 2400) + '\143' + chr(0b1101111) + chr(100) + chr(101))(chr(0b1110101) + '\164' + chr(102) + '\x2d' + chr(2723 - 2667)))())
xafqLlk3kkUe(s95gBb44VmuM, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(0b1100 + 0o130) + chr(8892 - 8791) + '\143' + '\x6f' + chr(100) + '\x65')(chr(0b100111 + 0o116) + chr(116) + chr(5920 - 5818) + chr(0b101101 + 0o0) + chr(2116 - 2060)))(xafqLlk3kkUe(L5ghGbOkzBG7, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1ai\x8do\xcb\xaa7'), '\144' + chr(0b10001 + 0o124) + chr(0b1010001 + 0o22) + chr(0b110101 + 0o72) + chr(0b1100100) + chr(4740 - 4639))('\165' + chr(116) + chr(102) + '\x2d' + chr(0b10011 + 0o45)))())
(zwygoYpiuL7h, ZUB6bkGRBiag) = cEkFpYktkSeK.tsdjvlgh9gDP(SFKqa_JlmBit[-ehT0Px3KOsy9('\x30' + chr(111) + '\061', 8)], ehT0Px3KOsy9(chr(943 - 895) + chr(0b1101111) + chr(0b110000), 8))
LmaxqZ1y3RS_ = [ehT0Px3KOsy9(ZUB6bkGRBiag.numpy())]
for ouXtVkE4_uIK in RFiwrCZH9Ie6(s95gBb44VmuM):
xafqLlk3kkUe(LmaxqZ1y3RS_, xafqLlk3kkUe(SXOLrMavuUCe(b'\x08h\x88o\xc0\xb4'), chr(100) + chr(9662 - 9561) + chr(1136 - 1037) + chr(6931 - 6820) + chr(0b1100100) + chr(0b111010 + 0o53))(chr(0b1110101) + '\x74' + chr(102) + chr(0b11100 + 0o21) + chr(2548 - 2492)))(ehT0Px3KOsy9(ouXtVkE4_uIK[LmaxqZ1y3RS_[-ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100111 + 0o12), 8)]]))
xafqLlk3kkUe(LmaxqZ1y3RS_, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03H\xb0s\xc1\x99\x05j\xe5\xda \xe5'), chr(0b1100100) + '\x65' + chr(99) + chr(3869 - 3758) + chr(0b1010110 + 0o16) + chr(8699 - 8598))(chr(117) + chr(116) + chr(0b1100110) + chr(0b101101) + chr(56)))()
return (LmaxqZ1y3RS_, zwygoYpiuL7h)
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_text_field_mask
|
def get_text_field_mask(text_field_tensors: Dict[str, torch.Tensor],
num_wrapping_dims: int = 0) -> torch.LongTensor:
"""
Takes the dictionary of tensors produced by a ``TextField`` and returns a mask
with 0 where the tokens are padding, and 1 otherwise. We also handle ``TextFields``
wrapped by an arbitrary number of ``ListFields``, where the number of wrapping ``ListFields``
is given by ``num_wrapping_dims``.
If ``num_wrapping_dims == 0``, the returned mask has shape ``(batch_size, num_tokens)``.
If ``num_wrapping_dims > 0`` then the returned mask has ``num_wrapping_dims`` extra
dimensions, so the shape will be ``(batch_size, ..., num_tokens)``.
There could be several entries in the tensor dictionary with different shapes (e.g., one for
word ids, one for character ids). In order to get a token mask, we use the tensor in
the dictionary with the lowest number of dimensions. After subtracting ``num_wrapping_dims``,
if this tensor has two dimensions we assume it has shape ``(batch_size, ..., num_tokens)``,
and use it for the mask. If instead it has three dimensions, we assume it has shape
``(batch_size, ..., num_tokens, num_features)``, and sum over the last dimension to produce
the mask. Most frequently this will be a character id tensor, but it could also be a
featurized representation of each token, etc.
If the input ``text_field_tensors`` contains the "mask" key, this is returned instead of inferring the mask.
TODO(joelgrus): can we change this?
NOTE: Our functions for generating masks create torch.LongTensors, because using
torch.ByteTensors makes it easy to run into overflow errors
when doing mask manipulation, such as summing to get the lengths of sequences - see below.
>>> mask = torch.ones([260]).byte()
>>> mask.sum() # equals 260.
>>> var_mask = torch.autograd.V(mask)
>>> var_mask.sum() # equals 4, due to 8 bit precision - the sum overflows.
"""
if "mask" in text_field_tensors:
return text_field_tensors["mask"]
tensor_dims = [(tensor.dim(), tensor) for tensor in text_field_tensors.values()]
tensor_dims.sort(key=lambda x: x[0])
smallest_dim = tensor_dims[0][0] - num_wrapping_dims
if smallest_dim == 2:
token_tensor = tensor_dims[0][1]
return (token_tensor != 0).long()
elif smallest_dim == 3:
character_tensor = tensor_dims[0][1]
return ((character_tensor > 0).long().sum(dim=-1) > 0).long()
else:
raise ValueError("Expected a tensor with dimension 2 or 3, found {}".format(smallest_dim))
|
python
|
def get_text_field_mask(text_field_tensors: Dict[str, torch.Tensor],
num_wrapping_dims: int = 0) -> torch.LongTensor:
"""
Takes the dictionary of tensors produced by a ``TextField`` and returns a mask
with 0 where the tokens are padding, and 1 otherwise. We also handle ``TextFields``
wrapped by an arbitrary number of ``ListFields``, where the number of wrapping ``ListFields``
is given by ``num_wrapping_dims``.
If ``num_wrapping_dims == 0``, the returned mask has shape ``(batch_size, num_tokens)``.
If ``num_wrapping_dims > 0`` then the returned mask has ``num_wrapping_dims`` extra
dimensions, so the shape will be ``(batch_size, ..., num_tokens)``.
There could be several entries in the tensor dictionary with different shapes (e.g., one for
word ids, one for character ids). In order to get a token mask, we use the tensor in
the dictionary with the lowest number of dimensions. After subtracting ``num_wrapping_dims``,
if this tensor has two dimensions we assume it has shape ``(batch_size, ..., num_tokens)``,
and use it for the mask. If instead it has three dimensions, we assume it has shape
``(batch_size, ..., num_tokens, num_features)``, and sum over the last dimension to produce
the mask. Most frequently this will be a character id tensor, but it could also be a
featurized representation of each token, etc.
If the input ``text_field_tensors`` contains the "mask" key, this is returned instead of inferring the mask.
TODO(joelgrus): can we change this?
NOTE: Our functions for generating masks create torch.LongTensors, because using
torch.ByteTensors makes it easy to run into overflow errors
when doing mask manipulation, such as summing to get the lengths of sequences - see below.
>>> mask = torch.ones([260]).byte()
>>> mask.sum() # equals 260.
>>> var_mask = torch.autograd.V(mask)
>>> var_mask.sum() # equals 4, due to 8 bit precision - the sum overflows.
"""
if "mask" in text_field_tensors:
return text_field_tensors["mask"]
tensor_dims = [(tensor.dim(), tensor) for tensor in text_field_tensors.values()]
tensor_dims.sort(key=lambda x: x[0])
smallest_dim = tensor_dims[0][0] - num_wrapping_dims
if smallest_dim == 2:
token_tensor = tensor_dims[0][1]
return (token_tensor != 0).long()
elif smallest_dim == 3:
character_tensor = tensor_dims[0][1]
return ((character_tensor > 0).long().sum(dim=-1) > 0).long()
else:
raise ValueError("Expected a tensor with dimension 2 or 3, found {}".format(smallest_dim))
|
[
"def",
"get_text_field_mask",
"(",
"text_field_tensors",
":",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
",",
"num_wrapping_dims",
":",
"int",
"=",
"0",
")",
"->",
"torch",
".",
"LongTensor",
":",
"if",
"\"mask\"",
"in",
"text_field_tensors",
":",
"return",
"text_field_tensors",
"[",
"\"mask\"",
"]",
"tensor_dims",
"=",
"[",
"(",
"tensor",
".",
"dim",
"(",
")",
",",
"tensor",
")",
"for",
"tensor",
"in",
"text_field_tensors",
".",
"values",
"(",
")",
"]",
"tensor_dims",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"0",
"]",
")",
"smallest_dim",
"=",
"tensor_dims",
"[",
"0",
"]",
"[",
"0",
"]",
"-",
"num_wrapping_dims",
"if",
"smallest_dim",
"==",
"2",
":",
"token_tensor",
"=",
"tensor_dims",
"[",
"0",
"]",
"[",
"1",
"]",
"return",
"(",
"token_tensor",
"!=",
"0",
")",
".",
"long",
"(",
")",
"elif",
"smallest_dim",
"==",
"3",
":",
"character_tensor",
"=",
"tensor_dims",
"[",
"0",
"]",
"[",
"1",
"]",
"return",
"(",
"(",
"character_tensor",
">",
"0",
")",
".",
"long",
"(",
")",
".",
"sum",
"(",
"dim",
"=",
"-",
"1",
")",
">",
"0",
")",
".",
"long",
"(",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Expected a tensor with dimension 2 or 3, found {}\"",
".",
"format",
"(",
"smallest_dim",
")",
")"
] |
Takes the dictionary of tensors produced by a ``TextField`` and returns a mask
with 0 where the tokens are padding, and 1 otherwise. We also handle ``TextFields``
wrapped by an arbitrary number of ``ListFields``, where the number of wrapping ``ListFields``
is given by ``num_wrapping_dims``.
If ``num_wrapping_dims == 0``, the returned mask has shape ``(batch_size, num_tokens)``.
If ``num_wrapping_dims > 0`` then the returned mask has ``num_wrapping_dims`` extra
dimensions, so the shape will be ``(batch_size, ..., num_tokens)``.
There could be several entries in the tensor dictionary with different shapes (e.g., one for
word ids, one for character ids). In order to get a token mask, we use the tensor in
the dictionary with the lowest number of dimensions. After subtracting ``num_wrapping_dims``,
if this tensor has two dimensions we assume it has shape ``(batch_size, ..., num_tokens)``,
and use it for the mask. If instead it has three dimensions, we assume it has shape
``(batch_size, ..., num_tokens, num_features)``, and sum over the last dimension to produce
the mask. Most frequently this will be a character id tensor, but it could also be a
featurized representation of each token, etc.
If the input ``text_field_tensors`` contains the "mask" key, this is returned instead of inferring the mask.
TODO(joelgrus): can we change this?
NOTE: Our functions for generating masks create torch.LongTensors, because using
torch.ByteTensors makes it easy to run into overflow errors
when doing mask manipulation, such as summing to get the lengths of sequences - see below.
>>> mask = torch.ones([260]).byte()
>>> mask.sum() # equals 260.
>>> var_mask = torch.autograd.V(mask)
>>> var_mask.sum() # equals 4, due to 8 bit precision - the sum overflows.
|
[
"Takes",
"the",
"dictionary",
"of",
"tensors",
"produced",
"by",
"a",
"TextField",
"and",
"returns",
"a",
"mask",
"with",
"0",
"where",
"the",
"tokens",
"are",
"padding",
"and",
"1",
"otherwise",
".",
"We",
"also",
"handle",
"TextFields",
"wrapped",
"by",
"an",
"arbitrary",
"number",
"of",
"ListFields",
"where",
"the",
"number",
"of",
"wrapping",
"ListFields",
"is",
"given",
"by",
"num_wrapping_dims",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L481-L527
|
train
|
Takes a dictionary of text field tensors produced by a TextField and returns a mask of the same length as the input text_field_tensors.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,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40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(1891 - 1837) + chr(0b110 + 0o61), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111101 + 0o62) + chr(0b11101 + 0o24) + '\x32' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1010 + 0o47) + chr(507 - 459) + chr(53), 62705 - 62697), ehT0Px3KOsy9('\x30' + chr(1065 - 954) + chr(848 - 799) + chr(0b110100 + 0o3) + chr(1786 - 1735), 57858 - 57850), ehT0Px3KOsy9(chr(1879 - 1831) + '\157' + chr(0b1110 + 0o43) + chr(53) + chr(52), ord("\x08")), ehT0Px3KOsy9('\060' + chr(10340 - 10229) + '\x32' + '\x33' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + chr(0b110101) + '\x36', 42560 - 42552), ehT0Px3KOsy9(chr(1863 - 1815) + chr(9347 - 9236) + '\x33' + chr(0b110101) + '\x31', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(2526 - 2475) + '\066', 0o10), ehT0Px3KOsy9(chr(2181 - 2133) + chr(0b1101111) + '\x32' + '\067', 0b1000), ehT0Px3KOsy9(chr(2258 - 2210) + chr(111) + '\x31' + chr(0b11110 + 0o27) + '\066', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1902 - 1851) + '\066' + chr(51), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10100 + 0o37) + chr(1180 - 1128) + chr(49), 0o10), ehT0Px3KOsy9(chr(1295 - 1247) + chr(4299 - 4188) + '\x32' + '\x31' + chr(0b101000 + 0o14), 24390 - 24382), ehT0Px3KOsy9(chr(48) + chr(353 - 242) + '\x32' + chr(0b101011 + 0o7) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(7098 - 6987) + chr(0b100000 + 0o23) + chr(0b11110 + 0o27) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + '\x36' + chr(49), 55648 - 55640), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100011 + 0o16) + '\x32' + chr(0b1101 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11611 - 11500) + chr(50) + '\064' + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1110 + 0o141) + '\x31' + chr(54) + chr(53), 0o10), ehT0Px3KOsy9(chr(357 - 309) + chr(5306 - 5195) + '\060', 46469 - 46461), ehT0Px3KOsy9(chr(48) + chr(6413 - 6302) + chr(50) + '\066' + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + '\x36' + '\x34', 64166 - 64158), ehT0Px3KOsy9(chr(901 - 853) + chr(9370 - 9259) + chr(0b1110 + 0o43) + chr(0b1001 + 0o55), ord("\x08")), ehT0Px3KOsy9(chr(1255 - 1207) + chr(0b1101111) + chr(832 - 783) + chr(281 - 226), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(48), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1010 + 0o50) + '\067' + chr(0b110000), 33294 - 33286), ehT0Px3KOsy9(chr(48) + '\157' + chr(937 - 888) + chr(55) + chr(571 - 520), 8), ehT0Px3KOsy9(chr(77 - 29) + chr(0b1101111) + chr(0b110011) + chr(2142 - 2087), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(1896 - 1844) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1568 - 1518) + chr(1174 - 1123), 0b1000), ehT0Px3KOsy9(chr(48) + chr(8880 - 8769) + chr(55) + '\x34', 14780 - 14772), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + '\x35' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(53) + chr(49), 35007 - 34999), ehT0Px3KOsy9(chr(0b110000) + chr(924 - 813) + '\x32' + chr(0b10010 + 0o41) + chr(0b110 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100000 + 0o22) + chr(0b11110 + 0o26) + chr(0b10011 + 0o37), 0o10), ehT0Px3KOsy9('\060' + chr(0b1010010 + 0o35) + '\063' + '\060' + chr(1211 - 1163), 31618 - 31610), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(51) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b11001 + 0o126) + '\063' + chr(0b110100), 10622 - 10614)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1000100 + 0o53) + chr(0b11111 + 0o26) + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'*'), chr(0b0 + 0o144) + chr(3092 - 2991) + chr(0b1000101 + 0o36) + chr(5697 - 5586) + chr(100) + '\x65')(chr(117) + '\164' + chr(0b1100110) + chr(45) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def UYWjw0AI483q(ZokENiRu8w1Z, jnSNAq6HERT5=ehT0Px3KOsy9(chr(408 - 360) + chr(0b1101111) + chr(48), 8)) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'H\x18?"/\t\xf3]\x86,'), chr(1065 - 965) + chr(0b1100101) + '\143' + '\157' + chr(0b1100100) + '\x65')(chr(13253 - 13136) + chr(0b110 + 0o156) + chr(102) + '\055' + chr(2837 - 2781))):
if xafqLlk3kkUe(SXOLrMavuUCe(b'i\x16".'), chr(0b1100001 + 0o3) + chr(7045 - 6944) + chr(0b100110 + 0o75) + '\157' + chr(9991 - 9891) + chr(8262 - 8161))(chr(0b11110 + 0o127) + chr(0b10100 + 0o140) + '\x66' + '\x2d' + chr(0b111000)) in ZokENiRu8w1Z:
return ZokENiRu8w1Z[xafqLlk3kkUe(SXOLrMavuUCe(b'i\x16".'), chr(0b1100011 + 0o1) + '\x65' + chr(0b1011010 + 0o11) + '\157' + chr(0b1001111 + 0o25) + chr(101))('\x75' + chr(0b1110100) + chr(8271 - 8169) + '\055' + chr(56))]
SV4v0kTvZfE2 = [(LK3cpXJU3UM0.dim(), LK3cpXJU3UM0) for LK3cpXJU3UM0 in ZokENiRu8w1Z.SPnCNu54H1db()]
xafqLlk3kkUe(SV4v0kTvZfE2, xafqLlk3kkUe(SXOLrMavuUCe(b'w\x18#1'), chr(4548 - 4448) + chr(101) + chr(0b1100011) + '\x6f' + chr(100) + '\x65')('\x75' + chr(6737 - 6621) + chr(0b1100110) + '\x2d' + chr(0b111000)))(key=lambda OeWW0F1dBPRQ: OeWW0F1dBPRQ[ehT0Px3KOsy9(chr(1367 - 1319) + chr(6410 - 6299) + chr(896 - 848), 8)])
wSqSBf8rQuHX = SV4v0kTvZfE2[ehT0Px3KOsy9(chr(2008 - 1960) + '\157' + chr(0b110000), 8)][ehT0Px3KOsy9(chr(562 - 514) + chr(111) + '\060', 8)] - jnSNAq6HERT5
if wSqSBf8rQuHX == ehT0Px3KOsy9('\060' + '\157' + chr(0b110010), 0o10):
RT0bjuN5QN5J = SV4v0kTvZfE2[ehT0Px3KOsy9('\x30' + chr(10549 - 10438) + chr(48), 8)][ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + chr(49), 0b1000)]
return xafqLlk3kkUe(RT0bjuN5QN5J != ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\060', 8), xafqLlk3kkUe(SXOLrMavuUCe(b'h\x18?"'), '\144' + chr(101) + chr(2121 - 2022) + chr(0b1100000 + 0o17) + chr(100) + chr(0b11000 + 0o115))(chr(4310 - 4193) + chr(116) + '\146' + chr(0b101101) + '\x38'))()
elif wSqSBf8rQuHX == ehT0Px3KOsy9('\060' + chr(0b1010100 + 0o33) + chr(0b110011), 27543 - 27535):
NWnj_nSiNM9U = SV4v0kTvZfE2[ehT0Px3KOsy9(chr(847 - 799) + chr(111) + chr(0b110000), 8)][ehT0Px3KOsy9(chr(1451 - 1403) + '\x6f' + '\061', 8)]
return xafqLlk3kkUe((NWnj_nSiNM9U > ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(48), 8)).long().sum(dim=-ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + '\x31', 8)) > ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(0b110000), 8), xafqLlk3kkUe(SXOLrMavuUCe(b'h\x18?"'), '\x64' + chr(0b1001011 + 0o32) + chr(4732 - 4633) + chr(0b1000 + 0o147) + chr(100) + '\145')('\x75' + '\164' + chr(0b1100110) + chr(45) + chr(56)))()
else:
raise q1QCh3W88sgk(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'A\x0f! \x18\x18\xf8J\xc9?7\x1a\x96\x8f\xff\xff\x9a\xd1$\xc9\x01h\x94\x90gbe\xd6\x08v\n}\x1c\x99\t\xf6\xd0\xe0\xad0$\x11>0\x15\x08\xbdU\x94'), '\144' + chr(0b1000101 + 0o40) + chr(99) + '\157' + '\x64' + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + chr(45) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'RC#*3\r\xce\x1d\xb9.r\x04'), chr(100) + '\145' + chr(99) + '\x6f' + chr(3438 - 3338) + chr(101))('\165' + chr(2799 - 2683) + '\146' + chr(0b101101) + chr(56)))(wSqSBf8rQuHX))
|
allenai/allennlp
|
allennlp/nn/util.py
|
weighted_sum
|
def weighted_sum(matrix: torch.Tensor, attention: torch.Tensor) -> torch.Tensor:
"""
Takes a matrix of vectors and a set of weights over the rows in the matrix (which we call an
"attention" vector), and returns a weighted sum of the rows in the matrix. This is the typical
computation performed after an attention mechanism.
Note that while we call this a "matrix" of vectors and an attention "vector", we also handle
higher-order tensors. We always sum over the second-to-last dimension of the "matrix", and we
assume that all dimensions in the "matrix" prior to the last dimension are matched in the
"vector". Non-matched dimensions in the "vector" must be `directly after the batch dimension`.
For example, say I have a "matrix" with dimensions ``(batch_size, num_queries, num_words,
embedding_dim)``. The attention "vector" then must have at least those dimensions, and could
have more. Both:
- ``(batch_size, num_queries, num_words)`` (distribution over words for each query)
- ``(batch_size, num_documents, num_queries, num_words)`` (distribution over words in a
query for each document)
are valid input "vectors", producing tensors of shape:
``(batch_size, num_queries, embedding_dim)`` and
``(batch_size, num_documents, num_queries, embedding_dim)`` respectively.
"""
# We'll special-case a few settings here, where there are efficient (but poorly-named)
# operations in pytorch that already do the computation we need.
if attention.dim() == 2 and matrix.dim() == 3:
return attention.unsqueeze(1).bmm(matrix).squeeze(1)
if attention.dim() == 3 and matrix.dim() == 3:
return attention.bmm(matrix)
if matrix.dim() - 1 < attention.dim():
expanded_size = list(matrix.size())
for i in range(attention.dim() - matrix.dim() + 1):
matrix = matrix.unsqueeze(1)
expanded_size.insert(i + 1, attention.size(i + 1))
matrix = matrix.expand(*expanded_size)
intermediate = attention.unsqueeze(-1).expand_as(matrix) * matrix
return intermediate.sum(dim=-2)
|
python
|
def weighted_sum(matrix: torch.Tensor, attention: torch.Tensor) -> torch.Tensor:
"""
Takes a matrix of vectors and a set of weights over the rows in the matrix (which we call an
"attention" vector), and returns a weighted sum of the rows in the matrix. This is the typical
computation performed after an attention mechanism.
Note that while we call this a "matrix" of vectors and an attention "vector", we also handle
higher-order tensors. We always sum over the second-to-last dimension of the "matrix", and we
assume that all dimensions in the "matrix" prior to the last dimension are matched in the
"vector". Non-matched dimensions in the "vector" must be `directly after the batch dimension`.
For example, say I have a "matrix" with dimensions ``(batch_size, num_queries, num_words,
embedding_dim)``. The attention "vector" then must have at least those dimensions, and could
have more. Both:
- ``(batch_size, num_queries, num_words)`` (distribution over words for each query)
- ``(batch_size, num_documents, num_queries, num_words)`` (distribution over words in a
query for each document)
are valid input "vectors", producing tensors of shape:
``(batch_size, num_queries, embedding_dim)`` and
``(batch_size, num_documents, num_queries, embedding_dim)`` respectively.
"""
# We'll special-case a few settings here, where there are efficient (but poorly-named)
# operations in pytorch that already do the computation we need.
if attention.dim() == 2 and matrix.dim() == 3:
return attention.unsqueeze(1).bmm(matrix).squeeze(1)
if attention.dim() == 3 and matrix.dim() == 3:
return attention.bmm(matrix)
if matrix.dim() - 1 < attention.dim():
expanded_size = list(matrix.size())
for i in range(attention.dim() - matrix.dim() + 1):
matrix = matrix.unsqueeze(1)
expanded_size.insert(i + 1, attention.size(i + 1))
matrix = matrix.expand(*expanded_size)
intermediate = attention.unsqueeze(-1).expand_as(matrix) * matrix
return intermediate.sum(dim=-2)
|
[
"def",
"weighted_sum",
"(",
"matrix",
":",
"torch",
".",
"Tensor",
",",
"attention",
":",
"torch",
".",
"Tensor",
")",
"->",
"torch",
".",
"Tensor",
":",
"# We'll special-case a few settings here, where there are efficient (but poorly-named)",
"# operations in pytorch that already do the computation we need.",
"if",
"attention",
".",
"dim",
"(",
")",
"==",
"2",
"and",
"matrix",
".",
"dim",
"(",
")",
"==",
"3",
":",
"return",
"attention",
".",
"unsqueeze",
"(",
"1",
")",
".",
"bmm",
"(",
"matrix",
")",
".",
"squeeze",
"(",
"1",
")",
"if",
"attention",
".",
"dim",
"(",
")",
"==",
"3",
"and",
"matrix",
".",
"dim",
"(",
")",
"==",
"3",
":",
"return",
"attention",
".",
"bmm",
"(",
"matrix",
")",
"if",
"matrix",
".",
"dim",
"(",
")",
"-",
"1",
"<",
"attention",
".",
"dim",
"(",
")",
":",
"expanded_size",
"=",
"list",
"(",
"matrix",
".",
"size",
"(",
")",
")",
"for",
"i",
"in",
"range",
"(",
"attention",
".",
"dim",
"(",
")",
"-",
"matrix",
".",
"dim",
"(",
")",
"+",
"1",
")",
":",
"matrix",
"=",
"matrix",
".",
"unsqueeze",
"(",
"1",
")",
"expanded_size",
".",
"insert",
"(",
"i",
"+",
"1",
",",
"attention",
".",
"size",
"(",
"i",
"+",
"1",
")",
")",
"matrix",
"=",
"matrix",
".",
"expand",
"(",
"*",
"expanded_size",
")",
"intermediate",
"=",
"attention",
".",
"unsqueeze",
"(",
"-",
"1",
")",
".",
"expand_as",
"(",
"matrix",
")",
"*",
"matrix",
"return",
"intermediate",
".",
"sum",
"(",
"dim",
"=",
"-",
"2",
")"
] |
Takes a matrix of vectors and a set of weights over the rows in the matrix (which we call an
"attention" vector), and returns a weighted sum of the rows in the matrix. This is the typical
computation performed after an attention mechanism.
Note that while we call this a "matrix" of vectors and an attention "vector", we also handle
higher-order tensors. We always sum over the second-to-last dimension of the "matrix", and we
assume that all dimensions in the "matrix" prior to the last dimension are matched in the
"vector". Non-matched dimensions in the "vector" must be `directly after the batch dimension`.
For example, say I have a "matrix" with dimensions ``(batch_size, num_queries, num_words,
embedding_dim)``. The attention "vector" then must have at least those dimensions, and could
have more. Both:
- ``(batch_size, num_queries, num_words)`` (distribution over words for each query)
- ``(batch_size, num_documents, num_queries, num_words)`` (distribution over words in a
query for each document)
are valid input "vectors", producing tensors of shape:
``(batch_size, num_queries, embedding_dim)`` and
``(batch_size, num_documents, num_queries, embedding_dim)`` respectively.
|
[
"Takes",
"a",
"matrix",
"of",
"vectors",
"and",
"a",
"set",
"of",
"weights",
"over",
"the",
"rows",
"in",
"the",
"matrix",
"(",
"which",
"we",
"call",
"an",
"attention",
"vector",
")",
"and",
"returns",
"a",
"weighted",
"sum",
"of",
"the",
"rows",
"in",
"the",
"matrix",
".",
"This",
"is",
"the",
"typical",
"computation",
"performed",
"after",
"an",
"attention",
"mechanism",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L530-L566
|
train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zwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(744 - 696) + chr(5395 - 5284) + chr(0b110011) + chr(2441 - 2390) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(742 - 694) + '\x6f' + chr(0b110001) + chr(2255 - 2201) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(182 - 134) + chr(111) + '\x35' + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1000100 + 0o53) + chr(2435 - 2385) + '\x34' + chr(51), 50326 - 50318), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + chr(2622 - 2568) + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + chr(0b101111 + 0o3) + '\063' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100110 + 0o111) + '\x32' + chr(54) + '\062', 7480 - 7472), ehT0Px3KOsy9(chr(2005 - 1957) + chr(111) + chr(0b110010) + chr(49) + '\x33', 38962 - 38954), ehT0Px3KOsy9(chr(0b110000) + chr(4715 - 4604) + '\x31' + chr(0b11000 + 0o35) + chr(0b110011), 60973 - 60965), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + '\x35' + '\066', 55160 - 55152), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(0b110110) + chr(53), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(0b110010) + chr(0b110101), 31408 - 31400), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1101111 + 0o0) + '\067' + chr(48), 18961 - 18953), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + chr(0b101010 + 0o12) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1101111) + '\066' + chr(0b100100 + 0o23), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b100001 + 0o116) + '\062' + chr(49) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2488 - 2377) + chr(0b110110), 21289 - 21281), ehT0Px3KOsy9(chr(1493 - 1445) + '\157' + chr(1565 - 1515) + chr(50) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(568 - 520) + chr(0b1000000 + 0o57) + chr(0b110010) + '\060' + '\061', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b0 + 0o61) + chr(52) + chr(0b10 + 0o60), 0o10), ehT0Px3KOsy9(chr(1128 - 1080) + '\157' + chr(0b110111) + '\060', 8), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(111) + chr(0b101001 + 0o14) + '\x36', 8), ehT0Px3KOsy9('\060' + chr(3487 - 3376) + chr(0b110011) + chr(0b1101 + 0o47), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10000 + 0o137) + chr(1500 - 1450) + '\063' + chr(0b101 + 0o55), 41150 - 41142), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b110001 + 0o76) + chr(0b10010 + 0o37) + chr(964 - 916) + '\x31', 45020 - 45012), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1101011 + 0o4) + chr(1932 - 1878) + '\x33', 33272 - 33264), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(111) + '\064' + chr(1898 - 1845), ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(111) + '\063' + chr(52) + chr(0b1000 + 0o57), 0b1000), ehT0Px3KOsy9(chr(1276 - 1228) + chr(11631 - 11520) + '\061' + '\x34' + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(621 - 572) + '\066', 24917 - 24909), ehT0Px3KOsy9(chr(0b110000) + chr(0b101000 + 0o107) + '\067' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(425 - 377) + chr(9245 - 9134) + chr(0b1 + 0o61) + '\x37' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\x33' + '\x37', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110010) + '\060' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1111 + 0o43) + '\064' + chr(0b110011 + 0o0), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100010 + 0o20) + '\067' + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + chr(0b1110 + 0o45) + '\x34' + chr(335 - 280), 8), ehT0Px3KOsy9('\060' + chr(1477 - 1366) + chr(2593 - 2542) + chr(49) + chr(0b110001), 51686 - 51678), ehT0Px3KOsy9(chr(48) + chr(5764 - 5653) + '\x31' + chr(48) + '\x36', 57957 - 57949)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x35' + chr(1779 - 1731), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(0b1100000 + 0o4) + chr(3038 - 2937) + '\143' + chr(0b1010000 + 0o37) + '\144' + chr(0b1100101))(chr(0b1100110 + 0o17) + chr(0b1110100) + chr(0b101010 + 0o74) + chr(0b100 + 0o51) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def _IesAG3Q_7pi(SXiupr_NPiu8, iJflGWIA0tgf) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x89\x17B\xd0\x1a\xee'), '\144' + chr(0b110100 + 0o61) + chr(0b110110 + 0o55) + chr(145 - 34) + '\x64' + chr(101))(chr(0b11001 + 0o134) + '\164' + '\x66' + chr(45) + '\x38')):
if xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), chr(100) + chr(101) + '\143' + chr(0b1101111) + '\144' + chr(101))(chr(0b111000 + 0o75) + chr(0b10100 + 0o140) + chr(102) + chr(0b101101) + chr(0b100100 + 0o24)))() == ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b1101111) + chr(0b10111 + 0o33), ord("\x08")) and xafqLlk3kkUe(SXiupr_NPiu8, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), '\144' + chr(0b1100101) + chr(99) + '\157' + chr(100) + chr(101))('\165' + '\164' + chr(6177 - 6075) + chr(1969 - 1924) + chr(3059 - 3003)))() == ehT0Px3KOsy9(chr(48) + '\157' + '\063', 40142 - 40134):
return xafqLlk3kkUe(iJflGWIA0tgf.unsqueeze(ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49), 0o10)).bmm(SXiupr_NPiu8), xafqLlk3kkUe(SXOLrMavuUCe(b'\xae\x03Y\xc6\x10\xe6\xd7'), chr(100) + chr(382 - 281) + '\x63' + chr(0b1101111) + chr(0b1100100) + '\x65')(chr(0b1110101) + '\x74' + chr(102) + chr(0b10001 + 0o34) + chr(56)))(ehT0Px3KOsy9('\x30' + chr(1556 - 1445) + chr(1755 - 1706), 8))
if xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), chr(6816 - 6716) + chr(101) + '\143' + '\157' + chr(100) + '\145')(chr(0b110000 + 0o105) + chr(116) + '\x66' + '\x2d' + chr(0b11101 + 0o33)))() == ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33', 8) and xafqLlk3kkUe(SXiupr_NPiu8, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), chr(0b1100100) + '\145' + chr(0b111100 + 0o47) + '\x6f' + '\144' + '\x65')(chr(0b110011 + 0o102) + '\x74' + chr(0b1000111 + 0o37) + chr(0b101101) + '\x38'))() == ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(111) + '\x33', 8):
return xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbf\x1fA'), '\144' + chr(101) + chr(0b1000000 + 0o43) + chr(2019 - 1908) + '\144' + chr(0b11111 + 0o106))('\165' + '\164' + '\x66' + chr(0b101101) + '\x38'))(SXiupr_NPiu8)
if xafqLlk3kkUe(SXiupr_NPiu8, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), chr(100) + chr(0b1100101) + chr(0b1010111 + 0o14) + chr(0b1101111) + '\144' + '\145')('\x75' + chr(116) + chr(0b1100110) + '\055' + '\x38'))() - ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1475 - 1426), 8) < xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), chr(0b100000 + 0o104) + chr(8310 - 8209) + chr(0b10101 + 0o116) + chr(0b1101111) + chr(100) + '\x65')(chr(0b11110 + 0o127) + '\x74' + '\x66' + chr(1740 - 1695) + chr(56)))():
J9NCZQz0HTiV = YyaZ4tpXu4lf(SXiupr_NPiu8.NLcc3BCJnQka())
for WVxHKyX45z_L in vQr8gNKaIaWE(xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), '\144' + '\145' + chr(0b10010 + 0o121) + chr(111) + '\144' + chr(0b110011 + 0o62))(chr(13057 - 12940) + chr(4157 - 4041) + chr(6317 - 6215) + '\x2d' + chr(0b10000 + 0o50)))() - xafqLlk3kkUe(SXiupr_NPiu8, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\x1bA'), '\x64' + chr(101) + '\x63' + chr(111) + chr(100) + chr(9001 - 8900))('\165' + '\x74' + chr(102) + chr(346 - 301) + '\x38'))() + ehT0Px3KOsy9(chr(1333 - 1285) + chr(0b1101111) + '\x31', 8)):
SXiupr_NPiu8 = SXiupr_NPiu8.unsqueeze(ehT0Px3KOsy9('\x30' + chr(111) + '\061', 8))
xafqLlk3kkUe(J9NCZQz0HTiV, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb4\x1c_\xc6\x07\xe8'), '\144' + '\x65' + '\x63' + chr(0b1101111) + chr(3661 - 3561) + chr(5230 - 5129))(chr(0b1101101 + 0o10) + chr(0b111000 + 0o74) + chr(0b1001110 + 0o30) + chr(0b101101) + chr(0b111000)))(WVxHKyX45z_L + ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31', 8), xafqLlk3kkUe(iJflGWIA0tgf, xafqLlk3kkUe(SXOLrMavuUCe(b'\x93>O\xc0F\xde\xf1\xc1\x05FE\xd4'), '\x64' + chr(7381 - 7280) + chr(99) + '\x6f' + chr(100) + chr(101))(chr(0b1110101) + '\164' + chr(102) + '\x2d' + '\x38'))(WVxHKyX45z_L + ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11010 + 0o27), 8)))
SXiupr_NPiu8 = SXiupr_NPiu8.expand(*J9NCZQz0HTiV)
DtCubB1K3kEU = iJflGWIA0tgf.unsqueeze(-ehT0Px3KOsy9('\x30' + '\157' + '\x31', 8)).expand_as(SXiupr_NPiu8) * SXiupr_NPiu8
return xafqLlk3kkUe(DtCubB1K3kEU, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa5\x19T\xe1\x18\xf3\x86\xb2\x13%o\xdb'), chr(0b1100 + 0o130) + chr(0b1100101) + chr(6443 - 6344) + chr(0b1101111) + chr(100) + '\145')(chr(117) + '\x74' + '\146' + chr(0b1000 + 0o45) + chr(0b111000)))(dim=-ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11011 + 0o27), 8))
|
allenai/allennlp
|
allennlp/nn/util.py
|
sequence_cross_entropy_with_logits
|
def sequence_cross_entropy_with_logits(logits: torch.FloatTensor,
targets: torch.LongTensor,
weights: torch.FloatTensor,
average: str = "batch",
label_smoothing: float = None) -> torch.FloatTensor:
"""
Computes the cross entropy loss of a sequence, weighted with respect to
some user provided weights. Note that the weighting here is not the same as
in the :func:`torch.nn.CrossEntropyLoss()` criterion, which is weighting
classes; here we are weighting the loss contribution from particular elements
in the sequence. This allows loss computations for models which use padding.
Parameters
----------
logits : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch_size, sequence_length, num_classes)
which contains the unnormalized probability for each class.
targets : ``torch.LongTensor``, required.
A ``torch.LongTensor`` of size (batch, sequence_length) which contains the
index of the true class for each corresponding step.
weights : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch, sequence_length)
average: str, optional (default = "batch")
If "batch", average the loss across the batches. If "token", average
the loss across each item in the input. If ``None``, return a vector
of losses per batch element.
label_smoothing : ``float``, optional (default = None)
Whether or not to apply label smoothing to the cross-entropy loss.
For example, with a label smoothing value of 0.2, a 4 class classification
target would look like ``[0.05, 0.05, 0.85, 0.05]`` if the 3rd class was
the correct label.
Returns
-------
A torch.FloatTensor representing the cross entropy loss.
If ``average=="batch"`` or ``average=="token"``, the returned loss is a scalar.
If ``average is None``, the returned loss is a vector of shape (batch_size,).
"""
if average not in {None, "token", "batch"}:
raise ValueError("Got average f{average}, expected one of "
"None, 'token', or 'batch'")
# shape : (batch * sequence_length, num_classes)
logits_flat = logits.view(-1, logits.size(-1))
# shape : (batch * sequence_length, num_classes)
log_probs_flat = torch.nn.functional.log_softmax(logits_flat, dim=-1)
# shape : (batch * max_len, 1)
targets_flat = targets.view(-1, 1).long()
if label_smoothing is not None and label_smoothing > 0.0:
num_classes = logits.size(-1)
smoothing_value = label_smoothing / num_classes
# Fill all the correct indices with 1 - smoothing value.
one_hot_targets = torch.zeros_like(log_probs_flat).scatter_(-1, targets_flat, 1.0 - label_smoothing)
smoothed_targets = one_hot_targets + smoothing_value
negative_log_likelihood_flat = - log_probs_flat * smoothed_targets
negative_log_likelihood_flat = negative_log_likelihood_flat.sum(-1, keepdim=True)
else:
# Contribution to the negative log likelihood only comes from the exact indices
# of the targets, as the target distributions are one-hot. Here we use torch.gather
# to extract the indices of the num_classes dimension which contribute to the loss.
# shape : (batch * sequence_length, 1)
negative_log_likelihood_flat = - torch.gather(log_probs_flat, dim=1, index=targets_flat)
# shape : (batch, sequence_length)
negative_log_likelihood = negative_log_likelihood_flat.view(*targets.size())
# shape : (batch, sequence_length)
negative_log_likelihood = negative_log_likelihood * weights.float()
if average == "batch":
# shape : (batch_size,)
per_batch_loss = negative_log_likelihood.sum(1) / (weights.sum(1).float() + 1e-13)
num_non_empty_sequences = ((weights.sum(1) > 0).float().sum() + 1e-13)
return per_batch_loss.sum() / num_non_empty_sequences
elif average == "token":
return negative_log_likelihood.sum() / (weights.sum().float() + 1e-13)
else:
# shape : (batch_size,)
per_batch_loss = negative_log_likelihood.sum(1) / (weights.sum(1).float() + 1e-13)
return per_batch_loss
|
python
|
def sequence_cross_entropy_with_logits(logits: torch.FloatTensor,
targets: torch.LongTensor,
weights: torch.FloatTensor,
average: str = "batch",
label_smoothing: float = None) -> torch.FloatTensor:
"""
Computes the cross entropy loss of a sequence, weighted with respect to
some user provided weights. Note that the weighting here is not the same as
in the :func:`torch.nn.CrossEntropyLoss()` criterion, which is weighting
classes; here we are weighting the loss contribution from particular elements
in the sequence. This allows loss computations for models which use padding.
Parameters
----------
logits : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch_size, sequence_length, num_classes)
which contains the unnormalized probability for each class.
targets : ``torch.LongTensor``, required.
A ``torch.LongTensor`` of size (batch, sequence_length) which contains the
index of the true class for each corresponding step.
weights : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch, sequence_length)
average: str, optional (default = "batch")
If "batch", average the loss across the batches. If "token", average
the loss across each item in the input. If ``None``, return a vector
of losses per batch element.
label_smoothing : ``float``, optional (default = None)
Whether or not to apply label smoothing to the cross-entropy loss.
For example, with a label smoothing value of 0.2, a 4 class classification
target would look like ``[0.05, 0.05, 0.85, 0.05]`` if the 3rd class was
the correct label.
Returns
-------
A torch.FloatTensor representing the cross entropy loss.
If ``average=="batch"`` or ``average=="token"``, the returned loss is a scalar.
If ``average is None``, the returned loss is a vector of shape (batch_size,).
"""
if average not in {None, "token", "batch"}:
raise ValueError("Got average f{average}, expected one of "
"None, 'token', or 'batch'")
# shape : (batch * sequence_length, num_classes)
logits_flat = logits.view(-1, logits.size(-1))
# shape : (batch * sequence_length, num_classes)
log_probs_flat = torch.nn.functional.log_softmax(logits_flat, dim=-1)
# shape : (batch * max_len, 1)
targets_flat = targets.view(-1, 1).long()
if label_smoothing is not None and label_smoothing > 0.0:
num_classes = logits.size(-1)
smoothing_value = label_smoothing / num_classes
# Fill all the correct indices with 1 - smoothing value.
one_hot_targets = torch.zeros_like(log_probs_flat).scatter_(-1, targets_flat, 1.0 - label_smoothing)
smoothed_targets = one_hot_targets + smoothing_value
negative_log_likelihood_flat = - log_probs_flat * smoothed_targets
negative_log_likelihood_flat = negative_log_likelihood_flat.sum(-1, keepdim=True)
else:
# Contribution to the negative log likelihood only comes from the exact indices
# of the targets, as the target distributions are one-hot. Here we use torch.gather
# to extract the indices of the num_classes dimension which contribute to the loss.
# shape : (batch * sequence_length, 1)
negative_log_likelihood_flat = - torch.gather(log_probs_flat, dim=1, index=targets_flat)
# shape : (batch, sequence_length)
negative_log_likelihood = negative_log_likelihood_flat.view(*targets.size())
# shape : (batch, sequence_length)
negative_log_likelihood = negative_log_likelihood * weights.float()
if average == "batch":
# shape : (batch_size,)
per_batch_loss = negative_log_likelihood.sum(1) / (weights.sum(1).float() + 1e-13)
num_non_empty_sequences = ((weights.sum(1) > 0).float().sum() + 1e-13)
return per_batch_loss.sum() / num_non_empty_sequences
elif average == "token":
return negative_log_likelihood.sum() / (weights.sum().float() + 1e-13)
else:
# shape : (batch_size,)
per_batch_loss = negative_log_likelihood.sum(1) / (weights.sum(1).float() + 1e-13)
return per_batch_loss
|
[
"def",
"sequence_cross_entropy_with_logits",
"(",
"logits",
":",
"torch",
".",
"FloatTensor",
",",
"targets",
":",
"torch",
".",
"LongTensor",
",",
"weights",
":",
"torch",
".",
"FloatTensor",
",",
"average",
":",
"str",
"=",
"\"batch\"",
",",
"label_smoothing",
":",
"float",
"=",
"None",
")",
"->",
"torch",
".",
"FloatTensor",
":",
"if",
"average",
"not",
"in",
"{",
"None",
",",
"\"token\"",
",",
"\"batch\"",
"}",
":",
"raise",
"ValueError",
"(",
"\"Got average f{average}, expected one of \"",
"\"None, 'token', or 'batch'\"",
")",
"# shape : (batch * sequence_length, num_classes)",
"logits_flat",
"=",
"logits",
".",
"view",
"(",
"-",
"1",
",",
"logits",
".",
"size",
"(",
"-",
"1",
")",
")",
"# shape : (batch * sequence_length, num_classes)",
"log_probs_flat",
"=",
"torch",
".",
"nn",
".",
"functional",
".",
"log_softmax",
"(",
"logits_flat",
",",
"dim",
"=",
"-",
"1",
")",
"# shape : (batch * max_len, 1)",
"targets_flat",
"=",
"targets",
".",
"view",
"(",
"-",
"1",
",",
"1",
")",
".",
"long",
"(",
")",
"if",
"label_smoothing",
"is",
"not",
"None",
"and",
"label_smoothing",
">",
"0.0",
":",
"num_classes",
"=",
"logits",
".",
"size",
"(",
"-",
"1",
")",
"smoothing_value",
"=",
"label_smoothing",
"/",
"num_classes",
"# Fill all the correct indices with 1 - smoothing value.",
"one_hot_targets",
"=",
"torch",
".",
"zeros_like",
"(",
"log_probs_flat",
")",
".",
"scatter_",
"(",
"-",
"1",
",",
"targets_flat",
",",
"1.0",
"-",
"label_smoothing",
")",
"smoothed_targets",
"=",
"one_hot_targets",
"+",
"smoothing_value",
"negative_log_likelihood_flat",
"=",
"-",
"log_probs_flat",
"*",
"smoothed_targets",
"negative_log_likelihood_flat",
"=",
"negative_log_likelihood_flat",
".",
"sum",
"(",
"-",
"1",
",",
"keepdim",
"=",
"True",
")",
"else",
":",
"# Contribution to the negative log likelihood only comes from the exact indices",
"# of the targets, as the target distributions are one-hot. Here we use torch.gather",
"# to extract the indices of the num_classes dimension which contribute to the loss.",
"# shape : (batch * sequence_length, 1)",
"negative_log_likelihood_flat",
"=",
"-",
"torch",
".",
"gather",
"(",
"log_probs_flat",
",",
"dim",
"=",
"1",
",",
"index",
"=",
"targets_flat",
")",
"# shape : (batch, sequence_length)",
"negative_log_likelihood",
"=",
"negative_log_likelihood_flat",
".",
"view",
"(",
"*",
"targets",
".",
"size",
"(",
")",
")",
"# shape : (batch, sequence_length)",
"negative_log_likelihood",
"=",
"negative_log_likelihood",
"*",
"weights",
".",
"float",
"(",
")",
"if",
"average",
"==",
"\"batch\"",
":",
"# shape : (batch_size,)",
"per_batch_loss",
"=",
"negative_log_likelihood",
".",
"sum",
"(",
"1",
")",
"/",
"(",
"weights",
".",
"sum",
"(",
"1",
")",
".",
"float",
"(",
")",
"+",
"1e-13",
")",
"num_non_empty_sequences",
"=",
"(",
"(",
"weights",
".",
"sum",
"(",
"1",
")",
">",
"0",
")",
".",
"float",
"(",
")",
".",
"sum",
"(",
")",
"+",
"1e-13",
")",
"return",
"per_batch_loss",
".",
"sum",
"(",
")",
"/",
"num_non_empty_sequences",
"elif",
"average",
"==",
"\"token\"",
":",
"return",
"negative_log_likelihood",
".",
"sum",
"(",
")",
"/",
"(",
"weights",
".",
"sum",
"(",
")",
".",
"float",
"(",
")",
"+",
"1e-13",
")",
"else",
":",
"# shape : (batch_size,)",
"per_batch_loss",
"=",
"negative_log_likelihood",
".",
"sum",
"(",
"1",
")",
"/",
"(",
"weights",
".",
"sum",
"(",
"1",
")",
".",
"float",
"(",
")",
"+",
"1e-13",
")",
"return",
"per_batch_loss"
] |
Computes the cross entropy loss of a sequence, weighted with respect to
some user provided weights. Note that the weighting here is not the same as
in the :func:`torch.nn.CrossEntropyLoss()` criterion, which is weighting
classes; here we are weighting the loss contribution from particular elements
in the sequence. This allows loss computations for models which use padding.
Parameters
----------
logits : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch_size, sequence_length, num_classes)
which contains the unnormalized probability for each class.
targets : ``torch.LongTensor``, required.
A ``torch.LongTensor`` of size (batch, sequence_length) which contains the
index of the true class for each corresponding step.
weights : ``torch.FloatTensor``, required.
A ``torch.FloatTensor`` of size (batch, sequence_length)
average: str, optional (default = "batch")
If "batch", average the loss across the batches. If "token", average
the loss across each item in the input. If ``None``, return a vector
of losses per batch element.
label_smoothing : ``float``, optional (default = None)
Whether or not to apply label smoothing to the cross-entropy loss.
For example, with a label smoothing value of 0.2, a 4 class classification
target would look like ``[0.05, 0.05, 0.85, 0.05]`` if the 3rd class was
the correct label.
Returns
-------
A torch.FloatTensor representing the cross entropy loss.
If ``average=="batch"`` or ``average=="token"``, the returned loss is a scalar.
If ``average is None``, the returned loss is a vector of shape (batch_size,).
|
[
"Computes",
"the",
"cross",
"entropy",
"loss",
"of",
"a",
"sequence",
"weighted",
"with",
"respect",
"to",
"some",
"user",
"provided",
"weights",
".",
"Note",
"that",
"the",
"weighting",
"here",
"is",
"not",
"the",
"same",
"as",
"in",
"the",
":",
"func",
":",
"torch",
".",
"nn",
".",
"CrossEntropyLoss",
"()",
"criterion",
"which",
"is",
"weighting",
"classes",
";",
"here",
"we",
"are",
"weighting",
"the",
"loss",
"contribution",
"from",
"particular",
"elements",
"in",
"the",
"sequence",
".",
"This",
"allows",
"loss",
"computations",
"for",
"models",
"which",
"use",
"padding",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L569-L648
|
train
|
Returns the cross - entropy loss of a sequence with the given logits targets and weights.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU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8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(2184 - 2136) + chr(3786 - 3675) + '\x31' + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + chr(592 - 538) + '\x36', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + '\x31' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + '\062' + chr(1725 - 1672) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(9427 - 9316) + chr(50) + '\x33' + chr(2096 - 2043), 33983 - 33975), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + '\061' + chr(52), 33414 - 33406), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(194 - 143) + chr(1427 - 1378) + chr(0b11011 + 0o32), 8), ehT0Px3KOsy9(chr(0b110000) + chr(609 - 498) + chr(377 - 327) + chr(0b110111), 7831 - 7823), ehT0Px3KOsy9('\x30' + chr(8934 - 8823) + '\061' + '\x32' + '\067', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + '\061' + chr(54), 25219 - 25211), ehT0Px3KOsy9(chr(1222 - 1174) + '\157' + chr(0b110011) + '\x36' + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(7406 - 7295) + chr(829 - 778) + '\x34' + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10111 + 0o130) + chr(0b100100 + 0o16) + '\x37' + chr(0b11010 + 0o34), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(1393 - 1282) + chr(50) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1001010 + 0o45) + chr(0b110000 + 0o2) + chr(0b100001 + 0o20) + chr(52), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\067' + chr(55), 64538 - 64530), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(0b100100 + 0o23) + chr(0b10001 + 0o46), 0b1000), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(0b110010) + chr(0b110011) + chr(52), 45276 - 45268), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x30', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(483 - 430) + '\062', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(1365 - 1312) + chr(0b10000 + 0o44), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(492 - 441) + '\x30' + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110111) + chr(0b100001 + 0o17), 0o10), ehT0Px3KOsy9('\x30' + chr(2974 - 2863) + chr(0b101101 + 0o6) + chr(1536 - 1487) + '\x35', 8), ehT0Px3KOsy9(chr(0b110000) + chr(2386 - 2275) + chr(1099 - 1049) + '\x36' + '\062', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(52) + chr(2061 - 2012), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110101) + chr(0b110110), 37830 - 37822), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(855 - 801) + chr(0b1110 + 0o47), 0b1000), ehT0Px3KOsy9(chr(566 - 518) + chr(0b0 + 0o157) + '\061' + chr(64 - 14) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x37', 0o10), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(50) + '\065' + chr(48), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(53) + '\062', 42961 - 42953), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b110110) + '\x34', 0b1000), ehT0Px3KOsy9(chr(1468 - 1420) + chr(5879 - 5768) + chr(51) + chr(0b110011 + 0o1) + '\065', 34863 - 34855), ehT0Px3KOsy9('\060' + chr(0b1001001 + 0o46) + chr(0b110011) + chr(49) + chr(52), 0o10), ehT0Px3KOsy9(chr(1965 - 1917) + chr(935 - 824) + chr(897 - 847) + '\x35' + chr(1738 - 1688), 8), ehT0Px3KOsy9('\x30' + chr(0b10111 + 0o130) + chr(0b110110) + '\066', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + '\x32' + '\066' + '\066', 28848 - 28840), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + '\x33' + chr(317 - 264) + chr(52), 8), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b0 + 0o157) + chr(51) + chr(0b110110) + chr(1366 - 1317), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + chr(0b110101) + chr(0b1010 + 0o46), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'"'), chr(0b1100100) + '\x65' + chr(9026 - 8927) + chr(0b1101111) + chr(100) + '\x65')(chr(3762 - 3645) + chr(0b1000000 + 0o64) + '\x66' + chr(45) + chr(141 - 85)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def v70FM3ybmJL0(wF9nmvjsKjYM, xIEmRseySp3z, ZurHTci57aXw, xgY0rH0w1Z2T=xafqLlk3kkUe(SXOLrMavuUCe(b'n\x97\xb9\xcf\xf5'), chr(100) + chr(101) + chr(0b1010100 + 0o17) + chr(0b1011100 + 0o23) + '\144' + chr(101))('\x75' + chr(116) + chr(0b11010 + 0o114) + chr(0b101101) + chr(56)), FSjUgdaczzRk=None) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'J\x9a\xa2\xcd\xe9\xd8\xa8y$!\x86'), '\144' + '\145' + chr(0b1010111 + 0o14) + '\x6f' + chr(0b1100100) + chr(8050 - 7949))(chr(0b1110101) + chr(8989 - 8873) + chr(0b1100110) + chr(45) + chr(1725 - 1669))):
if xgY0rH0w1Z2T not in {None, xafqLlk3kkUe(SXOLrMavuUCe(b'x\x99\xa6\xc9\xf3'), '\144' + chr(0b100101 + 0o100) + chr(0b101100 + 0o67) + chr(0b1101111) + chr(9400 - 9300) + '\145')('\x75' + '\164' + chr(102) + chr(0b101101) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'n\x97\xb9\xcf\xf5'), '\x64' + '\145' + '\143' + chr(0b1100000 + 0o17) + '\144' + '\x65')(chr(0b1110101) + chr(0b110000 + 0o104) + '\146' + chr(0b101101) + chr(0b11100 + 0o34))}:
raise q1QCh3W88sgk(xafqLlk3kkUe(SXOLrMavuUCe(b"K\x99\xb9\x8c\xfc\xfa\xa8e6)\x91\xc1\xd8k\xedI\x1a\xeeaM\x89\xb9\x14\xed\xd7Y^\x906s\xcd\xceT\x8a\xa2\xcf\x16\xd9\x8a\xd1B\x99\xa3\xc9\xb1\xac\xeac8%\x91\x8f\x99<\xacP\r\xbc'H\x8d\xb0[\xa5\x95"), chr(0b1001000 + 0o34) + '\x65' + '\x63' + chr(111) + chr(100) + '\x65')('\x75' + chr(7515 - 7399) + chr(0b1100110) + chr(365 - 320) + chr(56)))
SNwbgAF2Pu2s = wF9nmvjsKjYM.view(-ehT0Px3KOsy9(chr(1689 - 1641) + chr(0b1101111) + chr(49), 0b1000), wF9nmvjsKjYM.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + '\x31', 8)))
I4EtIXtFlREP = cEkFpYktkSeK.nn.functional.log_softmax(SNwbgAF2Pu2s, dim=-ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(49), 8))
GZZkKiWA4Xli = xIEmRseySp3z.view(-ehT0Px3KOsy9('\060' + chr(111) + '\061', 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31', 8)).long()
if FSjUgdaczzRk is not None and FSjUgdaczzRk > 0.0:
i6loyAgxUM2t = wF9nmvjsKjYM.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\061', 8))
t0Tp_nQTXE1y = FSjUgdaczzRk / i6loyAgxUM2t
fHDoaZCs9RRi = cEkFpYktkSeK.zeros_like(I4EtIXtFlREP).scatter_(-ehT0Px3KOsy9(chr(0b110000) + chr(0b100 + 0o153) + chr(0b11111 + 0o22), 8), GZZkKiWA4Xli, 1.0 - FSjUgdaczzRk)
oJghtGip_DOm = fHDoaZCs9RRi + t0Tp_nQTXE1y
bIoUgpPRwWgv = -I4EtIXtFlREP * oJghtGip_DOm
bIoUgpPRwWgv = bIoUgpPRwWgv.xkxBmo49x2An(-ehT0Px3KOsy9(chr(0b110000) + chr(0b1010101 + 0o32) + '\061', 8), keepdim=ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b1100011 + 0o14) + '\061', 8))
else:
bIoUgpPRwWgv = -cEkFpYktkSeK.kGr_8mTaGpVE(I4EtIXtFlREP, dim=ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + chr(49), 8), index=GZZkKiWA4Xli)
jayxWZXTL1Mz = bIoUgpPRwWgv.view(*xIEmRseySp3z.NLcc3BCJnQka())
jayxWZXTL1Mz = jayxWZXTL1Mz * ZurHTci57aXw.float()
if xgY0rH0w1Z2T == xafqLlk3kkUe(SXOLrMavuUCe(b'n\x97\xb9\xcf\xf5'), '\x64' + '\145' + chr(99) + '\157' + '\144' + chr(2104 - 2003))(chr(0b1110101) + chr(0b1110100) + chr(7950 - 7848) + chr(45) + chr(773 - 717)):
vPEvopbSD8Ww = jayxWZXTL1Mz.xkxBmo49x2An(ehT0Px3KOsy9('\x30' + chr(10794 - 10683) + chr(49), 8)) / (ZurHTci57aXw.sum(ehT0Px3KOsy9(chr(0b110000) + chr(0b100 + 0o153) + chr(0b110001), 8)).float() + 1e-13)
cXSXF3GSAwcA = (ZurHTci57aXw.sum(ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(0b11101 + 0o24), 8)) > ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(4087 - 3976) + chr(867 - 819), 8)).float().xkxBmo49x2An() + 1e-13
return xafqLlk3kkUe(vPEvopbSD8Ww, xafqLlk3kkUe(SXOLrMavuUCe(b't\x9d\xb5\xee\xf0\xe3\xf9./|\xb5\x8f'), chr(0b1100100) + chr(0b111111 + 0o46) + chr(99) + chr(111) + '\144' + chr(0b1100101))('\x75' + chr(116) + chr(10243 - 10141) + chr(329 - 284) + chr(107 - 51)))() / cXSXF3GSAwcA
elif xgY0rH0w1Z2T == xafqLlk3kkUe(SXOLrMavuUCe(b'x\x99\xa6\xc9\xf3'), '\144' + chr(101) + chr(0b1100011) + chr(111) + chr(0b1011111 + 0o5) + chr(0b1100101))('\x75' + '\164' + chr(3371 - 3269) + chr(1377 - 1332) + '\x38'):
return xafqLlk3kkUe(jayxWZXTL1Mz, xafqLlk3kkUe(SXOLrMavuUCe(b't\x9d\xb5\xee\xf0\xe3\xf9./|\xb5\x8f'), chr(0b1100100) + chr(101) + chr(0b11011 + 0o110) + chr(111) + '\x64' + chr(101))('\165' + '\164' + chr(7726 - 7624) + '\055' + chr(0b111000)))() / (xafqLlk3kkUe(ZurHTci57aXw.sum(), xafqLlk3kkUe(SXOLrMavuUCe(b'j\x9a\xa2\xcd\xe9'), chr(0b1100100) + chr(8363 - 8262) + chr(99) + chr(0b110001 + 0o76) + chr(5304 - 5204) + chr(0b1100101))('\x75' + chr(11627 - 11511) + '\x66' + chr(0b101101) + chr(0b11011 + 0o35)))() + 1e-13)
else:
vPEvopbSD8Ww = jayxWZXTL1Mz.xkxBmo49x2An(ehT0Px3KOsy9(chr(48) + '\157' + '\061', 8)) / (ZurHTci57aXw.sum(ehT0Px3KOsy9('\060' + chr(3301 - 3190) + chr(83 - 34), 8)).float() + 1e-13)
return vPEvopbSD8Ww
|
allenai/allennlp
|
allennlp/nn/util.py
|
replace_masked_values
|
def replace_masked_values(tensor: torch.Tensor, mask: torch.Tensor, replace_with: float) -> torch.Tensor:
"""
Replaces all masked values in ``tensor`` with ``replace_with``. ``mask`` must be broadcastable
to the same shape as ``tensor``. We require that ``tensor.dim() == mask.dim()``, as otherwise we
won't know which dimensions of the mask to unsqueeze.
This just does ``tensor.masked_fill()``, except the pytorch method fills in things with a mask
value of 1, where we want the opposite. You can do this in your own code with
``tensor.masked_fill((1 - mask).byte(), replace_with)``.
"""
if tensor.dim() != mask.dim():
raise ConfigurationError("tensor.dim() (%d) != mask.dim() (%d)" % (tensor.dim(), mask.dim()))
return tensor.masked_fill((1 - mask).byte(), replace_with)
|
python
|
def replace_masked_values(tensor: torch.Tensor, mask: torch.Tensor, replace_with: float) -> torch.Tensor:
"""
Replaces all masked values in ``tensor`` with ``replace_with``. ``mask`` must be broadcastable
to the same shape as ``tensor``. We require that ``tensor.dim() == mask.dim()``, as otherwise we
won't know which dimensions of the mask to unsqueeze.
This just does ``tensor.masked_fill()``, except the pytorch method fills in things with a mask
value of 1, where we want the opposite. You can do this in your own code with
``tensor.masked_fill((1 - mask).byte(), replace_with)``.
"""
if tensor.dim() != mask.dim():
raise ConfigurationError("tensor.dim() (%d) != mask.dim() (%d)" % (tensor.dim(), mask.dim()))
return tensor.masked_fill((1 - mask).byte(), replace_with)
|
[
"def",
"replace_masked_values",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"replace_with",
":",
"float",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"tensor",
".",
"dim",
"(",
")",
"!=",
"mask",
".",
"dim",
"(",
")",
":",
"raise",
"ConfigurationError",
"(",
"\"tensor.dim() (%d) != mask.dim() (%d)\"",
"%",
"(",
"tensor",
".",
"dim",
"(",
")",
",",
"mask",
".",
"dim",
"(",
")",
")",
")",
"return",
"tensor",
".",
"masked_fill",
"(",
"(",
"1",
"-",
"mask",
")",
".",
"byte",
"(",
")",
",",
"replace_with",
")"
] |
Replaces all masked values in ``tensor`` with ``replace_with``. ``mask`` must be broadcastable
to the same shape as ``tensor``. We require that ``tensor.dim() == mask.dim()``, as otherwise we
won't know which dimensions of the mask to unsqueeze.
This just does ``tensor.masked_fill()``, except the pytorch method fills in things with a mask
value of 1, where we want the opposite. You can do this in your own code with
``tensor.masked_fill((1 - mask).byte(), replace_with)``.
|
[
"Replaces",
"all",
"masked",
"values",
"in",
"tensor",
"with",
"replace_with",
".",
"mask",
"must",
"be",
"broadcastable",
"to",
"the",
"same",
"shape",
"as",
"tensor",
".",
"We",
"require",
"that",
"tensor",
".",
"dim",
"()",
"==",
"mask",
".",
"dim",
"()",
"as",
"otherwise",
"we",
"won",
"t",
"know",
"which",
"dimensions",
"of",
"the",
"mask",
"to",
"unsqueeze",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L651-L663
|
train
|
Replaces all masked values in tensor with replace_with.
|
Pu7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Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101110 + 0o3) + chr(339 - 285) + chr(49), 43090 - 43082), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(5748 - 5637) + '\x31' + chr(52) + chr(0b11110 + 0o24), 0b1000), ehT0Px3KOsy9(chr(1014 - 966) + chr(0b1101111) + chr(439 - 389) + chr(2718 - 2663) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(1619 - 1571) + chr(0b1100110 + 0o11) + '\061' + chr(0b10010 + 0o42) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1100 + 0o46) + chr(0b110110) + chr(1519 - 1465), 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + chr(2606 - 2552) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110101 + 0o0) + chr(54), 17327 - 17319), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + '\065' + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010011 + 0o34) + chr(49) + chr(432 - 384) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(1674 - 1626) + chr(0b1101111) + chr(405 - 355) + chr(0b11110 + 0o30), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110101) + chr(453 - 405), 52251 - 52243), ehT0Px3KOsy9('\060' + chr(111) + '\064' + '\x36', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(53) + chr(49), 0o10), ehT0Px3KOsy9(chr(2120 - 2072) + chr(397 - 286) + chr(51) + '\066' + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b1101111) + '\061' + chr(0b110 + 0o57) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + '\061' + chr(1761 - 1711), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + '\064', 0o10), ehT0Px3KOsy9('\x30' + chr(7273 - 7162) + '\061' + chr(839 - 789) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + chr(51) + chr(0b11110 + 0o26) + '\065', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(7457 - 7346) + chr(0b10111 + 0o33) + chr(0b110100) + '\060', 48622 - 48614), ehT0Px3KOsy9('\x30' + chr(0b10001 + 0o136) + chr(0b110011) + '\060' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101001 + 0o6) + '\x32' + chr(53) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(2022 - 1974) + chr(111) + chr(0b110001) + '\065' + chr(1401 - 1351), 15738 - 15730), ehT0Px3KOsy9(chr(0b110000) + chr(0b101100 + 0o103) + chr(0b110011) + chr(49) + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b10101 + 0o132) + chr(1378 - 1329) + '\065' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1697 - 1646) + chr(50) + chr(0b10011 + 0o42), ord("\x08")), ehT0Px3KOsy9(chr(1599 - 1551) + chr(0b1101111) + '\x33' + chr(1493 - 1440) + chr(58 - 3), 59680 - 59672), ehT0Px3KOsy9(chr(1119 - 1071) + chr(11586 - 11475) + chr(51) + chr(0b110101) + chr(52), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b110110) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + chr(0b110101) + chr(0b1110 + 0o47), 5282 - 5274), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + '\x33' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + '\x6f' + '\x32' + chr(0b110000) + chr(54), 30776 - 30768), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(48) + chr(9943 - 9832) + chr(0b11000 + 0o32) + '\x31' + chr(0b110010), 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(1162 - 1113) + chr(52) + chr(907 - 852), ord("\x08")), ehT0Px3KOsy9(chr(2062 - 2014) + '\x6f' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101001 + 0o106) + chr(0b110001) + '\060' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(1814 - 1766) + '\157' + chr(50) + '\066' + chr(2027 - 1977), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1100110 + 0o11) + chr(1858 - 1808) + chr(0b110110) + chr(0b11111 + 0o21), 63159 - 63151), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + chr(48), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(508 - 460) + '\x6f' + '\065' + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'_'), '\x64' + chr(101) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(101))('\165' + chr(116) + '\146' + chr(593 - 548) + chr(0b110010 + 0o6)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def JM7sLImxCTQB(LK3cpXJU3UM0, Iz1jSgUKZDvt, dFn9AFrvdK4Y) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'%\x07\xd5\x17\xd9@'), chr(4280 - 4180) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(7784 - 7684) + '\145')('\165' + chr(1595 - 1479) + chr(0b1100110) + '\x2d' + chr(56))):
if xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\x0b\xd6'), '\144' + chr(0b1 + 0o144) + chr(0b1100011) + chr(3659 - 3548) + chr(100) + chr(0b111000 + 0o55))(chr(0b1110101) + '\164' + '\x66' + chr(1569 - 1524) + '\x38'))() != xafqLlk3kkUe(Iz1jSgUKZDvt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\x0b\xd6'), '\144' + '\145' + chr(0b1100011) + chr(0b1011 + 0o144) + chr(0b1100100) + chr(0b100010 + 0o103))(chr(117) + '\164' + chr(102) + chr(801 - 756) + chr(0b11001 + 0o37)))():
raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\x07\xd5\x17\xd9@\x00K({\x00\x0f\t\xddI\xee=u\xc4\x9d\xe2\xc5\x0b\xbb\x04\xfb\x8b\x85\xdeE\xf1\xa6(\xaf\x03+'), '\x64' + '\145' + '\143' + chr(111) + '\x64' + '\145')(chr(0b1100101 + 0o20) + '\164' + '\x66' + chr(1625 - 1580) + chr(0b111000)) % (xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\x0b\xd6'), chr(1568 - 1468) + chr(0b1100 + 0o131) + '\143' + '\157' + chr(0b1100100) + '\145')(chr(0b1010110 + 0o37) + '\x74' + chr(102) + chr(689 - 644) + '\070'))(), xafqLlk3kkUe(Iz1jSgUKZDvt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\x0b\xd6'), chr(0b110001 + 0o63) + '\x65' + chr(250 - 151) + chr(111) + '\144' + '\145')(chr(8094 - 7977) + '\x74' + chr(0b1100110) + '\055' + chr(56)))()))
return xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c\x03\xc8\x0f\xd3VqI(zD'), chr(100) + chr(0b1000100 + 0o41) + '\x63' + '\x6f' + chr(100) + chr(9219 - 9118))('\x75' + '\164' + chr(3783 - 3681) + chr(0b101101) + chr(2269 - 2213)))(xafqLlk3kkUe(ehT0Px3KOsy9(chr(1346 - 1298) + chr(0b1010111 + 0o30) + chr(0b110001), 3754 - 3746) - Iz1jSgUKZDvt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x13\x1b\xcf\x01'), chr(0b111110 + 0o46) + '\145' + '\143' + chr(111) + '\x64' + chr(0b10101 + 0o120))(chr(117) + '\164' + chr(9663 - 9561) + '\x2d' + chr(720 - 664)))(), dFn9AFrvdK4Y)
|
allenai/allennlp
|
allennlp/nn/util.py
|
tensors_equal
|
def tensors_equal(tensor1: torch.Tensor, tensor2: torch.Tensor, tolerance: float = 1e-12) -> bool:
"""
A check for tensor equality (by value). We make sure that the tensors have the same shape,
then check all of the entries in the tensor for equality. We additionally allow the input
tensors to be lists or dictionaries, where we then do the above check on every position in the
list / item in the dictionary. If we find objects that aren't tensors as we're doing that, we
just defer to their equality check.
This is kind of a catch-all method that's designed to make implementing ``__eq__`` methods
easier, in a way that's really only intended to be useful for tests.
"""
# pylint: disable=too-many-return-statements
if isinstance(tensor1, (list, tuple)):
if not isinstance(tensor2, (list, tuple)) or len(tensor1) != len(tensor2):
return False
return all([tensors_equal(t1, t2, tolerance) for t1, t2 in zip(tensor1, tensor2)])
elif isinstance(tensor1, dict):
if not isinstance(tensor2, dict):
return False
if tensor1.keys() != tensor2.keys():
return False
return all([tensors_equal(tensor1[key], tensor2[key], tolerance) for key in tensor1])
elif isinstance(tensor1, torch.Tensor):
if not isinstance(tensor2, torch.Tensor):
return False
if tensor1.size() != tensor2.size():
return False
return ((tensor1 - tensor2).abs().float() < tolerance).all()
else:
try:
return tensor1 == tensor2
except RuntimeError:
print(type(tensor1), type(tensor2))
raise
|
python
|
def tensors_equal(tensor1: torch.Tensor, tensor2: torch.Tensor, tolerance: float = 1e-12) -> bool:
"""
A check for tensor equality (by value). We make sure that the tensors have the same shape,
then check all of the entries in the tensor for equality. We additionally allow the input
tensors to be lists or dictionaries, where we then do the above check on every position in the
list / item in the dictionary. If we find objects that aren't tensors as we're doing that, we
just defer to their equality check.
This is kind of a catch-all method that's designed to make implementing ``__eq__`` methods
easier, in a way that's really only intended to be useful for tests.
"""
# pylint: disable=too-many-return-statements
if isinstance(tensor1, (list, tuple)):
if not isinstance(tensor2, (list, tuple)) or len(tensor1) != len(tensor2):
return False
return all([tensors_equal(t1, t2, tolerance) for t1, t2 in zip(tensor1, tensor2)])
elif isinstance(tensor1, dict):
if not isinstance(tensor2, dict):
return False
if tensor1.keys() != tensor2.keys():
return False
return all([tensors_equal(tensor1[key], tensor2[key], tolerance) for key in tensor1])
elif isinstance(tensor1, torch.Tensor):
if not isinstance(tensor2, torch.Tensor):
return False
if tensor1.size() != tensor2.size():
return False
return ((tensor1 - tensor2).abs().float() < tolerance).all()
else:
try:
return tensor1 == tensor2
except RuntimeError:
print(type(tensor1), type(tensor2))
raise
|
[
"def",
"tensors_equal",
"(",
"tensor1",
":",
"torch",
".",
"Tensor",
",",
"tensor2",
":",
"torch",
".",
"Tensor",
",",
"tolerance",
":",
"float",
"=",
"1e-12",
")",
"->",
"bool",
":",
"# pylint: disable=too-many-return-statements",
"if",
"isinstance",
"(",
"tensor1",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensor2",
",",
"(",
"list",
",",
"tuple",
")",
")",
"or",
"len",
"(",
"tensor1",
")",
"!=",
"len",
"(",
"tensor2",
")",
":",
"return",
"False",
"return",
"all",
"(",
"[",
"tensors_equal",
"(",
"t1",
",",
"t2",
",",
"tolerance",
")",
"for",
"t1",
",",
"t2",
"in",
"zip",
"(",
"tensor1",
",",
"tensor2",
")",
"]",
")",
"elif",
"isinstance",
"(",
"tensor1",
",",
"dict",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensor2",
",",
"dict",
")",
":",
"return",
"False",
"if",
"tensor1",
".",
"keys",
"(",
")",
"!=",
"tensor2",
".",
"keys",
"(",
")",
":",
"return",
"False",
"return",
"all",
"(",
"[",
"tensors_equal",
"(",
"tensor1",
"[",
"key",
"]",
",",
"tensor2",
"[",
"key",
"]",
",",
"tolerance",
")",
"for",
"key",
"in",
"tensor1",
"]",
")",
"elif",
"isinstance",
"(",
"tensor1",
",",
"torch",
".",
"Tensor",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensor2",
",",
"torch",
".",
"Tensor",
")",
":",
"return",
"False",
"if",
"tensor1",
".",
"size",
"(",
")",
"!=",
"tensor2",
".",
"size",
"(",
")",
":",
"return",
"False",
"return",
"(",
"(",
"tensor1",
"-",
"tensor2",
")",
".",
"abs",
"(",
")",
".",
"float",
"(",
")",
"<",
"tolerance",
")",
".",
"all",
"(",
")",
"else",
":",
"try",
":",
"return",
"tensor1",
"==",
"tensor2",
"except",
"RuntimeError",
":",
"print",
"(",
"type",
"(",
"tensor1",
")",
",",
"type",
"(",
"tensor2",
")",
")",
"raise"
] |
A check for tensor equality (by value). We make sure that the tensors have the same shape,
then check all of the entries in the tensor for equality. We additionally allow the input
tensors to be lists or dictionaries, where we then do the above check on every position in the
list / item in the dictionary. If we find objects that aren't tensors as we're doing that, we
just defer to their equality check.
This is kind of a catch-all method that's designed to make implementing ``__eq__`` methods
easier, in a way that's really only intended to be useful for tests.
|
[
"A",
"check",
"for",
"tensor",
"equality",
"(",
"by",
"value",
")",
".",
"We",
"make",
"sure",
"that",
"the",
"tensors",
"have",
"the",
"same",
"shape",
"then",
"check",
"all",
"of",
"the",
"entries",
"in",
"the",
"tensor",
"for",
"equality",
".",
"We",
"additionally",
"allow",
"the",
"input",
"tensors",
"to",
"be",
"lists",
"or",
"dictionaries",
"where",
"we",
"then",
"do",
"the",
"above",
"check",
"on",
"every",
"position",
"in",
"the",
"list",
"/",
"item",
"in",
"the",
"dictionary",
".",
"If",
"we",
"find",
"objects",
"that",
"aren",
"t",
"tensors",
"as",
"we",
"re",
"doing",
"that",
"we",
"just",
"defer",
"to",
"their",
"equality",
"check",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L666-L699
|
train
|
A simple equality check for the two tensors.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT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QC9iu2kLpS8s,QOfmzcVJsrp8,tzcpInYwBvYW,iDQ_gSK8V7h0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(2506 - 2395) + chr(2657 - 2603) + chr(0b11011 + 0o32), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10011 + 0o134) + chr(1021 - 966) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(1550 - 1439) + chr(50) + chr(51) + chr(0b110101), 50914 - 50906), ehT0Px3KOsy9(chr(1245 - 1197) + chr(0b1001000 + 0o47) + chr(49) + chr(0b110010) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1010 + 0o51) + chr(0b110000) + chr(51), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(0b110000) + '\x36', 13756 - 13748), ehT0Px3KOsy9(chr(280 - 232) + '\157' + chr(0b110010) + '\067' + chr(50), 46947 - 46939), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(513 - 462) + chr(2069 - 2017), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b11000 + 0o127) + chr(1719 - 1668) + chr(55) + chr(53), 9993 - 9985), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(0b110111) + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(49) + chr(0b1100 + 0o51) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\157' + '\063' + chr(0b110011) + '\064', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101011 + 0o6) + chr(0b110001) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(0b110000 + 0o3) + '\x32', 56871 - 56863), ehT0Px3KOsy9(chr(48) + '\x6f' + '\067', 0o10), ehT0Px3KOsy9(chr(204 - 156) + chr(0b1011110 + 0o21) + chr(0b110011) + '\x37' + '\x35', 8), ehT0Px3KOsy9(chr(1224 - 1176) + '\157' + '\x32' + chr(0b110101) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b11010 + 0o125) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(0b101 + 0o54) + '\064' + '\066', 0o10), ehT0Px3KOsy9(chr(2097 - 2049) + chr(0b1011010 + 0o25) + chr(865 - 814), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(2021 - 1968) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000100 + 0o53) + chr(0b110010) + chr(53) + chr(51), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111 + 0o150) + chr(50) + '\061' + '\x37', 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(6607 - 6496) + chr(977 - 927) + '\062' + '\x33', 43558 - 43550), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b1001 + 0o55) + chr(0b110011), 27802 - 27794), ehT0Px3KOsy9(chr(173 - 125) + '\157' + chr(0b110001) + '\066' + chr(0b11100 + 0o24), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + '\062' + '\x34', 0o10), ehT0Px3KOsy9(chr(240 - 192) + chr(4213 - 4102) + chr(0b10100 + 0o42) + chr(49), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11 + 0o60) + chr(54) + chr(0b1001 + 0o52), 1556 - 1548), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(1211 - 1160) + chr(2740 - 2685), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x36' + '\x33', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + chr(55) + '\x32', 0o10), ehT0Px3KOsy9(chr(862 - 814) + '\157' + chr(0b1 + 0o62) + chr(686 - 633) + '\x31', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(0b110010) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110011) + chr(0b110101) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(2126 - 2078) + '\x6f' + chr(0b110010) + '\x30' + chr(54), 15640 - 15632), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + '\x32' + chr(0b110110) + chr(2159 - 2109), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2016 - 1967) + '\067' + chr(176 - 125), 11938 - 11930), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b100001 + 0o116) + chr(49) + chr(0b110101) + chr(0b11111 + 0o27), 16642 - 16634)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1403 - 1355) + '\157' + chr(0b110101) + chr(0b11110 + 0o22), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x1b'), '\144' + chr(4912 - 4811) + chr(466 - 367) + '\157' + chr(0b11110 + 0o106) + chr(0b1100101))('\x75' + chr(0b1100100 + 0o20) + chr(0b1100110) + '\055' + chr(0b1010 + 0o56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Ms3nhLARjdBO(_GoaLGZ5U6xS, H6fJ9QOZaJmh, eT0RFN_TG3vL=1e-12) -> WbBjf8Y7v9VN:
if PlSM16l2KDPD(_GoaLGZ5U6xS, (YyaZ4tpXu4lf, KNyTy8rYcwji)):
if not PlSM16l2KDPD(H6fJ9QOZaJmh, (YyaZ4tpXu4lf, KNyTy8rYcwji)) or c2A0yzQpDQB3(_GoaLGZ5U6xS) != c2A0yzQpDQB3(H6fJ9QOZaJmh):
return ehT0Px3KOsy9(chr(1780 - 1732) + chr(111) + chr(0b110000), 0b1000)
return Dl48nj1rbi23([Ms3nhLARjdBO(ePnIUew7NPYz, kzlXoYCxxWLU, eT0RFN_TG3vL) for (ePnIUew7NPYz, kzlXoYCxxWLU) in pZ0NK2y6HRbn(_GoaLGZ5U6xS, H6fJ9QOZaJmh)])
elif PlSM16l2KDPD(_GoaLGZ5U6xS, wLqBDw8l0eIm):
if not PlSM16l2KDPD(H6fJ9QOZaJmh, wLqBDw8l0eIm):
return ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + chr(48), 8)
if xafqLlk3kkUe(_GoaLGZ5U6xS, xafqLlk3kkUe(SXOLrMavuUCe(b'^X\xe4%'), chr(1186 - 1086) + chr(0b1100101) + chr(0b1100011) + chr(111) + '\x64' + '\145')('\x75' + chr(0b1110100) + chr(0b1100110) + chr(0b111 + 0o46) + chr(0b1011 + 0o55)))() != xafqLlk3kkUe(H6fJ9QOZaJmh, xafqLlk3kkUe(SXOLrMavuUCe(b'^X\xe4%'), '\144' + chr(101) + '\x63' + chr(0b100101 + 0o112) + chr(100) + chr(0b1100101))(chr(0b1001100 + 0o51) + chr(116) + chr(0b1100110) + chr(0b101101) + '\070'))():
return ehT0Px3KOsy9(chr(48) + chr(8060 - 7949) + chr(0b110000), 8)
return Dl48nj1rbi23([Ms3nhLARjdBO(_GoaLGZ5U6xS[K3J4ZwSlE0sT], H6fJ9QOZaJmh[K3J4ZwSlE0sT], eT0RFN_TG3vL) for K3J4ZwSlE0sT in _GoaLGZ5U6xS])
elif PlSM16l2KDPD(_GoaLGZ5U6xS, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'aX\xf3%\xac4'), '\144' + chr(101) + '\143' + chr(0b1101111) + chr(100) + chr(4263 - 4162))('\x75' + chr(0b1110100) + chr(4827 - 4725) + '\x2d' + chr(0b100111 + 0o21)))):
if not PlSM16l2KDPD(H6fJ9QOZaJmh, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'aX\xf3%\xac4'), chr(564 - 464) + '\145' + chr(99) + '\x6f' + chr(0b1011000 + 0o14) + '\x65')(chr(11661 - 11544) + chr(116) + chr(0b1000011 + 0o43) + '\055' + chr(401 - 345)))):
return ehT0Px3KOsy9(chr(0b110000) + '\157' + '\060', 8)
if xafqLlk3kkUe(_GoaLGZ5U6xS, xafqLlk3kkUe(SXOLrMavuUCe(b'{q\xfe5\xf0\x04\xf9\xd6\x93(\x03\xbd'), '\x64' + chr(101) + '\x63' + '\x6f' + '\144' + chr(0b111011 + 0o52))('\x75' + '\x74' + chr(102) + chr(0b100010 + 0o13) + chr(56)))() != xafqLlk3kkUe(H6fJ9QOZaJmh, xafqLlk3kkUe(SXOLrMavuUCe(b'{q\xfe5\xf0\x04\xf9\xd6\x93(\x03\xbd'), chr(0b1100100) + '\x65' + chr(0b10001 + 0o122) + '\157' + chr(100) + '\145')('\x75' + '\164' + chr(0b1010000 + 0o26) + chr(0b10101 + 0o30) + '\070'))():
return ehT0Px3KOsy9(chr(0b110000) + chr(0b1010011 + 0o34) + chr(0b11111 + 0o21), 8)
return xafqLlk3kkUe((_GoaLGZ5U6xS - H6fJ9QOZaJmh).abs().float() < eT0RFN_TG3vL, xafqLlk3kkUe(SXOLrMavuUCe(b'qQ\xa9n\xad,\x8b\xee\x9f\x10Z\xef'), chr(100) + chr(101) + '\143' + chr(0b1101010 + 0o5) + '\x64' + chr(101))(chr(5166 - 5049) + '\x74' + '\146' + '\x2d' + chr(56)))()
else:
try:
return _GoaLGZ5U6xS == H6fJ9QOZaJmh
except n0ZkatoveZpF:
zLUzGokYBM2Z(wmQmyeWBmUpv(_GoaLGZ5U6xS), wmQmyeWBmUpv(H6fJ9QOZaJmh))
raise
|
allenai/allennlp
|
allennlp/nn/util.py
|
device_mapping
|
def device_mapping(cuda_device: int):
"""
In order to `torch.load()` a GPU-trained model onto a CPU (or specific GPU),
you have to supply a `map_location` function. Call this with
the desired `cuda_device` to get the function that `torch.load()` needs.
"""
def inner_device_mapping(storage: torch.Storage, location) -> torch.Storage: # pylint: disable=unused-argument
if cuda_device >= 0:
return storage.cuda(cuda_device)
else:
return storage
return inner_device_mapping
|
python
|
def device_mapping(cuda_device: int):
"""
In order to `torch.load()` a GPU-trained model onto a CPU (or specific GPU),
you have to supply a `map_location` function. Call this with
the desired `cuda_device` to get the function that `torch.load()` needs.
"""
def inner_device_mapping(storage: torch.Storage, location) -> torch.Storage: # pylint: disable=unused-argument
if cuda_device >= 0:
return storage.cuda(cuda_device)
else:
return storage
return inner_device_mapping
|
[
"def",
"device_mapping",
"(",
"cuda_device",
":",
"int",
")",
":",
"def",
"inner_device_mapping",
"(",
"storage",
":",
"torch",
".",
"Storage",
",",
"location",
")",
"->",
"torch",
".",
"Storage",
":",
"# pylint: disable=unused-argument",
"if",
"cuda_device",
">=",
"0",
":",
"return",
"storage",
".",
"cuda",
"(",
"cuda_device",
")",
"else",
":",
"return",
"storage",
"return",
"inner_device_mapping"
] |
In order to `torch.load()` a GPU-trained model onto a CPU (or specific GPU),
you have to supply a `map_location` function. Call this with
the desired `cuda_device` to get the function that `torch.load()` needs.
|
[
"In",
"order",
"to",
"torch",
".",
"load",
"()",
"a",
"GPU",
"-",
"trained",
"model",
"onto",
"a",
"CPU",
"(",
"or",
"specific",
"GPU",
")",
"you",
"have",
"to",
"supply",
"a",
"map_location",
"function",
".",
"Call",
"this",
"with",
"the",
"desired",
"cuda_device",
"to",
"get",
"the",
"function",
"that",
"torch",
".",
"load",
"()",
"needs",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L702-L715
|
train
|
Returns a function that maps a GPU - trained model onto a CPU or specific GPU.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp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SX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(111) + '\x31' + '\065' + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(912 - 801) + chr(0b1000 + 0o51) + '\060' + chr(0b110010), 0o10), ehT0Px3KOsy9('\060' + chr(0b11 + 0o154) + '\x31' + chr(54) + chr(0b100111 + 0o17), 59729 - 59721), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + chr(0b110001) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(792 - 743) + chr(0b110101) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(1044 - 996) + chr(111) + chr(0b110011) + '\064', 24238 - 24230), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(1586 - 1537) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b1001 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + '\x33' + chr(2713 - 2660) + chr(0b11111 + 0o23), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1001011 + 0o44) + chr(51) + '\064', 8), ehT0Px3KOsy9('\060' + chr(7932 - 7821) + '\x33' + chr(0b110001) + '\062', 60197 - 60189), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + chr(0b110111) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + '\x35' + chr(2007 - 1958), 8670 - 8662), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b11101 + 0o122) + chr(1281 - 1232) + chr(51) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(111) + '\061' + chr(0b100010 + 0o20) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(111) + chr(0b110010) + '\065' + chr(0b10111 + 0o33), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + '\063' + chr(0b101101 + 0o12), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1010010 + 0o35) + chr(778 - 727) + chr(54) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\065' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + '\x35' + chr(48), 29866 - 29858), ehT0Px3KOsy9(chr(377 - 329) + '\x6f' + chr(0b110010) + chr(51) + chr(51), 41133 - 41125), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(111) + chr(0b110001) + chr(0b110101) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + '\062' + chr(0b11011 + 0o32), 45774 - 45766), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\x31' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(771 - 723) + chr(6084 - 5973) + chr(0b110010) + chr(0b110110) + chr(0b100 + 0o61), 0o10), ehT0Px3KOsy9(chr(48) + chr(781 - 670) + '\x32' + '\065' + '\060', 36447 - 36439), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1010 + 0o51) + chr(2679 - 2626) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b11101 + 0o122) + chr(50) + '\065' + '\060', 8), ehT0Px3KOsy9(chr(0b110000) + chr(6790 - 6679) + chr(0b101000 + 0o12) + '\x36' + chr(53), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b110111 + 0o70) + chr(0b100110 + 0o14) + '\063' + chr(49), 63311 - 63303), ehT0Px3KOsy9('\x30' + chr(0b1011010 + 0o25) + chr(0b100011 + 0o20) + '\x31' + chr(0b0 + 0o61), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(8555 - 8444) + '\061' + '\x36' + chr(0b1100 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b101001 + 0o106) + chr(0b110001) + chr(0b10011 + 0o35) + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(48) + chr(1163 - 1052) + chr(0b110001) + '\x35' + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1000 + 0o53) + '\x32' + '\x30', 39639 - 39631), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(792 - 742) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(54) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(323 - 269) + chr(0b110010), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1111 + 0o46) + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'F'), chr(0b10010 + 0o122) + '\x65' + chr(0b1101 + 0o126) + '\x6f' + chr(0b11101 + 0o107) + '\145')(chr(6340 - 6223) + chr(116) + chr(102) + chr(0b101010 + 0o3) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def MEnoRW4523io(jRcTRdiVAZAp):
def hkcbrEk3iwaR(SGlhJlEWrbsb, PmHHUsyAGu0d) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b';6\x19\xbc\x0e{\xe9'), chr(0b1100100) + chr(9819 - 9718) + chr(7376 - 7277) + chr(0b1101111) + chr(5815 - 5715) + chr(9766 - 9665))(chr(0b100 + 0o161) + chr(0b1000001 + 0o63) + chr(0b1000100 + 0o42) + chr(492 - 447) + chr(0b111000))):
if jRcTRdiVAZAp >= ehT0Px3KOsy9(chr(0b110000) + chr(5672 - 5561) + chr(0b110000), 0b1000):
return xafqLlk3kkUe(SGlhJlEWrbsb, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b7\x12\xaf'), '\144' + chr(7801 - 7700) + chr(99) + chr(0b1101111) + '\x64' + '\145')(chr(1349 - 1232) + chr(2593 - 2477) + chr(102) + '\x2d' + '\x38'))(jRcTRdiVAZAp)
else:
return SGlhJlEWrbsb
return hkcbrEk3iwaR
|
allenai/allennlp
|
allennlp/nn/util.py
|
combine_tensors
|
def combine_tensors(combination: str, tensors: List[torch.Tensor]) -> torch.Tensor:
"""
Combines a list of tensors using element-wise operations and concatenation, specified by a
``combination`` string. The string refers to (1-indexed) positions in the input tensor list,
and looks like ``"1,2,1+2,3-1"``.
We allow the following kinds of combinations: ``x``, ``x*y``, ``x+y``, ``x-y``, and ``x/y``,
where ``x`` and ``y`` are positive integers less than or equal to ``len(tensors)``. Each of
the binary operations is performed elementwise. You can give as many combinations as you want
in the ``combination`` string. For example, for the input string ``"1,2,1*2"``, the result
would be ``[1;2;1*2]``, as you would expect, where ``[;]`` is concatenation along the last
dimension.
If you have a fixed, known way to combine tensors that you use in a model, you should probably
just use something like ``torch.cat([x_tensor, y_tensor, x_tensor * y_tensor])``. This
function adds some complexity that is only necessary if you want the specific combination used
to be `configurable`.
If you want to do any element-wise operations, the tensors involved in each element-wise
operation must have the same shape.
This function also accepts ``x`` and ``y`` in place of ``1`` and ``2`` in the combination
string.
"""
if len(tensors) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
to_concatenate = [_get_combination(piece, tensors) for piece in combination.split(',')]
return torch.cat(to_concatenate, dim=-1)
|
python
|
def combine_tensors(combination: str, tensors: List[torch.Tensor]) -> torch.Tensor:
"""
Combines a list of tensors using element-wise operations and concatenation, specified by a
``combination`` string. The string refers to (1-indexed) positions in the input tensor list,
and looks like ``"1,2,1+2,3-1"``.
We allow the following kinds of combinations: ``x``, ``x*y``, ``x+y``, ``x-y``, and ``x/y``,
where ``x`` and ``y`` are positive integers less than or equal to ``len(tensors)``. Each of
the binary operations is performed elementwise. You can give as many combinations as you want
in the ``combination`` string. For example, for the input string ``"1,2,1*2"``, the result
would be ``[1;2;1*2]``, as you would expect, where ``[;]`` is concatenation along the last
dimension.
If you have a fixed, known way to combine tensors that you use in a model, you should probably
just use something like ``torch.cat([x_tensor, y_tensor, x_tensor * y_tensor])``. This
function adds some complexity that is only necessary if you want the specific combination used
to be `configurable`.
If you want to do any element-wise operations, the tensors involved in each element-wise
operation must have the same shape.
This function also accepts ``x`` and ``y`` in place of ``1`` and ``2`` in the combination
string.
"""
if len(tensors) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
to_concatenate = [_get_combination(piece, tensors) for piece in combination.split(',')]
return torch.cat(to_concatenate, dim=-1)
|
[
"def",
"combine_tensors",
"(",
"combination",
":",
"str",
",",
"tensors",
":",
"List",
"[",
"torch",
".",
"Tensor",
"]",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"len",
"(",
"tensors",
")",
">",
"9",
":",
"raise",
"ConfigurationError",
"(",
"\"Double-digit tensor lists not currently supported\"",
")",
"combination",
"=",
"combination",
".",
"replace",
"(",
"'x'",
",",
"'1'",
")",
".",
"replace",
"(",
"'y'",
",",
"'2'",
")",
"to_concatenate",
"=",
"[",
"_get_combination",
"(",
"piece",
",",
"tensors",
")",
"for",
"piece",
"in",
"combination",
".",
"split",
"(",
"','",
")",
"]",
"return",
"torch",
".",
"cat",
"(",
"to_concatenate",
",",
"dim",
"=",
"-",
"1",
")"
] |
Combines a list of tensors using element-wise operations and concatenation, specified by a
``combination`` string. The string refers to (1-indexed) positions in the input tensor list,
and looks like ``"1,2,1+2,3-1"``.
We allow the following kinds of combinations: ``x``, ``x*y``, ``x+y``, ``x-y``, and ``x/y``,
where ``x`` and ``y`` are positive integers less than or equal to ``len(tensors)``. Each of
the binary operations is performed elementwise. You can give as many combinations as you want
in the ``combination`` string. For example, for the input string ``"1,2,1*2"``, the result
would be ``[1;2;1*2]``, as you would expect, where ``[;]`` is concatenation along the last
dimension.
If you have a fixed, known way to combine tensors that you use in a model, you should probably
just use something like ``torch.cat([x_tensor, y_tensor, x_tensor * y_tensor])``. This
function adds some complexity that is only necessary if you want the specific combination used
to be `configurable`.
If you want to do any element-wise operations, the tensors involved in each element-wise
operation must have the same shape.
This function also accepts ``x`` and ``y`` in place of ``1`` and ``2`` in the combination
string.
|
[
"Combines",
"a",
"list",
"of",
"tensors",
"using",
"element",
"-",
"wise",
"operations",
"and",
"concatenation",
"specified",
"by",
"a",
"combination",
"string",
".",
"The",
"string",
"refers",
"to",
"(",
"1",
"-",
"indexed",
")",
"positions",
"in",
"the",
"input",
"tensor",
"list",
"and",
"looks",
"like",
"1",
"2",
"1",
"+",
"2",
"3",
"-",
"1",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L718-L746
|
train
|
Combines a list of tensors using element - wise operations and concatenation of tensors.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTx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rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1870 - 1822) + chr(2021 - 1910) + '\061' + chr(2299 - 2247) + chr(0b110110), 26268 - 26260), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(0b1110 + 0o50) + chr(948 - 898), 34293 - 34285), ehT0Px3KOsy9(chr(750 - 702) + chr(0b1101111) + '\061' + '\x30' + chr(51), 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(8296 - 8185) + '\x33' + chr(0b1 + 0o61) + chr(0b110001), 61466 - 61458), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1101 + 0o51) + chr(1692 - 1638), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101101 + 0o2) + chr(0b10001 + 0o40) + chr(0b1000 + 0o50) + chr(0b110011), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + '\x32' + chr(797 - 747) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(1478 - 1430) + '\157' + '\x32' + chr(51) + '\063', 24249 - 24241), ehT0Px3KOsy9(chr(1241 - 1193) + '\157' + chr(0b110001) + '\062' + chr(0b101001 + 0o11), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(49) + chr(1421 - 1372) + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10101 + 0o36) + '\066' + chr(2007 - 1952), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\060' + '\067', 0o10), ehT0Px3KOsy9(chr(1543 - 1495) + '\x6f' + chr(0b110001 + 0o3) + '\x35', 0b1000), ehT0Px3KOsy9(chr(1192 - 1144) + '\x6f' + chr(1115 - 1065) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(0b11 + 0o61) + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11001 + 0o30) + '\060' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11 + 0o56) + '\061' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b111101 + 0o62) + chr(49) + '\x35' + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1171 - 1120) + chr(0b110100) + chr(0b110101 + 0o1), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(12233 - 12122) + chr(0b110010) + chr(0b10100 + 0o34) + chr(0b1 + 0o61), 30359 - 30351), ehT0Px3KOsy9(chr(1960 - 1912) + chr(0b101 + 0o152) + chr(2263 - 2211) + chr(1206 - 1157), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\x6f' + chr(0b100100 + 0o16) + '\x32' + chr(0b11011 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(996 - 948) + chr(5933 - 5822) + chr(0b110001) + chr(55), 64495 - 64487), ehT0Px3KOsy9(chr(1479 - 1431) + chr(111) + chr(2139 - 2090) + '\062' + chr(2076 - 2021), 0b1000), ehT0Px3KOsy9(chr(526 - 478) + '\157' + chr(0b110101) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(1616 - 1505) + chr(0b110010) + '\061' + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(436 - 325) + chr(0b11111 + 0o25) + chr(0b101111 + 0o10), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b111011 + 0o64) + chr(51) + chr(732 - 678) + '\066', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b110110 + 0o71) + '\x32' + chr(53), 24406 - 24398), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\157' + '\063' + chr(54) + chr(53), 56621 - 56613), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + chr(0b11001 + 0o31) + '\x34' + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x36', 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(913 - 858) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b100 + 0o55) + chr(52) + chr(0b110100), 48131 - 48123), ehT0Px3KOsy9(chr(1612 - 1564) + chr(111) + chr(50) + chr(53) + '\062', 65480 - 65472), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + chr(0b101000 + 0o14) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10100 + 0o35) + chr(1166 - 1118) + chr(1795 - 1741), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000111 + 0o50) + chr(0b110011) + '\x33' + chr(0b11001 + 0o36), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b11111 + 0o22) + chr(0b110000) + chr(55), 8), ehT0Px3KOsy9(chr(189 - 141) + '\x6f' + chr(49) + chr(0b110000) + chr(0b110101), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + chr(53) + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'H'), chr(0b1100100) + chr(0b101010 + 0o73) + chr(0b1100011) + chr(0b1101111) + chr(7895 - 7795) + '\145')(chr(117) + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def ytaFm9WhnKAp(dlz6RaNsbONT, Tyy4rche81dW) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'2\x17-\xa2Y1'), chr(0b1100100) + chr(101) + chr(2517 - 2418) + chr(1398 - 1287) + '\x64' + chr(0b1000111 + 0o36))(chr(117) + chr(116) + '\146' + chr(600 - 555) + chr(1805 - 1749))):
if c2A0yzQpDQB3(Tyy4rche81dW) > ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(0b110001), 0o10):
raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'"\x1d6\xb3Z&\xb9\xff;,\x9e\xf3\x05`\x87)9\x04\x94\xa2M\xf8|#[\xabI\x99a\xd5\xc5s\xce\x16\xcf\x8a2\xb3>e\x15\x073\xa1Y1\xe0\xfe6'), '\x64' + '\145' + chr(3371 - 3272) + chr(0b1011010 + 0o25) + chr(100) + '\145')(chr(6058 - 5941) + chr(116) + '\x66' + '\x2d' + '\x38'))
dlz6RaNsbONT = dlz6RaNsbONT.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e'), chr(0b10 + 0o142) + chr(0b1100101) + chr(99) + chr(0b1100000 + 0o17) + '\x64' + '\x65')(chr(12362 - 12245) + chr(0b1011000 + 0o34) + chr(10060 - 9958) + '\x2d' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'W'), chr(0b1100100) + '\x65' + chr(8600 - 8501) + '\x6f' + '\144' + chr(8092 - 7991))(chr(1549 - 1432) + chr(9847 - 9731) + chr(0b1100011 + 0o3) + '\x2d' + chr(0b111000))).replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f'), chr(0b11001 + 0o113) + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(0b1000000 + 0o44) + '\145')(chr(0b1110101) + chr(2429 - 2313) + '\x66' + '\055' + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'T'), '\x64' + '\x65' + chr(0b1100011) + '\157' + '\x64' + '\145')(chr(117) + chr(0b1110100) + chr(8211 - 8109) + '\x2d' + chr(311 - 255)))
COoctjxnPhxZ = [aT_E_mGVZAUd(N0fpDLYvEEVW, Tyy4rche81dW) for N0fpDLYvEEVW in dlz6RaNsbONT.split(xafqLlk3kkUe(SXOLrMavuUCe(b'J'), chr(0b1100100) + chr(0b1100101) + chr(9081 - 8982) + chr(111) + chr(0b101010 + 0o72) + chr(0b1100000 + 0o5))('\165' + '\x74' + chr(0b1100 + 0o132) + chr(274 - 229) + chr(0b111000)))]
return xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x05\x137'), chr(2445 - 2345) + chr(6771 - 6670) + chr(0b1011100 + 0o7) + chr(4510 - 4399) + '\144' + chr(9058 - 8957))(chr(123 - 6) + '\164' + chr(102) + chr(0b100110 + 0o7) + chr(56)))(COoctjxnPhxZ, dim=-ehT0Px3KOsy9(chr(1320 - 1272) + chr(111) + chr(0b10100 + 0o35), ord("\x08")))
|
allenai/allennlp
|
allennlp/nn/util.py
|
_rindex
|
def _rindex(sequence: Sequence[T], obj: T) -> int:
"""
Return zero-based index in the sequence of the last item whose value is equal to obj. Raises a
ValueError if there is no such item.
Parameters
----------
sequence : ``Sequence[T]``
obj : ``T``
Returns
-------
zero-based index associated to the position of the last item equal to obj
"""
for i in range(len(sequence) - 1, -1, -1):
if sequence[i] == obj:
return i
raise ValueError(f"Unable to find {obj} in sequence {sequence}.")
|
python
|
def _rindex(sequence: Sequence[T], obj: T) -> int:
"""
Return zero-based index in the sequence of the last item whose value is equal to obj. Raises a
ValueError if there is no such item.
Parameters
----------
sequence : ``Sequence[T]``
obj : ``T``
Returns
-------
zero-based index associated to the position of the last item equal to obj
"""
for i in range(len(sequence) - 1, -1, -1):
if sequence[i] == obj:
return i
raise ValueError(f"Unable to find {obj} in sequence {sequence}.")
|
[
"def",
"_rindex",
"(",
"sequence",
":",
"Sequence",
"[",
"T",
"]",
",",
"obj",
":",
"T",
")",
"->",
"int",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"sequence",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
")",
":",
"if",
"sequence",
"[",
"i",
"]",
"==",
"obj",
":",
"return",
"i",
"raise",
"ValueError",
"(",
"f\"Unable to find {obj} in sequence {sequence}.\"",
")"
] |
Return zero-based index in the sequence of the last item whose value is equal to obj. Raises a
ValueError if there is no such item.
Parameters
----------
sequence : ``Sequence[T]``
obj : ``T``
Returns
-------
zero-based index associated to the position of the last item equal to obj
|
[
"Return",
"zero",
"-",
"based",
"index",
"in",
"the",
"sequence",
"of",
"the",
"last",
"item",
"whose",
"value",
"is",
"equal",
"to",
"obj",
".",
"Raises",
"a",
"ValueError",
"if",
"there",
"is",
"no",
"such",
"item",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L749-L767
|
train
|
Returns the index in the sequence of the last item whose value is equal to obj. Raises a
ValueError if there is no such item.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwD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oxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1577 - 1529) + chr(12102 - 11991) + chr(0b110000 + 0o4) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(10190 - 10079) + '\x31' + chr(1230 - 1182) + chr(52), 0b1000), ehT0Px3KOsy9(chr(1656 - 1608) + chr(0b100100 + 0o113) + chr(1268 - 1217) + chr(533 - 480) + chr(54), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(516 - 465) + chr(0b110111) + '\x36', 7054 - 7046), ehT0Px3KOsy9('\060' + chr(111) + chr(1157 - 1108) + '\x37' + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + chr(50) + chr(0b110100) + chr(641 - 591), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + chr(2630 - 2576), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(2680 - 2625) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1100 + 0o45) + chr(678 - 630) + chr(0b101001 + 0o15), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + chr(54) + '\x30', 51767 - 51759), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(0b101010 + 0o7) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(2614 - 2503) + chr(51) + chr(2304 - 2249) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + chr(51) + '\x35' + chr(0b1000 + 0o57), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\067' + chr(0b101101 + 0o5), 8), ehT0Px3KOsy9(chr(452 - 404) + '\157' + chr(0b110110) + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1000 + 0o53) + chr(49) + chr(54), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(55) + chr(0b110010), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1675 - 1626) + chr(0b100100 + 0o20) + '\x35', 0o10), ehT0Px3KOsy9(chr(1470 - 1422) + chr(0b1101111) + chr(184 - 134) + chr(562 - 509) + chr(0b110110), 3595 - 3587), ehT0Px3KOsy9(chr(1519 - 1471) + chr(6933 - 6822) + chr(100 - 49) + chr(52) + '\x30', 0b1000), ehT0Px3KOsy9(chr(633 - 585) + chr(111) + '\063' + '\064' + chr(251 - 203), 8), ehT0Px3KOsy9(chr(632 - 584) + '\157' + '\x32' + chr(55) + chr(0b110110), 41576 - 41568), ehT0Px3KOsy9(chr(1121 - 1073) + '\x6f' + chr(49) + chr(0b110101) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\x6f' + chr(1432 - 1382) + '\x37' + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(7066 - 6955) + chr(51) + chr(1735 - 1683) + chr(1601 - 1551), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1236 - 1186) + chr(0b100000 + 0o24) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b1101 + 0o51) + chr(2616 - 2564), ord("\x08")), ehT0Px3KOsy9(chr(910 - 862) + '\157' + '\x33' + chr(0b10100 + 0o35) + chr(48), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110101) + '\x32', 20698 - 20690), ehT0Px3KOsy9(chr(0b110000) + chr(0b0 + 0o157) + chr(0b10110 + 0o33) + chr(0b110101) + chr(53), 43667 - 43659), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + '\063' + '\x34', 57936 - 57928), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b100010 + 0o20) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\157' + chr(0b110001) + '\x37' + chr(0b100000 + 0o23), 52001 - 51993), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1792 - 1738) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + chr(148 - 97) + chr(0b11 + 0o60) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(0b100011 + 0o114) + chr(50) + '\x32' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b11101 + 0o122) + chr(1901 - 1849) + chr(52), 16704 - 16696), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(51) + chr(0b11011 + 0o27), ord("\x08")), ehT0Px3KOsy9('\060' + chr(3207 - 3096) + chr(0b110001) + '\067' + chr(150 - 102), 0b1000), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(4633 - 4522) + chr(0b110001) + chr(1123 - 1072) + chr(0b10000 + 0o46), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1266 - 1218) + chr(0b1101111) + '\x35' + chr(1333 - 1285), 34910 - 34902)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x0e'), chr(0b1101 + 0o127) + chr(0b1011 + 0o132) + chr(0b1100011) + chr(111) + chr(0b1100100) + chr(101))(chr(0b1011110 + 0o27) + chr(0b10000 + 0o144) + '\x66' + chr(45) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def tPI229cP5D3V(blgtMYjOOQgD, mDuDykdz0pcm) -> ehT0Px3KOsy9:
for WVxHKyX45z_L in vQr8gNKaIaWE(c2A0yzQpDQB3(blgtMYjOOQgD) - ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49), ord("\x08")), -ehT0Px3KOsy9('\x30' + chr(0b111000 + 0o67) + chr(49), 8), -ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b111010 + 0o65) + '\x31', 8)):
if blgtMYjOOQgD[WVxHKyX45z_L] == mDuDykdz0pcm:
return WVxHKyX45z_L
raise q1QCh3W88sgk(f'Unable to find {mDuDykdz0pcm} in sequence {blgtMYjOOQgD}.')
|
allenai/allennlp
|
allennlp/nn/util.py
|
combine_tensors_and_multiply
|
def combine_tensors_and_multiply(combination: str,
tensors: List[torch.Tensor],
weights: torch.nn.Parameter) -> torch.Tensor:
"""
Like :func:`combine_tensors`, but does a weighted (linear) multiplication while combining.
This is a separate function from ``combine_tensors`` because we try to avoid instantiating
large intermediate tensors during the combination, which is possible because we know that we're
going to be multiplying by a weight vector in the end.
Parameters
----------
combination : ``str``
Same as in :func:`combine_tensors`
tensors : ``List[torch.Tensor]``
A list of tensors to combine, where the integers in the ``combination`` are (1-indexed)
positions in this list of tensors. These tensors are all expected to have either three or
four dimensions, with the final dimension being an embedding. If there are four
dimensions, one of them must have length 1.
weights : ``torch.nn.Parameter``
A vector of weights to use for the combinations. This should have shape (combined_dim,),
as calculated by :func:`get_combined_dim`.
"""
if len(tensors) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
pieces = combination.split(',')
tensor_dims = [tensor.size(-1) for tensor in tensors]
combination_dims = [_get_combination_dim(piece, tensor_dims) for piece in pieces]
dims_so_far = 0
to_sum = []
for piece, combination_dim in zip(pieces, combination_dims):
weight = weights[dims_so_far:(dims_so_far + combination_dim)]
dims_so_far += combination_dim
to_sum.append(_get_combination_and_multiply(piece, tensors, weight))
result = to_sum[0]
for result_piece in to_sum[1:]:
result = result + result_piece
return result
|
python
|
def combine_tensors_and_multiply(combination: str,
tensors: List[torch.Tensor],
weights: torch.nn.Parameter) -> torch.Tensor:
"""
Like :func:`combine_tensors`, but does a weighted (linear) multiplication while combining.
This is a separate function from ``combine_tensors`` because we try to avoid instantiating
large intermediate tensors during the combination, which is possible because we know that we're
going to be multiplying by a weight vector in the end.
Parameters
----------
combination : ``str``
Same as in :func:`combine_tensors`
tensors : ``List[torch.Tensor]``
A list of tensors to combine, where the integers in the ``combination`` are (1-indexed)
positions in this list of tensors. These tensors are all expected to have either three or
four dimensions, with the final dimension being an embedding. If there are four
dimensions, one of them must have length 1.
weights : ``torch.nn.Parameter``
A vector of weights to use for the combinations. This should have shape (combined_dim,),
as calculated by :func:`get_combined_dim`.
"""
if len(tensors) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
pieces = combination.split(',')
tensor_dims = [tensor.size(-1) for tensor in tensors]
combination_dims = [_get_combination_dim(piece, tensor_dims) for piece in pieces]
dims_so_far = 0
to_sum = []
for piece, combination_dim in zip(pieces, combination_dims):
weight = weights[dims_so_far:(dims_so_far + combination_dim)]
dims_so_far += combination_dim
to_sum.append(_get_combination_and_multiply(piece, tensors, weight))
result = to_sum[0]
for result_piece in to_sum[1:]:
result = result + result_piece
return result
|
[
"def",
"combine_tensors_and_multiply",
"(",
"combination",
":",
"str",
",",
"tensors",
":",
"List",
"[",
"torch",
".",
"Tensor",
"]",
",",
"weights",
":",
"torch",
".",
"nn",
".",
"Parameter",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"len",
"(",
"tensors",
")",
">",
"9",
":",
"raise",
"ConfigurationError",
"(",
"\"Double-digit tensor lists not currently supported\"",
")",
"combination",
"=",
"combination",
".",
"replace",
"(",
"'x'",
",",
"'1'",
")",
".",
"replace",
"(",
"'y'",
",",
"'2'",
")",
"pieces",
"=",
"combination",
".",
"split",
"(",
"','",
")",
"tensor_dims",
"=",
"[",
"tensor",
".",
"size",
"(",
"-",
"1",
")",
"for",
"tensor",
"in",
"tensors",
"]",
"combination_dims",
"=",
"[",
"_get_combination_dim",
"(",
"piece",
",",
"tensor_dims",
")",
"for",
"piece",
"in",
"pieces",
"]",
"dims_so_far",
"=",
"0",
"to_sum",
"=",
"[",
"]",
"for",
"piece",
",",
"combination_dim",
"in",
"zip",
"(",
"pieces",
",",
"combination_dims",
")",
":",
"weight",
"=",
"weights",
"[",
"dims_so_far",
":",
"(",
"dims_so_far",
"+",
"combination_dim",
")",
"]",
"dims_so_far",
"+=",
"combination_dim",
"to_sum",
".",
"append",
"(",
"_get_combination_and_multiply",
"(",
"piece",
",",
"tensors",
",",
"weight",
")",
")",
"result",
"=",
"to_sum",
"[",
"0",
"]",
"for",
"result_piece",
"in",
"to_sum",
"[",
"1",
":",
"]",
":",
"result",
"=",
"result",
"+",
"result_piece",
"return",
"result"
] |
Like :func:`combine_tensors`, but does a weighted (linear) multiplication while combining.
This is a separate function from ``combine_tensors`` because we try to avoid instantiating
large intermediate tensors during the combination, which is possible because we know that we're
going to be multiplying by a weight vector in the end.
Parameters
----------
combination : ``str``
Same as in :func:`combine_tensors`
tensors : ``List[torch.Tensor]``
A list of tensors to combine, where the integers in the ``combination`` are (1-indexed)
positions in this list of tensors. These tensors are all expected to have either three or
four dimensions, with the final dimension being an embedding. If there are four
dimensions, one of them must have length 1.
weights : ``torch.nn.Parameter``
A vector of weights to use for the combinations. This should have shape (combined_dim,),
as calculated by :func:`get_combined_dim`.
|
[
"Like",
":",
"func",
":",
"combine_tensors",
"but",
"does",
"a",
"weighted",
"(",
"linear",
")",
"multiplication",
"while",
"combining",
".",
"This",
"is",
"a",
"separate",
"function",
"from",
"combine_tensors",
"because",
"we",
"try",
"to",
"avoid",
"instantiating",
"large",
"intermediate",
"tensors",
"during",
"the",
"combination",
"which",
"is",
"possible",
"because",
"we",
"know",
"that",
"we",
"re",
"going",
"to",
"be",
"multiplying",
"by",
"a",
"weight",
"vector",
"in",
"the",
"end",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e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,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(11206 - 11095) + chr(0b110101) + '\066', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + '\x6f' + chr(0b110010) + chr(0b110111) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\064' + chr(0b101 + 0o57), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010), 27484 - 27476), ehT0Px3KOsy9('\060' + chr(0b11 + 0o154) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + chr(1760 - 1711) + chr(1812 - 1760) + chr(53), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + '\060' + chr(0b110 + 0o53), 14928 - 14920), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(2014 - 1962) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(0b1010111 + 0o30) + chr(0b10011 + 0o40) + chr(547 - 493) + chr(49), 8464 - 8456), ehT0Px3KOsy9(chr(292 - 244) + chr(111) + '\x31' + chr(49) + '\x36', 20553 - 20545), ehT0Px3KOsy9('\x30' + chr(0b101111 + 0o100) + chr(0b111 + 0o53) + chr(0b100010 + 0o20), ord("\x08")), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b11100 + 0o123) + '\x33' + chr(0b110010) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(899 - 851) + chr(137 - 26) + chr(0b10000 + 0o41) + '\x36' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + chr(1815 - 1767) + '\x33', ord("\x08")), ehT0Px3KOsy9('\060' + chr(2057 - 1946) + '\x33' + chr(52) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\x37' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(0b10111 + 0o33) + chr(0b110101) + chr(1216 - 1167), 0o10), ehT0Px3KOsy9('\060' + chr(0b100101 + 0o112) + chr(0b100 + 0o57) + chr(0b110010) + '\x36', 6932 - 6924), ehT0Px3KOsy9('\060' + chr(0b110101 + 0o72) + chr(52) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(486 - 438) + '\x6f' + chr(393 - 344) + '\x37' + chr(48), 19876 - 19868), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(955 - 903) + '\x37', 8), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + '\062' + chr(1075 - 1023), 0b1000), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(2063 - 1952) + chr(0b11100 + 0o26) + chr(0b101000 + 0o17) + chr(50), 3409 - 3401), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100001 + 0o26) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(0b110100) + chr(2420 - 2368), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + '\x30' + '\064', 33056 - 33048), ehT0Px3KOsy9(chr(196 - 148) + chr(0b1011111 + 0o20) + chr(0b110000 + 0o3) + '\x35' + chr(2271 - 2223), 60602 - 60594), ehT0Px3KOsy9('\x30' + chr(951 - 840) + chr(0b1 + 0o60) + chr(52) + chr(0b110101), 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110000 + 0o1) + chr(0b110001) + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(5091 - 4980) + chr(50) + '\x34' + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1101111) + chr(0b100000 + 0o21) + chr(1328 - 1280) + '\x35', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(49) + '\x35' + chr(935 - 882), 48189 - 48181), ehT0Px3KOsy9(chr(2031 - 1983) + chr(7942 - 7831) + chr(0b110011) + chr(54) + chr(0b1111 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + '\x37' + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(10250 - 10139) + '\x33' + chr(0b110010) + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(1373 - 1323) + chr(0b1010 + 0o53), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11111 + 0o24) + chr(0b110100) + chr(0b110000 + 0o4), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101111 + 0o2) + chr(51) + chr(1384 - 1332), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110 + 0o54) + chr(0b110011) + chr(0b10000 + 0o46), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(7575 - 7464) + chr(0b110010) + chr(0b110111) + chr(2586 - 2532), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(695 - 647) + chr(8201 - 8090) + chr(0b110101) + chr(0b101101 + 0o3), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x00'), '\144' + '\x65' + '\x63' + chr(0b1101111) + chr(6785 - 6685) + chr(0b1100101))('\x75' + '\x74' + '\146' + chr(45) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def WE2_S2o0zymS(dlz6RaNsbONT, Tyy4rche81dW, ZurHTci57aXw) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'z\xda\xcaqh\x17'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(0b11100 + 0o123) + chr(0b1011000 + 0o14) + '\145')(chr(117) + chr(0b1110100) + chr(0b1100110) + chr(880 - 835) + chr(0b100110 + 0o22))):
if c2A0yzQpDQB3(Tyy4rche81dW) > ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(49), 0b1000):
raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b'j\xd0\xd1`k\x00\xec\x06\x98){\xa4Q7\x85\x90\xda\xb9UXK\xbd\xc9M\x17\xe4\x86\n8\x81&\x18\x84\xc9\xb4\xbb\x900\xe7\x9e]\xca\xd4rh\x17\xb5\x07\x95'), '\x64' + chr(0b1100101) + chr(0b101110 + 0o65) + chr(0b1100010 + 0o15) + '\x64' + chr(101))(chr(10369 - 10252) + chr(116) + chr(8594 - 8492) + chr(0b100110 + 0o7) + '\x38'))
dlz6RaNsbONT = dlz6RaNsbONT.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'V'), '\x64' + chr(101) + '\x63' + '\x6f' + chr(100) + chr(415 - 314))('\165' + chr(0b1101010 + 0o12) + chr(0b1000001 + 0o45) + chr(0b101101) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f'), '\x64' + chr(101) + '\143' + chr(8365 - 8254) + chr(9559 - 9459) + chr(0b1101 + 0o130))(chr(117) + '\164' + chr(0b1100110 + 0o0) + chr(45) + chr(56))).replace(xafqLlk3kkUe(SXOLrMavuUCe(b'W'), chr(0b101 + 0o137) + '\x65' + chr(99) + chr(111) + chr(408 - 308) + chr(101))(chr(0b1110101) + chr(0b1110100) + chr(0b1100101 + 0o1) + chr(1622 - 1577) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1c'), chr(0b110001 + 0o63) + chr(6012 - 5911) + chr(99) + '\157' + chr(0b1100100) + chr(0b1010110 + 0o17))(chr(0b1000101 + 0o60) + chr(116) + chr(0b101110 + 0o70) + '\055' + chr(2769 - 2713)))
X3b3u1PDVdmt = dlz6RaNsbONT.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\x02'), '\x64' + chr(0b1100101) + chr(99) + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(0b100011 + 0o122) + '\x74' + chr(2989 - 2887) + '\x2d' + '\x38'))
SV4v0kTvZfE2 = [LK3cpXJU3UM0.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + '\061', 0b1000)) for LK3cpXJU3UM0 in Tyy4rche81dW]
XAG4hoj0tLO_ = [ReIZ49pEMGQ_(N0fpDLYvEEVW, SV4v0kTvZfE2) for N0fpDLYvEEVW in X3b3u1PDVdmt]
igaIofBQ_KTW = ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110000), 0o10)
WqCEIWj5sufb = []
for (N0fpDLYvEEVW, IgmIJZDnEoo4) in pZ0NK2y6HRbn(X3b3u1PDVdmt, XAG4hoj0tLO_):
C0mVSPj6WjvB = ZurHTci57aXw[igaIofBQ_KTW:igaIofBQ_KTW + IgmIJZDnEoo4]
igaIofBQ_KTW += IgmIJZDnEoo4
xafqLlk3kkUe(WqCEIWj5sufb, xafqLlk3kkUe(SXOLrMavuUCe(b'O\xcf\xd4gi\x01'), '\144' + '\x65' + '\143' + chr(111) + '\144' + '\x65')(chr(460 - 343) + chr(0b1110100) + '\x66' + chr(0b11001 + 0o24) + chr(56)))(RTQLwR5Mo0tS(N0fpDLYvEEVW, Tyy4rche81dW, C0mVSPj6WjvB))
ShZmEKfTkAOZ = WqCEIWj5sufb[ehT0Px3KOsy9('\060' + chr(0b101100 + 0o103) + chr(48), 8)]
for wNxHDuOUWYeB in WqCEIWj5sufb[ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101110 + 0o3), 8):]:
ShZmEKfTkAOZ = ShZmEKfTkAOZ + wNxHDuOUWYeB
return ShZmEKfTkAOZ
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_combined_dim
|
def get_combined_dim(combination: str, tensor_dims: List[int]) -> int:
"""
For use with :func:`combine_tensors`. This function computes the resultant dimension when
calling ``combine_tensors(combination, tensors)``, when the tensor dimension is known. This is
necessary for knowing the sizes of weight matrices when building models that use
``combine_tensors``.
Parameters
----------
combination : ``str``
A comma-separated list of combination pieces, like ``"1,2,1*2"``, specified identically to
``combination`` in :func:`combine_tensors`.
tensor_dims : ``List[int]``
A list of tensor dimensions, where each dimension is from the `last axis` of the tensors
that will be input to :func:`combine_tensors`.
"""
if len(tensor_dims) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
return sum([_get_combination_dim(piece, tensor_dims) for piece in combination.split(',')])
|
python
|
def get_combined_dim(combination: str, tensor_dims: List[int]) -> int:
"""
For use with :func:`combine_tensors`. This function computes the resultant dimension when
calling ``combine_tensors(combination, tensors)``, when the tensor dimension is known. This is
necessary for knowing the sizes of weight matrices when building models that use
``combine_tensors``.
Parameters
----------
combination : ``str``
A comma-separated list of combination pieces, like ``"1,2,1*2"``, specified identically to
``combination`` in :func:`combine_tensors`.
tensor_dims : ``List[int]``
A list of tensor dimensions, where each dimension is from the `last axis` of the tensors
that will be input to :func:`combine_tensors`.
"""
if len(tensor_dims) > 9:
raise ConfigurationError("Double-digit tensor lists not currently supported")
combination = combination.replace('x', '1').replace('y', '2')
return sum([_get_combination_dim(piece, tensor_dims) for piece in combination.split(',')])
|
[
"def",
"get_combined_dim",
"(",
"combination",
":",
"str",
",",
"tensor_dims",
":",
"List",
"[",
"int",
"]",
")",
"->",
"int",
":",
"if",
"len",
"(",
"tensor_dims",
")",
">",
"9",
":",
"raise",
"ConfigurationError",
"(",
"\"Double-digit tensor lists not currently supported\"",
")",
"combination",
"=",
"combination",
".",
"replace",
"(",
"'x'",
",",
"'1'",
")",
".",
"replace",
"(",
"'y'",
",",
"'2'",
")",
"return",
"sum",
"(",
"[",
"_get_combination_dim",
"(",
"piece",
",",
"tensor_dims",
")",
"for",
"piece",
"in",
"combination",
".",
"split",
"(",
"','",
")",
"]",
")"
] |
For use with :func:`combine_tensors`. This function computes the resultant dimension when
calling ``combine_tensors(combination, tensors)``, when the tensor dimension is known. This is
necessary for knowing the sizes of weight matrices when building models that use
``combine_tensors``.
Parameters
----------
combination : ``str``
A comma-separated list of combination pieces, like ``"1,2,1*2"``, specified identically to
``combination`` in :func:`combine_tensors`.
tensor_dims : ``List[int]``
A list of tensor dimensions, where each dimension is from the `last axis` of the tensors
that will be input to :func:`combine_tensors`.
|
[
"For",
"use",
"with",
":",
"func",
":",
"combine_tensors",
".",
"This",
"function",
"computes",
"the",
"resultant",
"dimension",
"when",
"calling",
"combine_tensors",
"(",
"combination",
"tensors",
")",
"when",
"the",
"tensor",
"dimension",
"is",
"known",
".",
"This",
"is",
"necessary",
"for",
"knowing",
"the",
"sizes",
"of",
"weight",
"matrices",
"when",
"building",
"models",
"that",
"use",
"combine_tensors",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L882-L901
|
train
|
Returns the dimension of the combined tensor.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6A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gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + chr(2089 - 2036) + chr(1310 - 1258), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(736 - 683) + chr(0b110101 + 0o1), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010 + 0o0) + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b1001011 + 0o44) + chr(0b110011) + chr(0b110100) + chr(0b100011 + 0o15), 5091 - 5083), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b10011 + 0o36) + chr(2334 - 2281), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1921 - 1872) + '\x31' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(1134 - 1086) + '\x6f' + chr(0b110011) + chr(0b1011 + 0o50) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1010101 + 0o32) + chr(0b110001) + '\062' + chr(0b0 + 0o60), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(0b10100 + 0o37) + chr(0b101110 + 0o4), 45096 - 45088), ehT0Px3KOsy9(chr(2029 - 1981) + '\157' + chr(378 - 328) + chr(0b100001 + 0o20) + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + chr(11954 - 11843) + chr(52) + chr(0b110000), 14419 - 14411), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1637 - 1583) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b110100) + chr(0b100110 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(1930 - 1882) + chr(111) + chr(51) + '\x36', 51845 - 51837), ehT0Px3KOsy9(chr(48) + chr(0b1011010 + 0o25) + '\x31' + '\x33' + chr(52), 60741 - 60733), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2259 - 2208) + chr(2656 - 2604) + '\060', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + chr(0b110110), 33734 - 33726), ehT0Px3KOsy9(chr(1032 - 984) + '\x6f' + chr(1821 - 1770) + chr(0b110110) + chr(0b11111 + 0o30), 12144 - 12136), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1111 + 0o43) + chr(2066 - 2016) + chr(619 - 571), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(12175 - 12064) + chr(0b101001 + 0o10) + '\066' + chr(0b101011 + 0o12), 0b1000), ehT0Px3KOsy9(chr(786 - 738) + chr(111) + '\x33' + '\x30' + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + '\x37' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(279 - 230) + chr(0b110110) + chr(0b1000 + 0o57), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x33' + '\064' + '\067', 15178 - 15170), ehT0Px3KOsy9(chr(627 - 579) + '\157' + '\062' + '\060' + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1270 - 1220) + '\x30' + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(0b1010111 + 0o30) + chr(0b110011) + chr(48) + '\x32', 8), ehT0Px3KOsy9(chr(48) + chr(0b111101 + 0o62) + chr(1180 - 1130) + chr(53) + '\061', 59591 - 59583), ehT0Px3KOsy9(chr(2182 - 2134) + '\x6f' + chr(2073 - 2024) + chr(0b110010) + chr(1729 - 1678), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100100 + 0o17) + chr(0b100000 + 0o23) + chr(0b110000), 49520 - 49512), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\x6f' + '\x31' + '\066' + chr(825 - 774), 40329 - 40321), ehT0Px3KOsy9(chr(48) + '\157' + chr(952 - 900) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(335 - 286) + chr(0b110110) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10000 + 0o42) + chr(0b110000) + chr(1454 - 1401), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b110010) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + chr(0b11000 + 0o37) + chr(675 - 626), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b11100 + 0o25) + chr(2092 - 2041) + chr(2263 - 2212), 29565 - 29557), ehT0Px3KOsy9(chr(48) + '\157' + '\063' + chr(52) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + '\x36' + chr(55), 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(555 - 504), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(7045 - 6934) + chr(0b0 + 0o65) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x82'), '\x64' + chr(0b101 + 0o140) + '\x63' + chr(0b1101111) + chr(0b1100100) + chr(8418 - 8317))(chr(117) + chr(0b1110100) + chr(0b1100110) + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def g_fe6OsTtF2L(dlz6RaNsbONT, SV4v0kTvZfE2) -> ehT0Px3KOsy9:
if c2A0yzQpDQB3(SV4v0kTvZfE2) > ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101000 + 0o11) + chr(745 - 696), 45798 - 45790):
raise h0iXqtiKVeKg(xafqLlk3kkUe(SXOLrMavuUCe(b"\xe8\x01f\x82\xa1.\xf643\xeaIFEj9\x8e}\x98\xe2U\xae\x96\x04\x93\xf0\xa5\xac\xc6'\xf8\x10P\x04\xf7\xf3\x17/\x8e\x0e#\xdf\x1bc\x90\xa29\xaf5>"), '\144' + chr(6022 - 5921) + chr(0b100 + 0o137) + chr(0b1101111) + chr(100) + chr(0b110100 + 0o61))(chr(0b1110101) + '\164' + '\146' + '\x2d' + '\070'))
dlz6RaNsbONT = dlz6RaNsbONT.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4'), '\144' + '\145' + '\143' + chr(0b111101 + 0o62) + '\144' + chr(9388 - 9287))('\165' + chr(116) + chr(0b1001100 + 0o32) + chr(45) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d'), '\x64' + chr(101) + chr(0b110100 + 0o57) + chr(0b1101111 + 0o0) + '\144' + '\x65')('\165' + chr(0b1101110 + 0o6) + '\146' + chr(0b101101) + chr(0b111000))).replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd5'), '\x64' + chr(8493 - 8392) + chr(0b10001 + 0o122) + chr(12077 - 11966) + '\144' + chr(3690 - 3589))(chr(0b1011 + 0o152) + chr(116) + chr(0b1100110) + chr(45) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9e'), '\x64' + '\145' + '\x63' + '\x6f' + chr(100) + chr(0b110010 + 0o63))('\x75' + chr(0b1110100) + '\146' + '\x2d' + chr(0b1100 + 0o54)))
return xkxBmo49x2An([ReIZ49pEMGQ_(N0fpDLYvEEVW, SV4v0kTvZfE2) for N0fpDLYvEEVW in xafqLlk3kkUe(dlz6RaNsbONT, xafqLlk3kkUe(SXOLrMavuUCe(b'\xdf\x1e\x7f\x89\xb9'), '\x64' + '\145' + chr(0b1100011) + '\x6f' + chr(0b110001 + 0o63) + chr(0b1100101))(chr(0b111001 + 0o74) + '\164' + chr(102) + chr(0b11100 + 0o21) + chr(1193 - 1137)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\x80'), chr(100) + chr(0b10100 + 0o121) + '\x63' + chr(834 - 723) + chr(0b101011 + 0o71) + chr(101))(chr(11783 - 11666) + '\x74' + chr(102) + chr(501 - 456) + chr(1335 - 1279)))])
|
allenai/allennlp
|
allennlp/nn/util.py
|
logsumexp
|
def logsumexp(tensor: torch.Tensor,
dim: int = -1,
keepdim: bool = False) -> torch.Tensor:
"""
A numerically stable computation of logsumexp. This is mathematically equivalent to
`tensor.exp().sum(dim, keep=keepdim).log()`. This function is typically used for summing log
probabilities.
Parameters
----------
tensor : torch.FloatTensor, required.
A tensor of arbitrary size.
dim : int, optional (default = -1)
The dimension of the tensor to apply the logsumexp to.
keepdim: bool, optional (default = False)
Whether to retain a dimension of size one at the dimension we reduce over.
"""
max_score, _ = tensor.max(dim, keepdim=keepdim)
if keepdim:
stable_vec = tensor - max_score
else:
stable_vec = tensor - max_score.unsqueeze(dim)
return max_score + (stable_vec.exp().sum(dim, keepdim=keepdim)).log()
|
python
|
def logsumexp(tensor: torch.Tensor,
dim: int = -1,
keepdim: bool = False) -> torch.Tensor:
"""
A numerically stable computation of logsumexp. This is mathematically equivalent to
`tensor.exp().sum(dim, keep=keepdim).log()`. This function is typically used for summing log
probabilities.
Parameters
----------
tensor : torch.FloatTensor, required.
A tensor of arbitrary size.
dim : int, optional (default = -1)
The dimension of the tensor to apply the logsumexp to.
keepdim: bool, optional (default = False)
Whether to retain a dimension of size one at the dimension we reduce over.
"""
max_score, _ = tensor.max(dim, keepdim=keepdim)
if keepdim:
stable_vec = tensor - max_score
else:
stable_vec = tensor - max_score.unsqueeze(dim)
return max_score + (stable_vec.exp().sum(dim, keepdim=keepdim)).log()
|
[
"def",
"logsumexp",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"dim",
":",
"int",
"=",
"-",
"1",
",",
"keepdim",
":",
"bool",
"=",
"False",
")",
"->",
"torch",
".",
"Tensor",
":",
"max_score",
",",
"_",
"=",
"tensor",
".",
"max",
"(",
"dim",
",",
"keepdim",
"=",
"keepdim",
")",
"if",
"keepdim",
":",
"stable_vec",
"=",
"tensor",
"-",
"max_score",
"else",
":",
"stable_vec",
"=",
"tensor",
"-",
"max_score",
".",
"unsqueeze",
"(",
"dim",
")",
"return",
"max_score",
"+",
"(",
"stable_vec",
".",
"exp",
"(",
")",
".",
"sum",
"(",
"dim",
",",
"keepdim",
"=",
"keepdim",
")",
")",
".",
"log",
"(",
")"
] |
A numerically stable computation of logsumexp. This is mathematically equivalent to
`tensor.exp().sum(dim, keep=keepdim).log()`. This function is typically used for summing log
probabilities.
Parameters
----------
tensor : torch.FloatTensor, required.
A tensor of arbitrary size.
dim : int, optional (default = -1)
The dimension of the tensor to apply the logsumexp to.
keepdim: bool, optional (default = False)
Whether to retain a dimension of size one at the dimension we reduce over.
|
[
"A",
"numerically",
"stable",
"computation",
"of",
"logsumexp",
".",
"This",
"is",
"mathematically",
"equivalent",
"to",
"tensor",
".",
"exp",
"()",
".",
"sum",
"(",
"dim",
"keep",
"=",
"keepdim",
")",
".",
"log",
"()",
".",
"This",
"function",
"is",
"typically",
"used",
"for",
"summing",
"log",
"probabilities",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L919-L941
|
train
|
A numerically stable computation of logsumexp.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,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BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(2426 - 2376) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(0b110110) + chr(0b11011 + 0o26), 0b1000), ehT0Px3KOsy9(chr(670 - 622) + '\x6f' + '\x33' + '\063' + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(334 - 283) + chr(0b11111 + 0o24), 0b1000), ehT0Px3KOsy9(chr(711 - 663) + '\157' + '\061' + '\063' + chr(2179 - 2127), 0b1000), ehT0Px3KOsy9(chr(1020 - 972) + chr(0b1101111) + chr(0b10 + 0o61) + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110111) + chr(51), 58417 - 58409), ehT0Px3KOsy9(chr(1614 - 1566) + chr(0b110001 + 0o76) + chr(1988 - 1938) + chr(0b110011) + chr(48), 24439 - 24431), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(0b101100 + 0o10) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(111) + '\062' + chr(0b110 + 0o60) + chr(54), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + '\063' + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(10972 - 10861) + chr(0b10 + 0o61) + '\x36' + chr(51), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100110 + 0o15) + chr(0b101011 + 0o7) + chr(1184 - 1132), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101100 + 0o3) + chr(50) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(0b110010) + chr(913 - 859), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1271 - 1222) + '\066' + chr(0b100001 + 0o23), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101110 + 0o1) + chr(0b110001) + '\x31' + chr(2231 - 2182), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + chr(2016 - 1967) + chr(0b110001), 8), ehT0Px3KOsy9('\060' + '\157' + '\063' + '\x37', 43112 - 43104), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(52) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(1567 - 1456) + chr(371 - 321) + chr(90 - 36) + chr(55), 0o10), ehT0Px3KOsy9(chr(1216 - 1168) + '\x6f' + chr(50) + chr(53) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(157 - 109) + '\x6f' + '\062' + chr(0b111 + 0o52) + chr(1103 - 1053), 21200 - 21192), ehT0Px3KOsy9('\x30' + chr(4803 - 4692) + chr(0b10101 + 0o34) + chr(0b1111 + 0o47) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1000 + 0o147) + '\063' + chr(54) + chr(1192 - 1143), 8), ehT0Px3KOsy9(chr(0b10010 + 0o36) + '\x6f' + chr(2471 - 2421) + chr(0b110111) + chr(52), 58316 - 58308), ehT0Px3KOsy9(chr(1684 - 1636) + '\x6f' + chr(50) + chr(0b110111) + chr(0b110100), 8), ehT0Px3KOsy9('\060' + '\157' + chr(0b10001 + 0o46) + chr(0b1111 + 0o44), 8), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(4618 - 4507) + chr(49) + chr(0b101010 + 0o7) + chr(0b1110 + 0o44), 0o10), ehT0Px3KOsy9(chr(995 - 947) + '\157' + '\x31' + '\066' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(11228 - 11117) + chr(0b110001) + chr(50) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(1876 - 1765) + '\x31' + chr(53) + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b110111 + 0o70) + '\062' + chr(0b10110 + 0o35) + chr(0b110100), 19636 - 19628), ehT0Px3KOsy9('\x30' + chr(3552 - 3441) + chr(1128 - 1078) + '\067' + '\x34', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b101 + 0o152) + chr(51) + chr(2069 - 2015) + chr(50), 29503 - 29495), ehT0Px3KOsy9(chr(0b110000) + chr(4537 - 4426) + '\x33' + chr(0b110000 + 0o6) + chr(1480 - 1431), 8), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(6398 - 6287) + chr(0b110 + 0o54) + chr(0b1 + 0o64) + chr(0b110000), 5519 - 5511), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(53) + chr(1949 - 1894), 0o10), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\x6f' + chr(1737 - 1688) + chr(48) + chr(54), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(53) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfa'), '\144' + chr(0b1 + 0o144) + '\143' + chr(0b1100110 + 0o11) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(0b1100 + 0o150) + '\146' + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def nHBuZl689b4D(LK3cpXJU3UM0, Nl_JhL3qUwSN=-ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2307 - 2258), ord("\x08")), JV7aKBs7fw38=ehT0Px3KOsy9(chr(919 - 871) + chr(0b1101111) + chr(510 - 462), ord("\x08"))) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x80\x94\xb1\xe83n'), chr(8806 - 8706) + '\145' + chr(0b1100011) + chr(0b1001010 + 0o45) + chr(5422 - 5322) + chr(101))('\x75' + '\x74' + chr(102) + chr(45) + chr(0b110010 + 0o6))):
(irL68OOl4rza, VNGQdHSFPrso) = LK3cpXJU3UM0.tsdjvlgh9gDP(Nl_JhL3qUwSN, keepdim=JV7aKBs7fw38)
if JV7aKBs7fw38:
e0FymxYR2Ltk = LK3cpXJU3UM0 - irL68OOl4rza
else:
e0FymxYR2Ltk = LK3cpXJU3UM0 - irL68OOl4rza.unsqueeze(Nl_JhL3qUwSN)
return irL68OOl4rza + xafqLlk3kkUe(e0FymxYR2Ltk.exp().sum(Nl_JhL3qUwSN, keepdim=JV7aKBs7fw38), xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8\x9e\xb8'), chr(0b1100100) + chr(0b111011 + 0o52) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(9365 - 9264))(chr(117) + chr(5178 - 5062) + chr(102) + chr(0b101101) + chr(0b111000)))()
|
allenai/allennlp
|
allennlp/nn/util.py
|
flatten_and_batch_shift_indices
|
def flatten_and_batch_shift_indices(indices: torch.Tensor,
sequence_length: int) -> torch.Tensor:
"""
This is a subroutine for :func:`~batched_index_select`. The given ``indices`` of size
``(batch_size, d_1, ..., d_n)`` indexes into dimension 2 of a target tensor, which has size
``(batch_size, sequence_length, embedding_size)``. This function returns a vector that
correctly indexes into the flattened target. The sequence length of the target must be
provided to compute the appropriate offsets.
.. code-block:: python
indices = torch.ones([2,3], dtype=torch.long)
# Sequence length of the target tensor.
sequence_length = 10
shifted_indices = flatten_and_batch_shift_indices(indices, sequence_length)
# Indices into the second element in the batch are correctly shifted
# to take into account that the target tensor will be flattened before
# the indices are applied.
assert shifted_indices == [1, 1, 1, 11, 11, 11]
Parameters
----------
indices : ``torch.LongTensor``, required.
sequence_length : ``int``, required.
The length of the sequence the indices index into.
This must be the second dimension of the tensor.
Returns
-------
offset_indices : ``torch.LongTensor``
"""
# Shape: (batch_size)
offsets = get_range_vector(indices.size(0), get_device_of(indices)) * sequence_length
for _ in range(len(indices.size()) - 1):
offsets = offsets.unsqueeze(1)
# Shape: (batch_size, d_1, ..., d_n)
offset_indices = indices + offsets
# Shape: (batch_size * d_1 * ... * d_n)
offset_indices = offset_indices.view(-1)
return offset_indices
|
python
|
def flatten_and_batch_shift_indices(indices: torch.Tensor,
sequence_length: int) -> torch.Tensor:
"""
This is a subroutine for :func:`~batched_index_select`. The given ``indices`` of size
``(batch_size, d_1, ..., d_n)`` indexes into dimension 2 of a target tensor, which has size
``(batch_size, sequence_length, embedding_size)``. This function returns a vector that
correctly indexes into the flattened target. The sequence length of the target must be
provided to compute the appropriate offsets.
.. code-block:: python
indices = torch.ones([2,3], dtype=torch.long)
# Sequence length of the target tensor.
sequence_length = 10
shifted_indices = flatten_and_batch_shift_indices(indices, sequence_length)
# Indices into the second element in the batch are correctly shifted
# to take into account that the target tensor will be flattened before
# the indices are applied.
assert shifted_indices == [1, 1, 1, 11, 11, 11]
Parameters
----------
indices : ``torch.LongTensor``, required.
sequence_length : ``int``, required.
The length of the sequence the indices index into.
This must be the second dimension of the tensor.
Returns
-------
offset_indices : ``torch.LongTensor``
"""
# Shape: (batch_size)
offsets = get_range_vector(indices.size(0), get_device_of(indices)) * sequence_length
for _ in range(len(indices.size()) - 1):
offsets = offsets.unsqueeze(1)
# Shape: (batch_size, d_1, ..., d_n)
offset_indices = indices + offsets
# Shape: (batch_size * d_1 * ... * d_n)
offset_indices = offset_indices.view(-1)
return offset_indices
|
[
"def",
"flatten_and_batch_shift_indices",
"(",
"indices",
":",
"torch",
".",
"Tensor",
",",
"sequence_length",
":",
"int",
")",
"->",
"torch",
".",
"Tensor",
":",
"# Shape: (batch_size)",
"offsets",
"=",
"get_range_vector",
"(",
"indices",
".",
"size",
"(",
"0",
")",
",",
"get_device_of",
"(",
"indices",
")",
")",
"*",
"sequence_length",
"for",
"_",
"in",
"range",
"(",
"len",
"(",
"indices",
".",
"size",
"(",
")",
")",
"-",
"1",
")",
":",
"offsets",
"=",
"offsets",
".",
"unsqueeze",
"(",
"1",
")",
"# Shape: (batch_size, d_1, ..., d_n)",
"offset_indices",
"=",
"indices",
"+",
"offsets",
"# Shape: (batch_size * d_1 * ... * d_n)",
"offset_indices",
"=",
"offset_indices",
".",
"view",
"(",
"-",
"1",
")",
"return",
"offset_indices"
] |
This is a subroutine for :func:`~batched_index_select`. The given ``indices`` of size
``(batch_size, d_1, ..., d_n)`` indexes into dimension 2 of a target tensor, which has size
``(batch_size, sequence_length, embedding_size)``. This function returns a vector that
correctly indexes into the flattened target. The sequence length of the target must be
provided to compute the appropriate offsets.
.. code-block:: python
indices = torch.ones([2,3], dtype=torch.long)
# Sequence length of the target tensor.
sequence_length = 10
shifted_indices = flatten_and_batch_shift_indices(indices, sequence_length)
# Indices into the second element in the batch are correctly shifted
# to take into account that the target tensor will be flattened before
# the indices are applied.
assert shifted_indices == [1, 1, 1, 11, 11, 11]
Parameters
----------
indices : ``torch.LongTensor``, required.
sequence_length : ``int``, required.
The length of the sequence the indices index into.
This must be the second dimension of the tensor.
Returns
-------
offset_indices : ``torch.LongTensor``
|
[
"This",
"is",
"a",
"subroutine",
"for",
":",
"func",
":",
"~batched_index_select",
".",
"The",
"given",
"indices",
"of",
"size",
"(",
"batch_size",
"d_1",
"...",
"d_n",
")",
"indexes",
"into",
"dimension",
"2",
"of",
"a",
"target",
"tensor",
"which",
"has",
"size",
"(",
"batch_size",
"sequence_length",
"embedding_size",
")",
".",
"This",
"function",
"returns",
"a",
"vector",
"that",
"correctly",
"indexes",
"into",
"the",
"flattened",
"target",
".",
"The",
"sequence",
"length",
"of",
"the",
"target",
"must",
"be",
"provided",
"to",
"compute",
"the",
"appropriate",
"offsets",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L954-L995
|
train
|
This function is a subroutine for batched index_select. It returns a vector that is flattened with the given indices shifted into the batch_size d_1... d_n.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1H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Ie,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(7587 - 7476) + chr(49) + chr(48) + chr(0b10000 + 0o42), 21879 - 21871), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(0b1000 + 0o54) + chr(50), 29072 - 29064), ehT0Px3KOsy9(chr(48) + chr(0b10101 + 0o132) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\x6f' + chr(0b101010 + 0o11) + chr(223 - 174) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(54) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(3461 - 3350) + chr(546 - 497) + chr(0b110010) + chr(2060 - 2006), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10001 + 0o42) + chr(195 - 146) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101110 + 0o1) + chr(0b110010) + '\x35' + '\060', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(0b110110) + '\x33', 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\065' + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(1611 - 1563) + '\x6f' + chr(795 - 746) + chr(0b110011) + chr(0b11000 + 0o30), 9626 - 9618), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\157' + chr(1469 - 1419) + '\060' + chr(599 - 548), 0b1000), ehT0Px3KOsy9(chr(729 - 681) + chr(111) + chr(51) + chr(0b110101) + chr(0b10011 + 0o36), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + '\x32' + '\062', 0o10), ehT0Px3KOsy9('\060' + chr(12261 - 12150) + chr(214 - 164) + chr(449 - 401) + chr(0b11000 + 0o35), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + '\x35' + '\066', 0b1000), ehT0Px3KOsy9('\060' + chr(0b11 + 0o154) + '\062' + '\x32' + chr(52), 2618 - 2610), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(8587 - 8476) + '\062' + '\x36' + chr(2218 - 2169), 10521 - 10513), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + chr(1137 - 1086) + '\066' + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + '\x37', 0b1000), ehT0Px3KOsy9('\060' + chr(289 - 178) + '\x33' + '\x37' + chr(0b110100), 24565 - 24557), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(193 - 145) + '\061', 41621 - 41613), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b111001 + 0o66) + '\063' + chr(54) + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10010 + 0o37) + '\x34' + chr(0b111 + 0o60), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1111 + 0o140) + '\x36', 8), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(963 - 852) + chr(0b100001 + 0o20) + '\x35' + '\x34', 45612 - 45604), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + '\062' + chr(976 - 927) + chr(49), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(2078 - 2030) + chr(52), 18639 - 18631), ehT0Px3KOsy9(chr(945 - 897) + chr(0b110000 + 0o77) + '\061' + chr(0b10 + 0o63), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\x6f' + chr(1752 - 1701) + chr(947 - 899) + '\x35', 29330 - 29322), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(50) + '\064' + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10000 + 0o137) + '\x31' + chr(0b10111 + 0o33) + chr(0b110110), 8), ehT0Px3KOsy9('\x30' + chr(0b1011011 + 0o24) + chr(2489 - 2436) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b110001 + 0o76) + chr(0b110011) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(1747 - 1697) + chr(53) + chr(936 - 883), 34078 - 34070), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b10111 + 0o130) + '\062' + '\x33' + chr(0b110001), 43502 - 43494), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + chr(51) + '\x33' + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1100000 + 0o17) + '\x31' + '\x37', 8), ehT0Px3KOsy9('\060' + chr(8932 - 8821) + chr(0b11000 + 0o32) + chr(53) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(1562 - 1451) + chr(53) + '\061', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1569 - 1521) + chr(0b1101111) + chr(1791 - 1738) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'l'), chr(0b1100100) + '\x65' + chr(0b1001000 + 0o33) + '\x6f' + '\x64' + '\145')('\165' + '\164' + chr(0b1100110) + '\x2d' + chr(0b11111 + 0o31)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def JVV9rk8jelKh(pIcoaXENl5Pw, KpLkLOIdDwiZ) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x16\xc7h\xb8\xdc$'), chr(0b1100100) + chr(622 - 521) + '\143' + '\157' + chr(0b1100100) + '\x65')(chr(0b11001 + 0o134) + chr(0b1110100) + chr(102) + '\x2d' + chr(56))):
m6XSiwJFJw1f = BNXuFoJp86Jx(pIcoaXENl5Pw.NLcc3BCJnQka(ehT0Px3KOsy9('\x30' + '\157' + chr(561 - 513), 0b1000)), yRvvZkDFNAV9(pIcoaXENl5Pw)) * KpLkLOIdDwiZ
for VNGQdHSFPrso in vQr8gNKaIaWE(c2A0yzQpDQB3(xafqLlk3kkUe(pIcoaXENl5Pw, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c\xeee\xa8\x80\x14\x8a\xe2\xddx3\xe2'), chr(7953 - 7853) + chr(0b1100101) + '\143' + chr(3047 - 2936) + '\144' + '\x65')(chr(0b11100 + 0o131) + chr(0b1110100) + chr(0b101110 + 0o70) + chr(1544 - 1499) + '\070'))()) - ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(11645 - 11534) + '\061', 0o10)):
m6XSiwJFJw1f = m6XSiwJFJw1f.unsqueeze(ehT0Px3KOsy9(chr(1004 - 956) + chr(0b1010100 + 0o33) + '\x31', 8))
bwSXdgjBGfFO = pIcoaXENl5Pw + m6XSiwJFJw1f
bwSXdgjBGfFO = bwSXdgjBGfFO.view(-ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061', 8))
return bwSXdgjBGfFO
|
allenai/allennlp
|
allennlp/nn/util.py
|
batched_index_select
|
def batched_index_select(target: torch.Tensor,
indices: torch.LongTensor,
flattened_indices: Optional[torch.LongTensor] = None) -> torch.Tensor:
"""
The given ``indices`` of size ``(batch_size, d_1, ..., d_n)`` indexes into the sequence
dimension (dimension 2) of the target, which has size ``(batch_size, sequence_length,
embedding_size)``.
This function returns selected values in the target with respect to the provided indices, which
have size ``(batch_size, d_1, ..., d_n, embedding_size)``. This can use the optionally
precomputed :func:`~flattened_indices` with size ``(batch_size * d_1 * ... * d_n)`` if given.
An example use case of this function is looking up the start and end indices of spans in a
sequence tensor. This is used in the
:class:`~allennlp.models.coreference_resolution.CoreferenceResolver`. Model to select
contextual word representations corresponding to the start and end indices of mentions. The key
reason this can't be done with basic torch functions is that we want to be able to use look-up
tensors with an arbitrary number of dimensions (for example, in the coref model, we don't know
a-priori how many spans we are looking up).
Parameters
----------
target : ``torch.Tensor``, required.
A 3 dimensional tensor of shape (batch_size, sequence_length, embedding_size).
This is the tensor to be indexed.
indices : ``torch.LongTensor``
A tensor of shape (batch_size, ...), where each element is an index into the
``sequence_length`` dimension of the ``target`` tensor.
flattened_indices : Optional[torch.Tensor], optional (default = None)
An optional tensor representing the result of calling :func:~`flatten_and_batch_shift_indices`
on ``indices``. This is helpful in the case that the indices can be flattened once and
cached for many batch lookups.
Returns
-------
selected_targets : ``torch.Tensor``
A tensor with shape [indices.size(), target.size(-1)] representing the embedded indices
extracted from the batch flattened target tensor.
"""
if flattened_indices is None:
# Shape: (batch_size * d_1 * ... * d_n)
flattened_indices = flatten_and_batch_shift_indices(indices, target.size(1))
# Shape: (batch_size * sequence_length, embedding_size)
flattened_target = target.view(-1, target.size(-1))
# Shape: (batch_size * d_1 * ... * d_n, embedding_size)
flattened_selected = flattened_target.index_select(0, flattened_indices)
selected_shape = list(indices.size()) + [target.size(-1)]
# Shape: (batch_size, d_1, ..., d_n, embedding_size)
selected_targets = flattened_selected.view(*selected_shape)
return selected_targets
|
python
|
def batched_index_select(target: torch.Tensor,
indices: torch.LongTensor,
flattened_indices: Optional[torch.LongTensor] = None) -> torch.Tensor:
"""
The given ``indices`` of size ``(batch_size, d_1, ..., d_n)`` indexes into the sequence
dimension (dimension 2) of the target, which has size ``(batch_size, sequence_length,
embedding_size)``.
This function returns selected values in the target with respect to the provided indices, which
have size ``(batch_size, d_1, ..., d_n, embedding_size)``. This can use the optionally
precomputed :func:`~flattened_indices` with size ``(batch_size * d_1 * ... * d_n)`` if given.
An example use case of this function is looking up the start and end indices of spans in a
sequence tensor. This is used in the
:class:`~allennlp.models.coreference_resolution.CoreferenceResolver`. Model to select
contextual word representations corresponding to the start and end indices of mentions. The key
reason this can't be done with basic torch functions is that we want to be able to use look-up
tensors with an arbitrary number of dimensions (for example, in the coref model, we don't know
a-priori how many spans we are looking up).
Parameters
----------
target : ``torch.Tensor``, required.
A 3 dimensional tensor of shape (batch_size, sequence_length, embedding_size).
This is the tensor to be indexed.
indices : ``torch.LongTensor``
A tensor of shape (batch_size, ...), where each element is an index into the
``sequence_length`` dimension of the ``target`` tensor.
flattened_indices : Optional[torch.Tensor], optional (default = None)
An optional tensor representing the result of calling :func:~`flatten_and_batch_shift_indices`
on ``indices``. This is helpful in the case that the indices can be flattened once and
cached for many batch lookups.
Returns
-------
selected_targets : ``torch.Tensor``
A tensor with shape [indices.size(), target.size(-1)] representing the embedded indices
extracted from the batch flattened target tensor.
"""
if flattened_indices is None:
# Shape: (batch_size * d_1 * ... * d_n)
flattened_indices = flatten_and_batch_shift_indices(indices, target.size(1))
# Shape: (batch_size * sequence_length, embedding_size)
flattened_target = target.view(-1, target.size(-1))
# Shape: (batch_size * d_1 * ... * d_n, embedding_size)
flattened_selected = flattened_target.index_select(0, flattened_indices)
selected_shape = list(indices.size()) + [target.size(-1)]
# Shape: (batch_size, d_1, ..., d_n, embedding_size)
selected_targets = flattened_selected.view(*selected_shape)
return selected_targets
|
[
"def",
"batched_index_select",
"(",
"target",
":",
"torch",
".",
"Tensor",
",",
"indices",
":",
"torch",
".",
"LongTensor",
",",
"flattened_indices",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"None",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"flattened_indices",
"is",
"None",
":",
"# Shape: (batch_size * d_1 * ... * d_n)",
"flattened_indices",
"=",
"flatten_and_batch_shift_indices",
"(",
"indices",
",",
"target",
".",
"size",
"(",
"1",
")",
")",
"# Shape: (batch_size * sequence_length, embedding_size)",
"flattened_target",
"=",
"target",
".",
"view",
"(",
"-",
"1",
",",
"target",
".",
"size",
"(",
"-",
"1",
")",
")",
"# Shape: (batch_size * d_1 * ... * d_n, embedding_size)",
"flattened_selected",
"=",
"flattened_target",
".",
"index_select",
"(",
"0",
",",
"flattened_indices",
")",
"selected_shape",
"=",
"list",
"(",
"indices",
".",
"size",
"(",
")",
")",
"+",
"[",
"target",
".",
"size",
"(",
"-",
"1",
")",
"]",
"# Shape: (batch_size, d_1, ..., d_n, embedding_size)",
"selected_targets",
"=",
"flattened_selected",
".",
"view",
"(",
"*",
"selected_shape",
")",
"return",
"selected_targets"
] |
The given ``indices`` of size ``(batch_size, d_1, ..., d_n)`` indexes into the sequence
dimension (dimension 2) of the target, which has size ``(batch_size, sequence_length,
embedding_size)``.
This function returns selected values in the target with respect to the provided indices, which
have size ``(batch_size, d_1, ..., d_n, embedding_size)``. This can use the optionally
precomputed :func:`~flattened_indices` with size ``(batch_size * d_1 * ... * d_n)`` if given.
An example use case of this function is looking up the start and end indices of spans in a
sequence tensor. This is used in the
:class:`~allennlp.models.coreference_resolution.CoreferenceResolver`. Model to select
contextual word representations corresponding to the start and end indices of mentions. The key
reason this can't be done with basic torch functions is that we want to be able to use look-up
tensors with an arbitrary number of dimensions (for example, in the coref model, we don't know
a-priori how many spans we are looking up).
Parameters
----------
target : ``torch.Tensor``, required.
A 3 dimensional tensor of shape (batch_size, sequence_length, embedding_size).
This is the tensor to be indexed.
indices : ``torch.LongTensor``
A tensor of shape (batch_size, ...), where each element is an index into the
``sequence_length`` dimension of the ``target`` tensor.
flattened_indices : Optional[torch.Tensor], optional (default = None)
An optional tensor representing the result of calling :func:~`flatten_and_batch_shift_indices`
on ``indices``. This is helpful in the case that the indices can be flattened once and
cached for many batch lookups.
Returns
-------
selected_targets : ``torch.Tensor``
A tensor with shape [indices.size(), target.size(-1)] representing the embedded indices
extracted from the batch flattened target tensor.
|
[
"The",
"given",
"indices",
"of",
"size",
"(",
"batch_size",
"d_1",
"...",
"d_n",
")",
"indexes",
"into",
"the",
"sequence",
"dimension",
"(",
"dimension",
"2",
")",
"of",
"the",
"target",
"which",
"has",
"size",
"(",
"batch_size",
"sequence_length",
"embedding_size",
")",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L998-L1049
|
train
|
Select values from target with respect to the given indices.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,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rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(0b110100) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11100 + 0o27) + chr(0b110001) + '\x33', 55262 - 55254), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\x35' + chr(2134 - 2082), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\065' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(1754 - 1703) + chr(0b100101 + 0o17) + chr(1620 - 1571), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100111 + 0o13) + chr(48) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b10110 + 0o131) + chr(2253 - 2202) + chr(54) + '\x30', 37601 - 37593), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b110101) + '\063', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(2040 - 1990) + '\x35' + chr(51), 8), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(53) + chr(0b110101), 28441 - 28433), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b1101111) + chr(0b110011) + chr(0b110001) + chr(0b11111 + 0o24), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11 + 0o56) + '\x32' + chr(2035 - 1982), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + '\063' + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10101 + 0o35) + chr(0b110111) + '\066', 47984 - 47976), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\x37' + '\x36', 8), ehT0Px3KOsy9('\x30' + chr(3570 - 3459) + chr(49) + chr(49) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1688 - 1577) + chr(0b1101 + 0o44) + chr(55) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\x6f' + chr(148 - 97) + chr(0b1000 + 0o56) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + '\x31', 34187 - 34179), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11010 + 0o27) + '\x34' + '\064', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1001010 + 0o45) + chr(0b1 + 0o62) + chr(0b11011 + 0o26) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\061' + chr(0b101111 + 0o2) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + '\066' + chr(2472 - 2417), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b101110 + 0o3) + chr(0b1111 + 0o50) + '\065', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10101 + 0o35) + chr(0b110101) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101101 + 0o2) + chr(501 - 450) + chr(51) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(1513 - 1462) + '\065' + chr(0b100100 + 0o16), 17684 - 17676), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(9313 - 9202) + '\x31' + chr(51) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + '\062' + '\067', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(0b110001) + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(184 - 133) + chr(1631 - 1577) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(111) + chr(0b101001 + 0o11) + chr(0b110110), 28024 - 28016), ehT0Px3KOsy9(chr(1322 - 1274) + chr(111) + chr(2196 - 2147) + '\x33' + chr(0b1001 + 0o51), 46364 - 46356), ehT0Px3KOsy9(chr(2135 - 2087) + chr(0b1010010 + 0o35) + chr(0b110010) + chr(0b101000 + 0o16) + chr(1752 - 1700), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1486 - 1435) + chr(0b1 + 0o64) + chr(0b100110 + 0o13), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(856 - 806) + '\x34', 0o10), ehT0Px3KOsy9(chr(1999 - 1951) + '\157' + '\062' + chr(48) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\157' + '\x33' + chr(503 - 449), 0b1000), ehT0Px3KOsy9(chr(1183 - 1135) + chr(111) + '\063' + chr(50) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1101 + 0o46), 22469 - 22461)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1100001 + 0o16) + '\x35' + chr(0b111 + 0o51), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e'), chr(100) + chr(101) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(6202 - 6085) + chr(116) + '\x66' + chr(800 - 755) + chr(0b110100 + 0o4)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def SUN31ILCo8Aw(GR1581dR5rDS, pIcoaXENl5Pw, cory6p7oHgmF=None) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf4\xae\xc2[\x8e\xf1'), '\144' + chr(101) + chr(0b1100011) + chr(111) + '\144' + chr(101))('\x75' + chr(116) + chr(0b1100110) + chr(0b1110 + 0o37) + chr(0b100110 + 0o22))):
if cory6p7oHgmF is None:
cory6p7oHgmF = JVV9rk8jelKh(pIcoaXENl5Pw, GR1581dR5rDS.NLcc3BCJnQka(ehT0Px3KOsy9(chr(48) + chr(0b1100100 + 0o13) + chr(49), 0b1000)))
jznbQteNJ9Oa = GR1581dR5rDS.view(-ehT0Px3KOsy9(chr(935 - 887) + '\157' + '\061', 8), GR1581dR5rDS.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001), 8)))
Sr0S9RyYpxcg = jznbQteNJ9Oa.index_select(ehT0Px3KOsy9(chr(0b110000) + chr(10475 - 10364) + '\060', ord("\x08")), cory6p7oHgmF)
d1Q5uvoSlvMF = YyaZ4tpXu4lf(pIcoaXENl5Pw.NLcc3BCJnQka()) + [GR1581dR5rDS.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(512 - 464) + chr(9541 - 9430) + chr(1882 - 1833), 8))]
ISFOeN3jBWwV = Sr0S9RyYpxcg.view(*d1Q5uvoSlvMF)
return ISFOeN3jBWwV
|
allenai/allennlp
|
allennlp/nn/util.py
|
flattened_index_select
|
def flattened_index_select(target: torch.Tensor,
indices: torch.LongTensor) -> torch.Tensor:
"""
The given ``indices`` of size ``(set_size, subset_size)`` specifies subsets of the ``target``
that each of the set_size rows should select. The `target` has size
``(batch_size, sequence_length, embedding_size)``, and the resulting selected tensor has size
``(batch_size, set_size, subset_size, embedding_size)``.
Parameters
----------
target : ``torch.Tensor``, required.
A Tensor of shape (batch_size, sequence_length, embedding_size).
indices : ``torch.LongTensor``, required.
A LongTensor of shape (set_size, subset_size). All indices must be < sequence_length
as this tensor is an index into the sequence_length dimension of the target.
Returns
-------
selected : ``torch.Tensor``, required.
A Tensor of shape (batch_size, set_size, subset_size, embedding_size).
"""
if indices.dim() != 2:
raise ConfigurationError("Indices passed to flattened_index_select had shape {} but "
"only 2 dimensional inputs are supported.".format(indices.size()))
# Shape: (batch_size, set_size * subset_size, embedding_size)
flattened_selected = target.index_select(1, indices.view(-1))
# Shape: (batch_size, set_size, subset_size, embedding_size)
selected = flattened_selected.view(target.size(0), indices.size(0), indices.size(1), -1)
return selected
|
python
|
def flattened_index_select(target: torch.Tensor,
indices: torch.LongTensor) -> torch.Tensor:
"""
The given ``indices`` of size ``(set_size, subset_size)`` specifies subsets of the ``target``
that each of the set_size rows should select. The `target` has size
``(batch_size, sequence_length, embedding_size)``, and the resulting selected tensor has size
``(batch_size, set_size, subset_size, embedding_size)``.
Parameters
----------
target : ``torch.Tensor``, required.
A Tensor of shape (batch_size, sequence_length, embedding_size).
indices : ``torch.LongTensor``, required.
A LongTensor of shape (set_size, subset_size). All indices must be < sequence_length
as this tensor is an index into the sequence_length dimension of the target.
Returns
-------
selected : ``torch.Tensor``, required.
A Tensor of shape (batch_size, set_size, subset_size, embedding_size).
"""
if indices.dim() != 2:
raise ConfigurationError("Indices passed to flattened_index_select had shape {} but "
"only 2 dimensional inputs are supported.".format(indices.size()))
# Shape: (batch_size, set_size * subset_size, embedding_size)
flattened_selected = target.index_select(1, indices.view(-1))
# Shape: (batch_size, set_size, subset_size, embedding_size)
selected = flattened_selected.view(target.size(0), indices.size(0), indices.size(1), -1)
return selected
|
[
"def",
"flattened_index_select",
"(",
"target",
":",
"torch",
".",
"Tensor",
",",
"indices",
":",
"torch",
".",
"LongTensor",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"indices",
".",
"dim",
"(",
")",
"!=",
"2",
":",
"raise",
"ConfigurationError",
"(",
"\"Indices passed to flattened_index_select had shape {} but \"",
"\"only 2 dimensional inputs are supported.\"",
".",
"format",
"(",
"indices",
".",
"size",
"(",
")",
")",
")",
"# Shape: (batch_size, set_size * subset_size, embedding_size)",
"flattened_selected",
"=",
"target",
".",
"index_select",
"(",
"1",
",",
"indices",
".",
"view",
"(",
"-",
"1",
")",
")",
"# Shape: (batch_size, set_size, subset_size, embedding_size)",
"selected",
"=",
"flattened_selected",
".",
"view",
"(",
"target",
".",
"size",
"(",
"0",
")",
",",
"indices",
".",
"size",
"(",
"0",
")",
",",
"indices",
".",
"size",
"(",
"1",
")",
",",
"-",
"1",
")",
"return",
"selected"
] |
The given ``indices`` of size ``(set_size, subset_size)`` specifies subsets of the ``target``
that each of the set_size rows should select. The `target` has size
``(batch_size, sequence_length, embedding_size)``, and the resulting selected tensor has size
``(batch_size, set_size, subset_size, embedding_size)``.
Parameters
----------
target : ``torch.Tensor``, required.
A Tensor of shape (batch_size, sequence_length, embedding_size).
indices : ``torch.LongTensor``, required.
A LongTensor of shape (set_size, subset_size). All indices must be < sequence_length
as this tensor is an index into the sequence_length dimension of the target.
Returns
-------
selected : ``torch.Tensor``, required.
A Tensor of shape (batch_size, set_size, subset_size, embedding_size).
|
[
"The",
"given",
"indices",
"of",
"size",
"(",
"set_size",
"subset_size",
")",
"specifies",
"subsets",
"of",
"the",
"target",
"that",
"each",
"of",
"the",
"set_size",
"rows",
"should",
"select",
".",
"The",
"target",
"has",
"size",
"(",
"batch_size",
"sequence_length",
"embedding_size",
")",
"and",
"the",
"resulting",
"selected",
"tensor",
"has",
"size",
"(",
"batch_size",
"set_size",
"subset_size",
"embedding_size",
")",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1052-L1081
|
train
|
Returns a flattened version of the index_select function.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxp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Ycwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b110110), 16371 - 16363), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(924 - 873) + chr(53), 1517 - 1509), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + '\064' + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110101) + chr(50), 33877 - 33869), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1110 + 0o141) + chr(730 - 679) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(126 - 76) + chr(0b1100 + 0o51) + '\x33', 0o10), ehT0Px3KOsy9(chr(1644 - 1596) + '\157' + chr(0b110011) + '\060', 17795 - 17787), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + chr(0b110 + 0o60) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + '\063' + '\x33' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110000 + 0o1) + chr(0b101101 + 0o3) + chr(0b101011 + 0o11), 31762 - 31754), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(53) + '\062', 8), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1101 + 0o46) + chr(0b110110) + chr(48), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(0b1111 + 0o41) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11001 + 0o31) + chr(55) + '\062', 0o10), ehT0Px3KOsy9(chr(788 - 740) + chr(0b1000100 + 0o53) + '\063' + chr(50) + '\x30', 17143 - 17135), ehT0Px3KOsy9(chr(1333 - 1285) + chr(111) + chr(0b110000 + 0o1) + chr(2078 - 2026) + chr(0b11 + 0o55), 0o10), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + '\x37' + chr(330 - 282), 0o10), ehT0Px3KOsy9(chr(1617 - 1569) + '\157' + chr(1193 - 1142) + chr(2170 - 2120), 292 - 284), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b11011 + 0o26) + chr(0b1010 + 0o53), 45967 - 45959), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + '\x32' + chr(52) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\157' + '\062' + chr(50) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(461 - 412) + chr(51), 0b1000), ehT0Px3KOsy9('\060' + chr(0b111111 + 0o60) + chr(49) + chr(51) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b100010 + 0o115) + chr(807 - 758) + '\064' + chr(488 - 435), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2211 - 2157) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b1000000 + 0o57) + chr(0b110011) + '\066', 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11110 + 0o23), 11456 - 11448), ehT0Px3KOsy9(chr(2292 - 2244) + chr(0b1101111) + '\063' + chr(0b110110) + chr(0b10001 + 0o43), 17923 - 17915), ehT0Px3KOsy9(chr(48) + chr(0b1 + 0o156) + '\x32' + chr(1398 - 1347) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(1408 - 1360) + chr(0b1101111) + '\061' + chr(0b110000 + 0o2) + chr(51), 29917 - 29909), ehT0Px3KOsy9(chr(48) + chr(6792 - 6681) + chr(51) + chr(53) + chr(0b1011 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + chr(0b100100 + 0o16) + chr(0b10110 + 0o41) + chr(1052 - 998), 57980 - 57972), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + '\061' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10000 + 0o43) + chr(396 - 346) + chr(1277 - 1229), 8), ehT0Px3KOsy9('\060' + chr(0b110011 + 0o74) + chr(0b110001) + chr(48) + chr(690 - 642), ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(11239 - 11128) + chr(0b100000 + 0o21) + '\x31' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b100 + 0o153) + '\x33' + '\063', 8), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + chr(0b101101 + 0o7), 52711 - 52703), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(0b110010) + chr(223 - 169), ord("\x08")), ehT0Px3KOsy9(chr(1312 - 1264) + '\157' + '\x32' + chr(49) + chr(0b110110), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(90 - 42) + chr(11308 - 11197) + chr(53) + chr(0b1101 + 0o43), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'0'), '\144' + chr(5844 - 5743) + chr(0b1100011) + chr(9402 - 9291) + '\144' + '\x65')(chr(0b1110101) + chr(116) + chr(0b1100110) + chr(0b101101) + chr(0b110111 + 0o1)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def NKFkuKTRMXQ7(GR1581dR5rDS, pIcoaXENl5Pw) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'J\xb8\x0bYt\xd9'), '\144' + chr(3577 - 3476) + '\143' + chr(139 - 28) + '\x64' + chr(107 - 6))(chr(0b1001101 + 0o50) + chr(650 - 534) + chr(8944 - 8842) + chr(1781 - 1736) + '\070')):
if xafqLlk3kkUe(pIcoaXENl5Pw, xafqLlk3kkUe(SXOLrMavuUCe(b'z\xb4\x08'), '\x64' + chr(101) + chr(8960 - 8861) + '\x6f' + '\x64' + '\145')(chr(117) + '\164' + '\x66' + '\055' + chr(664 - 608)))() != ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1238 - 1188), ord("\x08")):
raise h0iXqtiKVeKg(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'W\xb3\x01Cx\xcek\x91\xaa%Y\x83\xe0\xde\xf0\x14W:+\xce\xf3?/\x00[{e\xab\xf6=\x8e\xdb4\x8f3/wa\xf5\xfa>\xb5\x04N;\xd8p\xd0\xaa!\n\x8b\xf8\x9a\xb2\x15L:"\xcc\xfe2{W\x15zh\x99\xfa=\x99\xd7#\xbe!&;m\xf8\xfek\xa9\x16\nz\xd9}\x91\xa91Z\x80\xea\xc8\xa4\x05\\4'), chr(0b1100100) + chr(101) + chr(8161 - 8062) + '\157' + '\x64' + '\145')(chr(0b1110101) + chr(116) + '\x66' + '\x2d' + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'H\xe9\x17ES\xcaK\x82\x8a4O\x9a'), chr(0b1011001 + 0o13) + '\145' + '\143' + chr(111) + chr(100) + chr(0b1010001 + 0o24))(chr(0b101111 + 0o106) + chr(0b111110 + 0o66) + '\x66' + chr(45) + '\070'))(xafqLlk3kkUe(pIcoaXENl5Pw, xafqLlk3kkUe(SXOLrMavuUCe(b'P\x91\x06I(\xe9[\xfb\xb4\x15A\x91'), '\144' + chr(0b1100101) + chr(0b101101 + 0o66) + '\157' + chr(0b1101 + 0o127) + chr(0b110 + 0o137))(chr(0b1110101) + chr(116) + '\x66' + chr(1707 - 1662) + chr(0b111000)))()))
Sr0S9RyYpxcg = GR1581dR5rDS.index_select(ehT0Px3KOsy9(chr(1989 - 1941) + chr(0b1101111) + chr(0b11010 + 0o27), 8), pIcoaXENl5Pw.view(-ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061', 8)))
YaoWvQOCAANk = Sr0S9RyYpxcg.view(GR1581dR5rDS.NLcc3BCJnQka(ehT0Px3KOsy9('\x30' + chr(9167 - 9056) + chr(0b110000), 62827 - 62819)), pIcoaXENl5Pw.NLcc3BCJnQka(ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110000), 8)), pIcoaXENl5Pw.NLcc3BCJnQka(ehT0Px3KOsy9('\x30' + chr(111) + chr(49), 8)), -ehT0Px3KOsy9('\x30' + '\x6f' + chr(1476 - 1427), 8))
return YaoWvQOCAANk
|
allenai/allennlp
|
allennlp/nn/util.py
|
get_range_vector
|
def get_range_vector(size: int, device: int) -> torch.Tensor:
"""
Returns a range vector with the desired size, starting at 0. The CUDA implementation
is meant to avoid copy data from CPU to GPU.
"""
if device > -1:
return torch.cuda.LongTensor(size, device=device).fill_(1).cumsum(0) - 1
else:
return torch.arange(0, size, dtype=torch.long)
|
python
|
def get_range_vector(size: int, device: int) -> torch.Tensor:
"""
Returns a range vector with the desired size, starting at 0. The CUDA implementation
is meant to avoid copy data from CPU to GPU.
"""
if device > -1:
return torch.cuda.LongTensor(size, device=device).fill_(1).cumsum(0) - 1
else:
return torch.arange(0, size, dtype=torch.long)
|
[
"def",
"get_range_vector",
"(",
"size",
":",
"int",
",",
"device",
":",
"int",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"device",
">",
"-",
"1",
":",
"return",
"torch",
".",
"cuda",
".",
"LongTensor",
"(",
"size",
",",
"device",
"=",
"device",
")",
".",
"fill_",
"(",
"1",
")",
".",
"cumsum",
"(",
"0",
")",
"-",
"1",
"else",
":",
"return",
"torch",
".",
"arange",
"(",
"0",
",",
"size",
",",
"dtype",
"=",
"torch",
".",
"long",
")"
] |
Returns a range vector with the desired size, starting at 0. The CUDA implementation
is meant to avoid copy data from CPU to GPU.
|
[
"Returns",
"a",
"range",
"vector",
"with",
"the",
"desired",
"size",
"starting",
"at",
"0",
".",
"The",
"CUDA",
"implementation",
"is",
"meant",
"to",
"avoid",
"copy",
"data",
"from",
"CPU",
"to",
"GPU",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1084-L1092
|
train
|
Returns a range vector with the desired size starting at 0.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXv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G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + '\061' + '\x34' + chr(0b101101 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(335 - 286) + chr(49) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(1452 - 1341) + '\x33' + '\063' + chr(0b111 + 0o56), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(55) + chr(2531 - 2478), 0o10), ehT0Px3KOsy9('\x30' + chr(10192 - 10081) + chr(372 - 323) + chr(1256 - 1206) + '\060', 36507 - 36499), ehT0Px3KOsy9(chr(0b110000) + chr(0b100111 + 0o110) + '\x31' + '\x34' + '\067', 0o10), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b1100011 + 0o14) + chr(50) + chr(50) + chr(0b100000 + 0o24), 0b1000), ehT0Px3KOsy9('\060' + chr(2231 - 2120) + chr(0b110010) + '\062' + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1100 + 0o47) + chr(636 - 582) + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(2301 - 2252) + chr(0b110010) + chr(0b11110 + 0o23), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10295 - 10184) + '\061' + '\x34' + '\064', 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + chr(599 - 548) + chr(0b101011 + 0o6) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + '\x35' + '\063', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b1101111) + '\x33' + chr(0b101100 + 0o6) + chr(2343 - 2288), 13380 - 13372), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(0b10010 + 0o44), 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(0b101110 + 0o6) + '\066', 2747 - 2739), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(0b101110 + 0o101) + '\x32' + chr(0b1110 + 0o46) + chr(2130 - 2081), 37303 - 37295), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(1728 - 1617) + chr(0b10111 + 0o33) + chr(0b100011 + 0o23) + chr(2585 - 2533), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(1513 - 1464) + chr(0b110000 + 0o3) + chr(2170 - 2122), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x33' + chr(55) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + chr(0b101001 + 0o10), 0o10), ehT0Px3KOsy9('\060' + chr(1250 - 1139) + chr(1863 - 1814) + chr(0b100001 + 0o22) + chr(48), 8), ehT0Px3KOsy9(chr(432 - 384) + chr(0b110 + 0o151) + chr(49) + chr(0b110000) + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\x37' + chr(157 - 109), 0o10), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + chr(0b110011) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000 + 0o147) + '\061' + chr(1787 - 1735) + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + '\x36' + chr(49), 8), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1110 + 0o50) + chr(1507 - 1459), 0b1000), ehT0Px3KOsy9(chr(1175 - 1127) + chr(0b1101111) + chr(0b101101 + 0o7) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + '\x35' + '\x33', 8), ehT0Px3KOsy9(chr(1542 - 1494) + chr(10889 - 10778) + '\062' + chr(0b110101) + '\065', 16613 - 16605), ehT0Px3KOsy9('\060' + '\x6f' + chr(49) + chr(0b11101 + 0o24) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(533 - 422) + chr(0b11 + 0o56) + chr(1806 - 1753) + chr(2601 - 2547), 11019 - 11011), ehT0Px3KOsy9(chr(48) + chr(0b11111 + 0o120) + chr(0b1110 + 0o43) + chr(1072 - 1019) + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b111 + 0o55) + chr(0b110111), 17305 - 17297), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10001 + 0o40) + '\061' + chr(0b110101), 8), ehT0Px3KOsy9(chr(0b1101 + 0o43) + '\x6f' + chr(0b110010) + '\x34' + chr(0b1111 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(7072 - 6961) + '\062' + chr(50) + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + chr(678 - 625) + chr(122 - 73), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(7560 - 7449) + chr(2166 - 2117), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(1762 - 1709) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'L'), '\x64' + chr(0b11110 + 0o107) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(0b1000001 + 0o64) + chr(0b1110100) + chr(6617 - 6515) + chr(691 - 646) + chr(147 - 91)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def BNXuFoJp86Jx(NLcc3BCJnQka, v9dZPx26KxBP) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'6(\xb3N?\x15'), chr(100) + '\x65' + '\x63' + chr(0b1101111) + '\x64' + chr(0b10100 + 0o121))(chr(1216 - 1099) + chr(0b1110100) + chr(0b1100110) + '\055' + '\x38')):
if v9dZPx26KxBP > -ehT0Px3KOsy9('\060' + chr(111) + chr(2047 - 1998), 8):
return xafqLlk3kkUe(cEkFpYktkSeK.cuda.LongTensor(NLcc3BCJnQka, device=v9dZPx26KxBP).fill_(ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31', 8)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b}\xb1G\n0\xa7\xe3\xc1a\x11\xac'), chr(951 - 851) + '\x65' + '\143' + chr(0b101001 + 0o106) + chr(8660 - 8560) + chr(0b1100101))(chr(12317 - 12200) + chr(3597 - 3481) + '\146' + chr(946 - 901) + chr(56)))(ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x30', ord("\x08"))) - ehT0Px3KOsy9(chr(1005 - 957) + '\157' + '\061', 8)
else:
return xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03?\xbcS7\x02'), chr(3107 - 3007) + '\145' + '\143' + chr(4936 - 4825) + chr(4997 - 4897) + chr(6307 - 6206))('\165' + chr(116) + chr(0b1001101 + 0o31) + chr(45) + chr(0b101101 + 0o13)))(ehT0Px3KOsy9(chr(485 - 437) + chr(111) + '\060', 8), NLcc3BCJnQka, dtype=xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0e"\xb3Z'), chr(345 - 245) + chr(0b11001 + 0o114) + '\143' + '\157' + chr(0b1001100 + 0o30) + chr(0b110011 + 0o62))(chr(8746 - 8629) + chr(0b1110100) + chr(102) + '\055' + chr(56))))
|
allenai/allennlp
|
allennlp/nn/util.py
|
bucket_values
|
def bucket_values(distances: torch.Tensor,
num_identity_buckets: int = 4,
num_total_buckets: int = 10) -> torch.Tensor:
"""
Places the given values (designed for distances) into ``num_total_buckets``semi-logscale
buckets, with ``num_identity_buckets`` of these capturing single values.
The default settings will bucket values into the following buckets:
[0, 1, 2, 3, 4, 5-7, 8-15, 16-31, 32-63, 64+].
Parameters
----------
distances : ``torch.Tensor``, required.
A Tensor of any size, to be bucketed.
num_identity_buckets: int, optional (default = 4).
The number of identity buckets (those only holding a single value).
num_total_buckets : int, (default = 10)
The total number of buckets to bucket values into.
Returns
-------
A tensor of the same shape as the input, containing the indices of the buckets
the values were placed in.
"""
# Chunk the values into semi-logscale buckets using .floor().
# This is a semi-logscale bucketing because we divide by log(2) after taking the log.
# We do this to make the buckets more granular in the initial range, where we expect
# most values to fall. We then add (num_identity_buckets - 1) because we want these indices
# to start _after_ the fixed number of buckets which we specified would only hold single values.
logspace_index = (distances.float().log() / math.log(2)).floor().long() + (num_identity_buckets - 1)
# create a mask for values which will go into single number buckets (i.e not a range).
use_identity_mask = (distances <= num_identity_buckets).long()
use_buckets_mask = 1 + (-1 * use_identity_mask)
# Use the original values if they are less than num_identity_buckets, otherwise
# use the logspace indices.
combined_index = use_identity_mask * distances + use_buckets_mask * logspace_index
# Clamp to put anything > num_total_buckets into the final bucket.
return combined_index.clamp(0, num_total_buckets - 1)
|
python
|
def bucket_values(distances: torch.Tensor,
num_identity_buckets: int = 4,
num_total_buckets: int = 10) -> torch.Tensor:
"""
Places the given values (designed for distances) into ``num_total_buckets``semi-logscale
buckets, with ``num_identity_buckets`` of these capturing single values.
The default settings will bucket values into the following buckets:
[0, 1, 2, 3, 4, 5-7, 8-15, 16-31, 32-63, 64+].
Parameters
----------
distances : ``torch.Tensor``, required.
A Tensor of any size, to be bucketed.
num_identity_buckets: int, optional (default = 4).
The number of identity buckets (those only holding a single value).
num_total_buckets : int, (default = 10)
The total number of buckets to bucket values into.
Returns
-------
A tensor of the same shape as the input, containing the indices of the buckets
the values were placed in.
"""
# Chunk the values into semi-logscale buckets using .floor().
# This is a semi-logscale bucketing because we divide by log(2) after taking the log.
# We do this to make the buckets more granular in the initial range, where we expect
# most values to fall. We then add (num_identity_buckets - 1) because we want these indices
# to start _after_ the fixed number of buckets which we specified would only hold single values.
logspace_index = (distances.float().log() / math.log(2)).floor().long() + (num_identity_buckets - 1)
# create a mask for values which will go into single number buckets (i.e not a range).
use_identity_mask = (distances <= num_identity_buckets).long()
use_buckets_mask = 1 + (-1 * use_identity_mask)
# Use the original values if they are less than num_identity_buckets, otherwise
# use the logspace indices.
combined_index = use_identity_mask * distances + use_buckets_mask * logspace_index
# Clamp to put anything > num_total_buckets into the final bucket.
return combined_index.clamp(0, num_total_buckets - 1)
|
[
"def",
"bucket_values",
"(",
"distances",
":",
"torch",
".",
"Tensor",
",",
"num_identity_buckets",
":",
"int",
"=",
"4",
",",
"num_total_buckets",
":",
"int",
"=",
"10",
")",
"->",
"torch",
".",
"Tensor",
":",
"# Chunk the values into semi-logscale buckets using .floor().",
"# This is a semi-logscale bucketing because we divide by log(2) after taking the log.",
"# We do this to make the buckets more granular in the initial range, where we expect",
"# most values to fall. We then add (num_identity_buckets - 1) because we want these indices",
"# to start _after_ the fixed number of buckets which we specified would only hold single values.",
"logspace_index",
"=",
"(",
"distances",
".",
"float",
"(",
")",
".",
"log",
"(",
")",
"/",
"math",
".",
"log",
"(",
"2",
")",
")",
".",
"floor",
"(",
")",
".",
"long",
"(",
")",
"+",
"(",
"num_identity_buckets",
"-",
"1",
")",
"# create a mask for values which will go into single number buckets (i.e not a range).",
"use_identity_mask",
"=",
"(",
"distances",
"<=",
"num_identity_buckets",
")",
".",
"long",
"(",
")",
"use_buckets_mask",
"=",
"1",
"+",
"(",
"-",
"1",
"*",
"use_identity_mask",
")",
"# Use the original values if they are less than num_identity_buckets, otherwise",
"# use the logspace indices.",
"combined_index",
"=",
"use_identity_mask",
"*",
"distances",
"+",
"use_buckets_mask",
"*",
"logspace_index",
"# Clamp to put anything > num_total_buckets into the final bucket.",
"return",
"combined_index",
".",
"clamp",
"(",
"0",
",",
"num_total_buckets",
"-",
"1",
")"
] |
Places the given values (designed for distances) into ``num_total_buckets``semi-logscale
buckets, with ``num_identity_buckets`` of these capturing single values.
The default settings will bucket values into the following buckets:
[0, 1, 2, 3, 4, 5-7, 8-15, 16-31, 32-63, 64+].
Parameters
----------
distances : ``torch.Tensor``, required.
A Tensor of any size, to be bucketed.
num_identity_buckets: int, optional (default = 4).
The number of identity buckets (those only holding a single value).
num_total_buckets : int, (default = 10)
The total number of buckets to bucket values into.
Returns
-------
A tensor of the same shape as the input, containing the indices of the buckets
the values were placed in.
|
[
"Places",
"the",
"given",
"values",
"(",
"designed",
"for",
"distances",
")",
"into",
"num_total_buckets",
"semi",
"-",
"logscale",
"buckets",
"with",
"num_identity_buckets",
"of",
"these",
"capturing",
"single",
"values",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1095-L1132
|
train
|
Returns a tensor that contains the values for each bucket in the given distances.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmC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UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1010100 + 0o33) + chr(0b110010) + chr(119 - 65) + chr(0b100100 + 0o15), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(292 - 238) + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b1110 + 0o50) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\x6f' + chr(353 - 302) + '\065' + '\065', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + '\x30' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b11101 + 0o122) + chr(49) + '\x31' + chr(0b10100 + 0o37), 0o10), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(2700 - 2589) + '\x32' + chr(1920 - 1872) + chr(0b110000), 51045 - 51037), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(53) + chr(55), 0o10), ehT0Px3KOsy9(chr(115 - 67) + chr(111) + chr(51) + '\x35' + '\x31', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + '\064' + '\x35', 0o10), ehT0Px3KOsy9('\060' + chr(4713 - 4602) + chr(0b110011) + '\062' + chr(2700 - 2646), ord("\x08")), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + chr(0b110011) + chr(0b11110 + 0o31) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(573 - 525) + '\157' + chr(0b110010) + chr(50) + chr(2765 - 2710), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b101111 + 0o2), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001010 + 0o45) + chr(50) + '\x31' + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(55) + chr(0b101000 + 0o17), 33353 - 33345), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\063' + '\060', 0b1000), ehT0Px3KOsy9('\060' + chr(9936 - 9825) + chr(0b100001 + 0o21) + '\060' + chr(2248 - 2196), 34611 - 34603), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110010) + chr(48) + chr(0b110101 + 0o2), ord("\x08")), ehT0Px3KOsy9(chr(680 - 632) + '\157' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + '\x37' + chr(0b100011 + 0o22), 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1101111) + chr(0b10011 + 0o36) + '\x35' + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010001 + 0o36) + chr(185 - 134) + chr(55) + '\x30', 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\063' + chr(302 - 252), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\x31', 8), ehT0Px3KOsy9(chr(233 - 185) + '\x6f' + chr(51) + '\x34' + chr(0b110101), 8), ehT0Px3KOsy9('\060' + chr(0b1000111 + 0o50) + '\061' + chr(2015 - 1967) + chr(0b1111 + 0o42), 44504 - 44496), ehT0Px3KOsy9('\060' + '\x6f' + chr(298 - 245) + chr(1606 - 1551), 22706 - 22698), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + '\x37' + chr(1074 - 1021), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b10 + 0o155) + '\062' + '\061' + chr(0b10111 + 0o34), 0o10), ehT0Px3KOsy9(chr(733 - 685) + '\x6f' + chr(50) + chr(51) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b10111 + 0o130) + '\x31' + chr(0b10101 + 0o41) + '\063', 8), ehT0Px3KOsy9(chr(1949 - 1901) + '\x6f' + chr(0b100010 + 0o24) + chr(52), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\x34' + chr(82 - 32), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\062' + chr(0b110111), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + '\x32' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(1510 - 1462) + chr(0b1101111) + chr(50) + chr(54) + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100010 + 0o15) + '\065' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + '\061', 8), ehT0Px3KOsy9(chr(2017 - 1969) + chr(111) + chr(1655 - 1606) + chr(52) + chr(0b0 + 0o61), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + '\x35' + chr(0b10101 + 0o33), 35978 - 35970)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x9f'), chr(0b111 + 0o135) + '\145' + chr(0b1010110 + 0o15) + chr(193 - 82) + '\x64' + '\145')('\165' + '\x74' + chr(0b1010 + 0o134) + chr(0b101101) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def JhiqFUOnSZOr(_NvIcr6svyB8, qbbWRnODwjhK=ehT0Px3KOsy9(chr(48) + '\x6f' + chr(678 - 626), 8), EIkl1iaHz0PO=ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101 + 0o54) + chr(0b110010), ord("\x08"))) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5\x16\xdb\x9e\xed9'), chr(0b1100100) + chr(4891 - 4790) + chr(99) + '\x6f' + chr(0b1100100) + '\145')(chr(12636 - 12519) + '\x74' + '\146' + '\055' + chr(56))):
Bf0UhzjMb8BF = (_NvIcr6svyB8.float().log() / yhiZVkosCjBm.log(ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32', 0o10))).floor().long() + (qbbWRnODwjhK - ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + chr(0b110001), 8))
cRlINe31nqcH = (_NvIcr6svyB8 <= qbbWRnODwjhK).long()
yMwOw5j_21c5 = ehT0Px3KOsy9(chr(256 - 208) + chr(0b1101111) + chr(0b11 + 0o56), 8) + -ehT0Px3KOsy9(chr(1986 - 1938) + '\x6f' + '\061', 8) * cRlINe31nqcH
hcQHnV1ZbDvW = cRlINe31nqcH * _NvIcr6svyB8 + yMwOw5j_21c5 * Bf0UhzjMb8BF
return xafqLlk3kkUe(hcQHnV1ZbDvW, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\x1f\xd4\x80\xf2'), '\144' + chr(0b1100101) + chr(99) + chr(111) + chr(100) + '\145')('\165' + '\x74' + chr(0b111111 + 0o47) + chr(0b101101) + chr(56)))(ehT0Px3KOsy9(chr(2056 - 2008) + chr(11838 - 11727) + chr(1814 - 1766), 0b1000), EIkl1iaHz0PO - ehT0Px3KOsy9(chr(1754 - 1706) + chr(0b1101001 + 0o6) + chr(49), 8))
|
allenai/allennlp
|
allennlp/nn/util.py
|
add_sentence_boundary_token_ids
|
def add_sentence_boundary_token_ids(tensor: torch.Tensor,
mask: torch.Tensor,
sentence_begin_token: Any,
sentence_end_token: Any) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Add begin/end of sentence tokens to the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps)`` or
``(batch_size, timesteps, dim)`` this returns a tensor of shape
``(batch_size, timesteps + 2)`` or ``(batch_size, timesteps + 2, dim)`` respectively.
Returns both the new tensor and updated mask.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)`` or ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
sentence_begin_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the <S> id. For 3D input, a tensor with length dim.
sentence_end_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the </S> id. For 3D input, a tensor with length dim.
Returns
-------
tensor_with_boundary_tokens : ``torch.Tensor``
The tensor with the appended and prepended boundary tokens. If the input was 2D,
it has shape (batch_size, timesteps + 2) and if the input was 3D, it has shape
(batch_size, timesteps + 2, dim).
new_mask : ``torch.Tensor``
The new mask for the tensor, taking into account the appended tokens
marking the beginning and end of the sentence.
"""
# TODO: matthewp, profile this transfer
sequence_lengths = mask.sum(dim=1).detach().cpu().numpy()
tensor_shape = list(tensor.data.shape)
new_shape = list(tensor_shape)
new_shape[1] = tensor_shape[1] + 2
tensor_with_boundary_tokens = tensor.new_zeros(*new_shape)
if len(tensor_shape) == 2:
tensor_with_boundary_tokens[:, 1:-1] = tensor
tensor_with_boundary_tokens[:, 0] = sentence_begin_token
for i, j in enumerate(sequence_lengths):
tensor_with_boundary_tokens[i, j + 1] = sentence_end_token
new_mask = (tensor_with_boundary_tokens != 0).long()
elif len(tensor_shape) == 3:
tensor_with_boundary_tokens[:, 1:-1, :] = tensor
for i, j in enumerate(sequence_lengths):
tensor_with_boundary_tokens[i, 0, :] = sentence_begin_token
tensor_with_boundary_tokens[i, j + 1, :] = sentence_end_token
new_mask = ((tensor_with_boundary_tokens > 0).long().sum(dim=-1) > 0).long()
else:
raise ValueError("add_sentence_boundary_token_ids only accepts 2D and 3D input")
return tensor_with_boundary_tokens, new_mask
|
python
|
def add_sentence_boundary_token_ids(tensor: torch.Tensor,
mask: torch.Tensor,
sentence_begin_token: Any,
sentence_end_token: Any) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Add begin/end of sentence tokens to the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps)`` or
``(batch_size, timesteps, dim)`` this returns a tensor of shape
``(batch_size, timesteps + 2)`` or ``(batch_size, timesteps + 2, dim)`` respectively.
Returns both the new tensor and updated mask.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)`` or ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
sentence_begin_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the <S> id. For 3D input, a tensor with length dim.
sentence_end_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the </S> id. For 3D input, a tensor with length dim.
Returns
-------
tensor_with_boundary_tokens : ``torch.Tensor``
The tensor with the appended and prepended boundary tokens. If the input was 2D,
it has shape (batch_size, timesteps + 2) and if the input was 3D, it has shape
(batch_size, timesteps + 2, dim).
new_mask : ``torch.Tensor``
The new mask for the tensor, taking into account the appended tokens
marking the beginning and end of the sentence.
"""
# TODO: matthewp, profile this transfer
sequence_lengths = mask.sum(dim=1).detach().cpu().numpy()
tensor_shape = list(tensor.data.shape)
new_shape = list(tensor_shape)
new_shape[1] = tensor_shape[1] + 2
tensor_with_boundary_tokens = tensor.new_zeros(*new_shape)
if len(tensor_shape) == 2:
tensor_with_boundary_tokens[:, 1:-1] = tensor
tensor_with_boundary_tokens[:, 0] = sentence_begin_token
for i, j in enumerate(sequence_lengths):
tensor_with_boundary_tokens[i, j + 1] = sentence_end_token
new_mask = (tensor_with_boundary_tokens != 0).long()
elif len(tensor_shape) == 3:
tensor_with_boundary_tokens[:, 1:-1, :] = tensor
for i, j in enumerate(sequence_lengths):
tensor_with_boundary_tokens[i, 0, :] = sentence_begin_token
tensor_with_boundary_tokens[i, j + 1, :] = sentence_end_token
new_mask = ((tensor_with_boundary_tokens > 0).long().sum(dim=-1) > 0).long()
else:
raise ValueError("add_sentence_boundary_token_ids only accepts 2D and 3D input")
return tensor_with_boundary_tokens, new_mask
|
[
"def",
"add_sentence_boundary_token_ids",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
",",
"sentence_begin_token",
":",
"Any",
",",
"sentence_end_token",
":",
"Any",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"# TODO: matthewp, profile this transfer",
"sequence_lengths",
"=",
"mask",
".",
"sum",
"(",
"dim",
"=",
"1",
")",
".",
"detach",
"(",
")",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
"tensor_shape",
"=",
"list",
"(",
"tensor",
".",
"data",
".",
"shape",
")",
"new_shape",
"=",
"list",
"(",
"tensor_shape",
")",
"new_shape",
"[",
"1",
"]",
"=",
"tensor_shape",
"[",
"1",
"]",
"+",
"2",
"tensor_with_boundary_tokens",
"=",
"tensor",
".",
"new_zeros",
"(",
"*",
"new_shape",
")",
"if",
"len",
"(",
"tensor_shape",
")",
"==",
"2",
":",
"tensor_with_boundary_tokens",
"[",
":",
",",
"1",
":",
"-",
"1",
"]",
"=",
"tensor",
"tensor_with_boundary_tokens",
"[",
":",
",",
"0",
"]",
"=",
"sentence_begin_token",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"sequence_lengths",
")",
":",
"tensor_with_boundary_tokens",
"[",
"i",
",",
"j",
"+",
"1",
"]",
"=",
"sentence_end_token",
"new_mask",
"=",
"(",
"tensor_with_boundary_tokens",
"!=",
"0",
")",
".",
"long",
"(",
")",
"elif",
"len",
"(",
"tensor_shape",
")",
"==",
"3",
":",
"tensor_with_boundary_tokens",
"[",
":",
",",
"1",
":",
"-",
"1",
",",
":",
"]",
"=",
"tensor",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"sequence_lengths",
")",
":",
"tensor_with_boundary_tokens",
"[",
"i",
",",
"0",
",",
":",
"]",
"=",
"sentence_begin_token",
"tensor_with_boundary_tokens",
"[",
"i",
",",
"j",
"+",
"1",
",",
":",
"]",
"=",
"sentence_end_token",
"new_mask",
"=",
"(",
"(",
"tensor_with_boundary_tokens",
">",
"0",
")",
".",
"long",
"(",
")",
".",
"sum",
"(",
"dim",
"=",
"-",
"1",
")",
">",
"0",
")",
".",
"long",
"(",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"add_sentence_boundary_token_ids only accepts 2D and 3D input\"",
")",
"return",
"tensor_with_boundary_tokens",
",",
"new_mask"
] |
Add begin/end of sentence tokens to the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps)`` or
``(batch_size, timesteps, dim)`` this returns a tensor of shape
``(batch_size, timesteps + 2)`` or ``(batch_size, timesteps + 2, dim)`` respectively.
Returns both the new tensor and updated mask.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)`` or ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
sentence_begin_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the <S> id. For 3D input, a tensor with length dim.
sentence_end_token: Any (anything that can be broadcast in torch for assignment)
For 2D input, a scalar with the </S> id. For 3D input, a tensor with length dim.
Returns
-------
tensor_with_boundary_tokens : ``torch.Tensor``
The tensor with the appended and prepended boundary tokens. If the input was 2D,
it has shape (batch_size, timesteps + 2) and if the input was 3D, it has shape
(batch_size, timesteps + 2, dim).
new_mask : ``torch.Tensor``
The new mask for the tensor, taking into account the appended tokens
marking the beginning and end of the sentence.
|
[
"Add",
"begin",
"/",
"end",
"of",
"sentence",
"tokens",
"to",
"the",
"batch",
"of",
"sentences",
".",
"Given",
"a",
"batch",
"of",
"sentences",
"with",
"size",
"(",
"batch_size",
"timesteps",
")",
"or",
"(",
"batch_size",
"timesteps",
"dim",
")",
"this",
"returns",
"a",
"tensor",
"of",
"shape",
"(",
"batch_size",
"timesteps",
"+",
"2",
")",
"or",
"(",
"batch_size",
"timesteps",
"+",
"2",
"dim",
")",
"respectively",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1135-L1189
|
train
|
Add begin and end of sentence tokens to the batch of sentences.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,Kk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dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(50) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(230 - 182) + chr(0b11001 + 0o126) + '\061' + '\063', 0o10), ehT0Px3KOsy9(chr(1941 - 1893) + chr(111) + '\063' + chr(848 - 796) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b101010 + 0o105) + chr(0b110100 + 0o1), ord("\x08")), ehT0Px3KOsy9(chr(1384 - 1336) + chr(0b1010100 + 0o33) + chr(0b11011 + 0o26) + chr(0b100110 + 0o13), 42495 - 42487), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b1 + 0o65) + chr(53), 19385 - 19377), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b111101 + 0o62) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(6256 - 6145) + chr(0b10100 + 0o37) + chr(50), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110111) + '\060', 26288 - 26280), ehT0Px3KOsy9('\060' + chr(0b110001 + 0o76) + chr(0b1110 + 0o45) + '\x36' + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(0b101011 + 0o6) + chr(52) + chr(597 - 543), 45698 - 45690), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(51) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(1055 - 1003) + '\x30', 51517 - 51509), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110110) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b101111 + 0o100) + '\x32' + chr(1750 - 1697), 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b100011 + 0o114) + chr(268 - 214) + chr(0b101100 + 0o13), 19671 - 19663), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(0b110111) + '\x36', 60042 - 60034), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001) + chr(0b110101) + '\063', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101011 + 0o104) + '\061' + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(834 - 786) + chr(2174 - 2063) + '\x33' + chr(0b1011 + 0o50) + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(55) + '\x37', 63136 - 63128), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b111010 + 0o65) + chr(0b100010 + 0o17) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\x6f' + '\x32' + chr(0b110111) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + '\x36' + chr(0b11011 + 0o26), 31430 - 31422), ehT0Px3KOsy9('\060' + '\157' + chr(0b110111) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1180 - 1132) + chr(1236 - 1125) + chr(0b101110 + 0o4) + chr(0b110000) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1928 - 1880) + chr(0b1101111) + chr(1742 - 1692) + '\x31' + chr(0b100100 + 0o16), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1677 - 1625) + chr(1783 - 1732), 5587 - 5579), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(4906 - 4795) + '\x33' + '\x32' + '\x33', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b100101 + 0o112) + '\063' + chr(0b110100 + 0o1) + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + chr(994 - 883) + '\062' + chr(0b101 + 0o55) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100111 + 0o16) + chr(1666 - 1611), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1831 - 1720) + chr(49) + chr(53) + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + '\x35' + '\065', 52793 - 52785), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31' + chr(51) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b1010010 + 0o35) + chr(1117 - 1068) + chr(51) + '\062', 64874 - 64866), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + chr(52) + '\064', 0b1000), ehT0Px3KOsy9(chr(1293 - 1245) + chr(0b101100 + 0o103) + '\064' + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(0b1101 + 0o45) + chr(50), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + chr(81 - 28) + chr(0b110000), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfd'), '\x64' + chr(0b11110 + 0o107) + '\143' + chr(111) + chr(3797 - 3697) + '\145')(chr(13221 - 13104) + '\164' + chr(0b1010111 + 0o17) + '\x2d' + chr(0b111000 + 0o0)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def lgDVfzWIwOn1(LK3cpXJU3UM0, Iz1jSgUKZDvt, KK68bGYdtz3_, g1cUUibxUYFO) -> MRK8Uzg2En3D[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x87n\x8avf\x07'), '\144' + chr(0b1010001 + 0o24) + '\x63' + chr(111) + '\144' + chr(101))('\x75' + '\164' + chr(0b111110 + 0o50) + '\055' + chr(56))), xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x87n\x8avf\x07'), chr(0b1001000 + 0o34) + chr(0b1010001 + 0o24) + chr(99) + chr(0b110010 + 0o75) + chr(0b1100100) + '\x65')('\x75' + chr(7437 - 7321) + '\x66' + chr(1103 - 1058) + chr(0b11 + 0o65)))]:
JqDKXxFsMQp2 = Iz1jSgUKZDvt.sum(dim=ehT0Px3KOsy9('\060' + '\157' + '\061', 50790 - 50782)).detach().cpu().numpy()
bZy43dSfWwvu = YyaZ4tpXu4lf(LK3cpXJU3UM0.data.nauYfLglTpcb)
P7dVzv6_yXeE = YyaZ4tpXu4lf(bZy43dSfWwvu)
P7dVzv6_yXeE[ehT0Px3KOsy9('\x30' + chr(7781 - 7670) + '\x31', 8)] = bZy43dSfWwvu[ehT0Px3KOsy9('\x30' + chr(111) + chr(49), 8)] + ehT0Px3KOsy9(chr(2192 - 2144) + chr(111) + '\x32', 155 - 147)
FBJaMMTunfY8 = LK3cpXJU3UM0.new_zeros(*P7dVzv6_yXeE)
if c2A0yzQpDQB3(bZy43dSfWwvu) == ehT0Px3KOsy9('\x30' + '\x6f' + chr(50), 8):
FBJaMMTunfY8[:, ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(0b1101111) + chr(0b110001), 8):-ehT0Px3KOsy9(chr(48) + chr(0b1100001 + 0o16) + '\061', 8)] = LK3cpXJU3UM0
FBJaMMTunfY8[:, ehT0Px3KOsy9(chr(566 - 518) + '\157' + chr(0b10111 + 0o31), ord("\x08"))] = KK68bGYdtz3_
for (WVxHKyX45z_L, tlORBuYsiw3X) in YlkZvXL8qwsX(JqDKXxFsMQp2):
FBJaMMTunfY8[WVxHKyX45z_L, tlORBuYsiw3X + ehT0Px3KOsy9('\x30' + '\x6f' + chr(1756 - 1707), 8)] = g1cUUibxUYFO
rmZdi06ze3ez = (FBJaMMTunfY8 != ehT0Px3KOsy9('\x30' + '\157' + '\060', 8)).long()
elif c2A0yzQpDQB3(bZy43dSfWwvu) == ehT0Px3KOsy9(chr(0b11011 + 0o25) + '\x6f' + chr(0b110010 + 0o1), 0b1000):
FBJaMMTunfY8[:, ehT0Px3KOsy9(chr(1870 - 1822) + '\157' + '\061', 8):-ehT0Px3KOsy9(chr(807 - 759) + '\x6f' + chr(0b110001), 8), :] = LK3cpXJU3UM0
for (WVxHKyX45z_L, tlORBuYsiw3X) in YlkZvXL8qwsX(JqDKXxFsMQp2):
FBJaMMTunfY8[WVxHKyX45z_L, ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\060', 8), :] = KK68bGYdtz3_
FBJaMMTunfY8[WVxHKyX45z_L, tlORBuYsiw3X + ehT0Px3KOsy9(chr(48) + chr(8500 - 8389) + chr(635 - 586), 8), :] = g1cUUibxUYFO
rmZdi06ze3ez = ((FBJaMMTunfY8 > ehT0Px3KOsy9(chr(0b110000) + chr(0b101110 + 0o101) + chr(0b10110 + 0o32), 8)).long().sum(dim=-ehT0Px3KOsy9('\x30' + chr(9851 - 9740) + '\061', 8)) > ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11111 + 0o21), 8)).long()
else:
raise q1QCh3W88sgk(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2o\x80Zz\x10jn]\x99e\x03A\x02Z`Y\x1a\n\x7f\xa1 |\xd1\x9a\\\xef\xd5J\xb7\x9a\xb2@\x04\x01$z\xc5E1\xb6{\x90v)G@:Y\x99bF-$\x15|Y\x0e\x1ey'), chr(0b1100100) + '\x65' + chr(3626 - 3527) + chr(0b1101111) + chr(5660 - 5560) + chr(0b110111 + 0o56))('\x75' + chr(0b11 + 0o161) + chr(102) + '\x2d' + chr(780 - 724)))
return (FBJaMMTunfY8, rmZdi06ze3ez)
|
allenai/allennlp
|
allennlp/nn/util.py
|
remove_sentence_boundaries
|
def remove_sentence_boundaries(tensor: torch.Tensor,
mask: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Remove begin/end of sentence embeddings from the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps, dim)``
this returns a tensor of shape ``(batch_size, timesteps - 2, dim)`` after removing
the beginning and end sentence markers. The sentences are assumed to be padded on the right,
with the beginning of each sentence assumed to occur at index 0 (i.e., ``mask[:, 0]`` is assumed
to be 1).
Returns both the new tensor and updated mask.
This function is the inverse of ``add_sentence_boundary_token_ids``.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
Returns
-------
tensor_without_boundary_tokens : ``torch.Tensor``
The tensor after removing the boundary tokens of shape ``(batch_size, timesteps - 2, dim)``
new_mask : ``torch.Tensor``
The new mask for the tensor of shape ``(batch_size, timesteps - 2)``.
"""
# TODO: matthewp, profile this transfer
sequence_lengths = mask.sum(dim=1).detach().cpu().numpy()
tensor_shape = list(tensor.data.shape)
new_shape = list(tensor_shape)
new_shape[1] = tensor_shape[1] - 2
tensor_without_boundary_tokens = tensor.new_zeros(*new_shape)
new_mask = tensor.new_zeros((new_shape[0], new_shape[1]), dtype=torch.long)
for i, j in enumerate(sequence_lengths):
if j > 2:
tensor_without_boundary_tokens[i, :(j - 2), :] = tensor[i, 1:(j - 1), :]
new_mask[i, :(j - 2)] = 1
return tensor_without_boundary_tokens, new_mask
|
python
|
def remove_sentence_boundaries(tensor: torch.Tensor,
mask: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Remove begin/end of sentence embeddings from the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps, dim)``
this returns a tensor of shape ``(batch_size, timesteps - 2, dim)`` after removing
the beginning and end sentence markers. The sentences are assumed to be padded on the right,
with the beginning of each sentence assumed to occur at index 0 (i.e., ``mask[:, 0]`` is assumed
to be 1).
Returns both the new tensor and updated mask.
This function is the inverse of ``add_sentence_boundary_token_ids``.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
Returns
-------
tensor_without_boundary_tokens : ``torch.Tensor``
The tensor after removing the boundary tokens of shape ``(batch_size, timesteps - 2, dim)``
new_mask : ``torch.Tensor``
The new mask for the tensor of shape ``(batch_size, timesteps - 2)``.
"""
# TODO: matthewp, profile this transfer
sequence_lengths = mask.sum(dim=1).detach().cpu().numpy()
tensor_shape = list(tensor.data.shape)
new_shape = list(tensor_shape)
new_shape[1] = tensor_shape[1] - 2
tensor_without_boundary_tokens = tensor.new_zeros(*new_shape)
new_mask = tensor.new_zeros((new_shape[0], new_shape[1]), dtype=torch.long)
for i, j in enumerate(sequence_lengths):
if j > 2:
tensor_without_boundary_tokens[i, :(j - 2), :] = tensor[i, 1:(j - 1), :]
new_mask[i, :(j - 2)] = 1
return tensor_without_boundary_tokens, new_mask
|
[
"def",
"remove_sentence_boundaries",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"Tensor",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"# TODO: matthewp, profile this transfer",
"sequence_lengths",
"=",
"mask",
".",
"sum",
"(",
"dim",
"=",
"1",
")",
".",
"detach",
"(",
")",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
"tensor_shape",
"=",
"list",
"(",
"tensor",
".",
"data",
".",
"shape",
")",
"new_shape",
"=",
"list",
"(",
"tensor_shape",
")",
"new_shape",
"[",
"1",
"]",
"=",
"tensor_shape",
"[",
"1",
"]",
"-",
"2",
"tensor_without_boundary_tokens",
"=",
"tensor",
".",
"new_zeros",
"(",
"*",
"new_shape",
")",
"new_mask",
"=",
"tensor",
".",
"new_zeros",
"(",
"(",
"new_shape",
"[",
"0",
"]",
",",
"new_shape",
"[",
"1",
"]",
")",
",",
"dtype",
"=",
"torch",
".",
"long",
")",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"sequence_lengths",
")",
":",
"if",
"j",
">",
"2",
":",
"tensor_without_boundary_tokens",
"[",
"i",
",",
":",
"(",
"j",
"-",
"2",
")",
",",
":",
"]",
"=",
"tensor",
"[",
"i",
",",
"1",
":",
"(",
"j",
"-",
"1",
")",
",",
":",
"]",
"new_mask",
"[",
"i",
",",
":",
"(",
"j",
"-",
"2",
")",
"]",
"=",
"1",
"return",
"tensor_without_boundary_tokens",
",",
"new_mask"
] |
Remove begin/end of sentence embeddings from the batch of sentences.
Given a batch of sentences with size ``(batch_size, timesteps, dim)``
this returns a tensor of shape ``(batch_size, timesteps - 2, dim)`` after removing
the beginning and end sentence markers. The sentences are assumed to be padded on the right,
with the beginning of each sentence assumed to occur at index 0 (i.e., ``mask[:, 0]`` is assumed
to be 1).
Returns both the new tensor and updated mask.
This function is the inverse of ``add_sentence_boundary_token_ids``.
Parameters
----------
tensor : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps, dim)``
mask : ``torch.Tensor``
A tensor of shape ``(batch_size, timesteps)``
Returns
-------
tensor_without_boundary_tokens : ``torch.Tensor``
The tensor after removing the boundary tokens of shape ``(batch_size, timesteps - 2, dim)``
new_mask : ``torch.Tensor``
The new mask for the tensor of shape ``(batch_size, timesteps - 2)``.
|
[
"Remove",
"begin",
"/",
"end",
"of",
"sentence",
"embeddings",
"from",
"the",
"batch",
"of",
"sentences",
".",
"Given",
"a",
"batch",
"of",
"sentences",
"with",
"size",
"(",
"batch_size",
"timesteps",
"dim",
")",
"this",
"returns",
"a",
"tensor",
"of",
"shape",
"(",
"batch_size",
"timesteps",
"-",
"2",
"dim",
")",
"after",
"removing",
"the",
"beginning",
"and",
"end",
"sentence",
"markers",
".",
"The",
"sentences",
"are",
"assumed",
"to",
"be",
"padded",
"on",
"the",
"right",
"with",
"the",
"beginning",
"of",
"each",
"sentence",
"assumed",
"to",
"occur",
"at",
"index",
"0",
"(",
"i",
".",
"e",
".",
"mask",
"[",
":",
"0",
"]",
"is",
"assumed",
"to",
"be",
"1",
")",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1192-L1232
|
train
|
Removes the sentence boundaries from the batch of sentences.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3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,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + '\x37' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6895 - 6784) + chr(51) + '\066' + '\065', 38769 - 38761), ehT0Px3KOsy9(chr(48) + '\x6f' + '\064' + chr(1755 - 1707), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + '\063' + chr(1575 - 1526), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10111 + 0o34) + chr(0b110011) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(642 - 589) + chr(2166 - 2117), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + chr(0b11010 + 0o32) + '\x36', 0b1000), ehT0Px3KOsy9(chr(252 - 204) + chr(0b1101111) + chr(2064 - 2015) + chr(0b111 + 0o57) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(4262 - 4151) + chr(0b110001 + 0o0) + chr(0b110001) + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(4596 - 4485) + chr(0b110001) + chr(52) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(6621 - 6510) + chr(0b0 + 0o62) + chr(0b11 + 0o55) + chr(1255 - 1206), 36737 - 36729), ehT0Px3KOsy9('\060' + chr(111) + chr(170 - 120) + '\065' + '\x30', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\061' + chr(0b100000 + 0o26) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(1545 - 1497) + chr(10563 - 10452) + '\061' + chr(52) + '\x34', 61615 - 61607), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b110001) + chr(3012 - 2957) + chr(0b11100 + 0o32), 39189 - 39181), ehT0Px3KOsy9(chr(2037 - 1989) + chr(8905 - 8794) + chr(0b100001 + 0o24) + '\064', 39350 - 39342), ehT0Px3KOsy9('\x30' + '\157' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101101 + 0o5) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b111111 + 0o60) + chr(51) + chr(52) + chr(3024 - 2969), 0o10), ehT0Px3KOsy9(chr(1717 - 1669) + chr(111) + '\x32' + '\064' + chr(0b1010 + 0o51), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b110000 + 0o77) + chr(0b110011) + chr(1612 - 1560), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010000 + 0o37) + chr(1270 - 1220) + chr(54) + '\066', 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + '\x33' + chr(0b110000) + chr(1996 - 1945), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + chr(0b1011 + 0o50) + chr(1095 - 1041) + chr(0b10110 + 0o32), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b1111 + 0o45) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11110 + 0o24) + '\x30' + chr(0b1100 + 0o52), 0b1000), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + '\062' + '\x31' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(1415 - 1366) + chr(0b110000 + 0o6), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10010 + 0o40) + chr(0b100111 + 0o11) + chr(0b100010 + 0o20), 7823 - 7815), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\x6f' + '\x33' + chr(0b110011) + '\x34', 8), ehT0Px3KOsy9(chr(973 - 925) + '\x6f' + chr(2393 - 2343) + chr(0b10001 + 0o44) + chr(55), ord("\x08")), ehT0Px3KOsy9('\060' + chr(1678 - 1567) + '\063' + chr(53) + chr(0b1011 + 0o51), 51902 - 51894), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + chr(0b110011) + '\063' + chr(0b1100 + 0o44), ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + '\157' + chr(0b10000 + 0o41) + chr(2853 - 2799) + chr(51), 50191 - 50183), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\066' + chr(0b11011 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\x31' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(3414 - 3303) + chr(50) + '\x33' + chr(0b101010 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1101111) + chr(602 - 551) + chr(0b110011), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b1110 + 0o44) + chr(55), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(111) + chr(53) + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3'), '\x64' + chr(101) + chr(99) + chr(111) + chr(0b1100100) + chr(101))('\x75' + chr(0b1110100) + '\x66' + '\055' + chr(0b110111 + 0o1)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def ooqEa__WcZPK(LK3cpXJU3UM0, Iz1jSgUKZDvt) -> MRK8Uzg2En3D[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa9\x90N\xaa\xb3\x9b'), chr(0b1100100) + chr(0b1000111 + 0o36) + chr(99) + chr(0b11001 + 0o126) + chr(0b10001 + 0o123) + chr(0b1100101))(chr(1903 - 1786) + chr(116) + chr(102) + '\x2d' + '\070')), xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa9\x90N\xaa\xb3\x9b'), '\x64' + '\x65' + chr(0b1100011) + chr(111) + chr(0b1100100) + chr(101))(chr(117) + '\164' + '\x66' + chr(0b101101) + chr(0b1101 + 0o53)))]:
JqDKXxFsMQp2 = Iz1jSgUKZDvt.sum(dim=ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11111 + 0o22), 0b1000)).detach().cpu().numpy()
bZy43dSfWwvu = YyaZ4tpXu4lf(LK3cpXJU3UM0.data.nauYfLglTpcb)
P7dVzv6_yXeE = YyaZ4tpXu4lf(bZy43dSfWwvu)
P7dVzv6_yXeE[ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + '\061', 8)] = bZy43dSfWwvu[ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + '\x31', 8)] - ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b100101 + 0o112) + chr(0b1001 + 0o51), 8)
m_yMTxjY2QAh = LK3cpXJU3UM0.new_zeros(*P7dVzv6_yXeE)
rmZdi06ze3ez = LK3cpXJU3UM0.new_zeros((P7dVzv6_yXeE[ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110000), ord("\x08"))], P7dVzv6_yXeE[ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(6507 - 6396) + chr(0b110001), 8)]), dtype=cEkFpYktkSeK.long)
for (WVxHKyX45z_L, tlORBuYsiw3X) in YlkZvXL8qwsX(JqDKXxFsMQp2):
if tlORBuYsiw3X > ehT0Px3KOsy9('\x30' + chr(10963 - 10852) + chr(0b110010), 8):
m_yMTxjY2QAh[WVxHKyX45z_L, :tlORBuYsiw3X - ehT0Px3KOsy9(chr(2196 - 2148) + '\157' + chr(0b110010), 8), :] = LK3cpXJU3UM0[WVxHKyX45z_L, ehT0Px3KOsy9(chr(1215 - 1167) + chr(111) + chr(0b100100 + 0o15), 8):tlORBuYsiw3X - ehT0Px3KOsy9('\x30' + chr(111) + chr(652 - 603), 8), :]
rmZdi06ze3ez[WVxHKyX45z_L, :tlORBuYsiw3X - ehT0Px3KOsy9(chr(680 - 632) + chr(0b1101111) + chr(0b11101 + 0o25), 8)] = ehT0Px3KOsy9(chr(48) + '\157' + chr(49), 8)
return (m_yMTxjY2QAh, rmZdi06ze3ez)
|
allenai/allennlp
|
allennlp/nn/util.py
|
add_positional_features
|
def add_positional_features(tensor: torch.Tensor,
min_timescale: float = 1.0,
max_timescale: float = 1.0e4):
# pylint: disable=line-too-long
"""
Implements the frequency-based positional encoding described
in `Attention is all you Need
<https://www.semanticscholar.org/paper/Attention-Is-All-You-Need-Vaswani-Shazeer/0737da0767d77606169cbf4187b83e1ab62f6077>`_ .
Adds sinusoids of different frequencies to a ``Tensor``. A sinusoid of a
different frequency and phase is added to each dimension of the input ``Tensor``.
This allows the attention heads to use absolute and relative positions.
The number of timescales is equal to hidden_dim / 2 within the range
(min_timescale, max_timescale). For each timescale, the two sinusoidal
signals sin(timestep / timescale) and cos(timestep / timescale) are
generated and concatenated along the hidden_dim dimension.
Parameters
----------
tensor : ``torch.Tensor``
a Tensor with shape (batch_size, timesteps, hidden_dim).
min_timescale : ``float``, optional (default = 1.0)
The smallest timescale to use.
max_timescale : ``float``, optional (default = 1.0e4)
The largest timescale to use.
Returns
-------
The input tensor augmented with the sinusoidal frequencies.
"""
_, timesteps, hidden_dim = tensor.size()
timestep_range = get_range_vector(timesteps, get_device_of(tensor)).data.float()
# We're generating both cos and sin frequencies,
# so half for each.
num_timescales = hidden_dim // 2
timescale_range = get_range_vector(num_timescales, get_device_of(tensor)).data.float()
log_timescale_increments = math.log(float(max_timescale) / float(min_timescale)) / float(num_timescales - 1)
inverse_timescales = min_timescale * torch.exp(timescale_range * -log_timescale_increments)
# Broadcasted multiplication - shape (timesteps, num_timescales)
scaled_time = timestep_range.unsqueeze(1) * inverse_timescales.unsqueeze(0)
# shape (timesteps, 2 * num_timescales)
sinusoids = torch.cat([torch.sin(scaled_time), torch.cos(scaled_time)], 1)
if hidden_dim % 2 != 0:
# if the number of dimensions is odd, the cos and sin
# timescales had size (hidden_dim - 1) / 2, so we need
# to add a row of zeros to make up the difference.
sinusoids = torch.cat([sinusoids, sinusoids.new_zeros(timesteps, 1)], 1)
return tensor + sinusoids.unsqueeze(0)
|
python
|
def add_positional_features(tensor: torch.Tensor,
min_timescale: float = 1.0,
max_timescale: float = 1.0e4):
# pylint: disable=line-too-long
"""
Implements the frequency-based positional encoding described
in `Attention is all you Need
<https://www.semanticscholar.org/paper/Attention-Is-All-You-Need-Vaswani-Shazeer/0737da0767d77606169cbf4187b83e1ab62f6077>`_ .
Adds sinusoids of different frequencies to a ``Tensor``. A sinusoid of a
different frequency and phase is added to each dimension of the input ``Tensor``.
This allows the attention heads to use absolute and relative positions.
The number of timescales is equal to hidden_dim / 2 within the range
(min_timescale, max_timescale). For each timescale, the two sinusoidal
signals sin(timestep / timescale) and cos(timestep / timescale) are
generated and concatenated along the hidden_dim dimension.
Parameters
----------
tensor : ``torch.Tensor``
a Tensor with shape (batch_size, timesteps, hidden_dim).
min_timescale : ``float``, optional (default = 1.0)
The smallest timescale to use.
max_timescale : ``float``, optional (default = 1.0e4)
The largest timescale to use.
Returns
-------
The input tensor augmented with the sinusoidal frequencies.
"""
_, timesteps, hidden_dim = tensor.size()
timestep_range = get_range_vector(timesteps, get_device_of(tensor)).data.float()
# We're generating both cos and sin frequencies,
# so half for each.
num_timescales = hidden_dim // 2
timescale_range = get_range_vector(num_timescales, get_device_of(tensor)).data.float()
log_timescale_increments = math.log(float(max_timescale) / float(min_timescale)) / float(num_timescales - 1)
inverse_timescales = min_timescale * torch.exp(timescale_range * -log_timescale_increments)
# Broadcasted multiplication - shape (timesteps, num_timescales)
scaled_time = timestep_range.unsqueeze(1) * inverse_timescales.unsqueeze(0)
# shape (timesteps, 2 * num_timescales)
sinusoids = torch.cat([torch.sin(scaled_time), torch.cos(scaled_time)], 1)
if hidden_dim % 2 != 0:
# if the number of dimensions is odd, the cos and sin
# timescales had size (hidden_dim - 1) / 2, so we need
# to add a row of zeros to make up the difference.
sinusoids = torch.cat([sinusoids, sinusoids.new_zeros(timesteps, 1)], 1)
return tensor + sinusoids.unsqueeze(0)
|
[
"def",
"add_positional_features",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"min_timescale",
":",
"float",
"=",
"1.0",
",",
"max_timescale",
":",
"float",
"=",
"1.0e4",
")",
":",
"# pylint: disable=line-too-long",
"_",
",",
"timesteps",
",",
"hidden_dim",
"=",
"tensor",
".",
"size",
"(",
")",
"timestep_range",
"=",
"get_range_vector",
"(",
"timesteps",
",",
"get_device_of",
"(",
"tensor",
")",
")",
".",
"data",
".",
"float",
"(",
")",
"# We're generating both cos and sin frequencies,",
"# so half for each.",
"num_timescales",
"=",
"hidden_dim",
"//",
"2",
"timescale_range",
"=",
"get_range_vector",
"(",
"num_timescales",
",",
"get_device_of",
"(",
"tensor",
")",
")",
".",
"data",
".",
"float",
"(",
")",
"log_timescale_increments",
"=",
"math",
".",
"log",
"(",
"float",
"(",
"max_timescale",
")",
"/",
"float",
"(",
"min_timescale",
")",
")",
"/",
"float",
"(",
"num_timescales",
"-",
"1",
")",
"inverse_timescales",
"=",
"min_timescale",
"*",
"torch",
".",
"exp",
"(",
"timescale_range",
"*",
"-",
"log_timescale_increments",
")",
"# Broadcasted multiplication - shape (timesteps, num_timescales)",
"scaled_time",
"=",
"timestep_range",
".",
"unsqueeze",
"(",
"1",
")",
"*",
"inverse_timescales",
".",
"unsqueeze",
"(",
"0",
")",
"# shape (timesteps, 2 * num_timescales)",
"sinusoids",
"=",
"torch",
".",
"cat",
"(",
"[",
"torch",
".",
"sin",
"(",
"scaled_time",
")",
",",
"torch",
".",
"cos",
"(",
"scaled_time",
")",
"]",
",",
"1",
")",
"if",
"hidden_dim",
"%",
"2",
"!=",
"0",
":",
"# if the number of dimensions is odd, the cos and sin",
"# timescales had size (hidden_dim - 1) / 2, so we need",
"# to add a row of zeros to make up the difference.",
"sinusoids",
"=",
"torch",
".",
"cat",
"(",
"[",
"sinusoids",
",",
"sinusoids",
".",
"new_zeros",
"(",
"timesteps",
",",
"1",
")",
"]",
",",
"1",
")",
"return",
"tensor",
"+",
"sinusoids",
".",
"unsqueeze",
"(",
"0",
")"
] |
Implements the frequency-based positional encoding described
in `Attention is all you Need
<https://www.semanticscholar.org/paper/Attention-Is-All-You-Need-Vaswani-Shazeer/0737da0767d77606169cbf4187b83e1ab62f6077>`_ .
Adds sinusoids of different frequencies to a ``Tensor``. A sinusoid of a
different frequency and phase is added to each dimension of the input ``Tensor``.
This allows the attention heads to use absolute and relative positions.
The number of timescales is equal to hidden_dim / 2 within the range
(min_timescale, max_timescale). For each timescale, the two sinusoidal
signals sin(timestep / timescale) and cos(timestep / timescale) are
generated and concatenated along the hidden_dim dimension.
Parameters
----------
tensor : ``torch.Tensor``
a Tensor with shape (batch_size, timesteps, hidden_dim).
min_timescale : ``float``, optional (default = 1.0)
The smallest timescale to use.
max_timescale : ``float``, optional (default = 1.0e4)
The largest timescale to use.
Returns
-------
The input tensor augmented with the sinusoidal frequencies.
|
[
"Implements",
"the",
"frequency",
"-",
"based",
"positional",
"encoding",
"described",
"in",
"Attention",
"is",
"all",
"you",
"Need",
"<https",
":",
"//",
"www",
".",
"semanticscholar",
".",
"org",
"/",
"paper",
"/",
"Attention",
"-",
"Is",
"-",
"All",
"-",
"You",
"-",
"Need",
"-",
"Vaswani",
"-",
"Shazeer",
"/",
"0737da0767d77606169cbf4187b83e1ab62f6077",
">",
"_",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1235-L1286
|
train
|
A function that adds positional features to a base - 2 vocab.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHA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kZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(652 - 603) + chr(518 - 467) + '\x31', 54412 - 54404), ehT0Px3KOsy9(chr(211 - 163) + chr(2665 - 2554) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b1001 + 0o51) + '\x37' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(226 - 175) + chr(0b110100) + chr(0b110100), 56882 - 56874), ehT0Px3KOsy9('\060' + chr(111) + '\062' + chr(0b10001 + 0o40) + chr(55), 0b1000), ehT0Px3KOsy9(chr(48) + chr(9355 - 9244) + chr(51) + chr(48) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + chr(11184 - 11073) + chr(0b100011 + 0o17) + '\x33' + '\x36', 15315 - 15307), ehT0Px3KOsy9(chr(320 - 272) + '\157' + '\063' + chr(0b110000 + 0o5) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + chr(0b110001 + 0o2) + chr(0b1101 + 0o45) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(1704 - 1656) + chr(3930 - 3819) + '\061' + chr(1688 - 1640) + '\x35', 0o10), ehT0Px3KOsy9(chr(656 - 608) + '\157' + '\065' + chr(48), 10884 - 10876), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b11010 + 0o34) + chr(49), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001000 + 0o47) + chr(49) + '\x36' + chr(807 - 753), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101 + 0o142) + '\067' + chr(53), 11909 - 11901), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11001 + 0o33) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\061' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11982 - 11871) + '\x33' + chr(0b110100) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\x37' + '\x33', 57980 - 57972), ehT0Px3KOsy9('\060' + chr(0b1100111 + 0o10) + chr(0b10011 + 0o37) + chr(0b100 + 0o62) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1245 - 1197) + chr(4539 - 4428) + chr(0b11011 + 0o26) + '\066' + '\063', 61238 - 61230), ehT0Px3KOsy9(chr(0b110000) + chr(1376 - 1265) + chr(0b110001) + '\x36' + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x35' + chr(347 - 298), ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(5812 - 5701) + chr(2172 - 2122) + '\062', 15337 - 15329), ehT0Px3KOsy9('\x30' + chr(0b11111 + 0o120) + chr(496 - 445) + '\x31' + chr(0b11111 + 0o26), 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + '\x36' + chr(1819 - 1764), 33339 - 33331), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\x37' + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + '\066' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\x6f' + '\x31' + chr(0b101010 + 0o6) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(1383 - 1332) + chr(0b111 + 0o57) + chr(1954 - 1905), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(623 - 572) + chr(1897 - 1849) + chr(804 - 750), 28420 - 28412), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(0b100110 + 0o21) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(0b10100 + 0o34), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100001 + 0o20) + '\060' + '\064', 8), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(0b0 + 0o62), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(1814 - 1765) + '\061', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x32' + '\x30' + chr(52), 27317 - 27309), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(3995 - 3884) + chr(0b110011) + chr(0b110111) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110101) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6573 - 6462) + chr(0b10101 + 0o35) + chr(54) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1100 + 0o143) + '\x32' + '\064' + '\x37', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1101111) + '\065' + '\x30', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'w'), chr(100) + '\145' + chr(0b1100011) + '\x6f' + '\144' + '\x65')(chr(9785 - 9668) + chr(0b1110100) + chr(0b1001 + 0o135) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def FHq6d_1q0zfo(LK3cpXJU3UM0, oBkcbk4shbII=1.0, PypK95RAsTJD=10000.0):
(VNGQdHSFPrso, QNvXCjnvcnON, CQFa_cRh0Tor) = LK3cpXJU3UM0.NLcc3BCJnQka()
Ga6EyINDNFk1 = BNXuFoJp86Jx(QNvXCjnvcnON, yRvvZkDFNAV9(LK3cpXJU3UM0)).data.float()
OIfnhLMUVPqI = CQFa_cRh0Tor // ehT0Px3KOsy9(chr(442 - 394) + chr(0b1101111) + chr(50), 0o10)
zOupgJZzoY76 = BNXuFoJp86Jx(OIfnhLMUVPqI, yRvvZkDFNAV9(LK3cpXJU3UM0)).data.float()
IrpVjD1x9id2 = yhiZVkosCjBm.log(kkSX4ccExqw4(PypK95RAsTJD) / kkSX4ccExqw4(oBkcbk4shbII)) / kkSX4ccExqw4(OIfnhLMUVPqI - ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1445 - 1396), 41800 - 41792))
HC9mM09PQ9S2 = oBkcbk4shbII * cEkFpYktkSeK.exp(zOupgJZzoY76 * -IrpVjD1x9id2)
Du9ko_fYsEXa = Ga6EyINDNFk1.unsqueeze(ehT0Px3KOsy9('\060' + chr(111) + chr(1152 - 1103), 8)) * HC9mM09PQ9S2.unsqueeze(ehT0Px3KOsy9('\060' + '\157' + chr(0b110000), 0o10))
RUpUNpNYJ3v2 = cEkFpYktkSeK.cat([cEkFpYktkSeK.sin(Du9ko_fYsEXa), cEkFpYktkSeK.cos(Du9ko_fYsEXa)], ehT0Px3KOsy9(chr(48) + '\157' + chr(49), 8))
if CQFa_cRh0Tor % ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(11558 - 11447) + '\062', 8) != ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100110 + 0o12), 8):
RUpUNpNYJ3v2 = cEkFpYktkSeK.cat([RUpUNpNYJ3v2, RUpUNpNYJ3v2.new_zeros(QNvXCjnvcnON, ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x31', 8))], ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(8640 - 8529) + chr(0b110001), 8))
return LK3cpXJU3UM0 + xafqLlk3kkUe(RUpUNpNYJ3v2, xafqLlk3kkUe(SXOLrMavuUCe(b',m\xca\x95\xfa\xa2\xfb\x97\xb5'), chr(100) + chr(0b1100101) + chr(5352 - 5253) + chr(0b1101111) + '\x64' + '\145')(chr(117) + '\x74' + chr(0b1001100 + 0o32) + '\x2d' + chr(0b111000)))(ehT0Px3KOsy9(chr(48) + '\x6f' + '\x30', 8))
|
allenai/allennlp
|
allennlp/nn/util.py
|
clone
|
def clone(module: torch.nn.Module, num_copies: int) -> torch.nn.ModuleList:
"""Produce N identical layers."""
return torch.nn.ModuleList([copy.deepcopy(module) for _ in range(num_copies)])
|
python
|
def clone(module: torch.nn.Module, num_copies: int) -> torch.nn.ModuleList:
"""Produce N identical layers."""
return torch.nn.ModuleList([copy.deepcopy(module) for _ in range(num_copies)])
|
[
"def",
"clone",
"(",
"module",
":",
"torch",
".",
"nn",
".",
"Module",
",",
"num_copies",
":",
"int",
")",
"->",
"torch",
".",
"nn",
".",
"ModuleList",
":",
"return",
"torch",
".",
"nn",
".",
"ModuleList",
"(",
"[",
"copy",
".",
"deepcopy",
"(",
"module",
")",
"for",
"_",
"in",
"range",
"(",
"num_copies",
")",
"]",
")"
] |
Produce N identical layers.
|
[
"Produce",
"N",
"identical",
"layers",
"."
] |
648a36f77db7e45784c047176074f98534c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3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b10011 + 0o134) + '\x32' + chr(0b110011) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(1546 - 1498) + '\157' + '\062' + chr(0b11110 + 0o22), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10111 + 0o34) + '\066' + chr(1786 - 1731), ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b100010 + 0o115) + '\x36' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(51) + chr(0b110010), 18355 - 18347), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100010 + 0o20) + '\063' + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2213 - 2163) + '\061' + chr(0b11001 + 0o27), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(6272 - 6161) + chr(51) + '\x31' + chr(2003 - 1948), 46076 - 46068), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + chr(0b100100 + 0o14) + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1000001 + 0o56) + chr(853 - 804) + chr(919 - 868) + '\x31', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111 + 0o0) + chr(0b100111 + 0o14) + chr(0b1111 + 0o43) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1010101 + 0o32) + chr(0b110010) + '\066' + '\062', 24532 - 24524), ehT0Px3KOsy9(chr(0b110000) + chr(0b11011 + 0o124) + '\061' + '\x37' + chr(0b10111 + 0o34), 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(10603 - 10492) + chr(54) + '\x33', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1011011 + 0o24) + chr(0b10010 + 0o37) + chr(0b101011 + 0o5) + chr(198 - 149), 0o10), ehT0Px3KOsy9('\060' + chr(7204 - 7093) + chr(0b110010) + chr(0b110001) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + '\x34' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b110000), 8), ehT0Px3KOsy9(chr(479 - 431) + '\157' + '\x31' + '\062' + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(1426 - 1374) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(108 - 60) + chr(2854 - 2743) + chr(1770 - 1721) + '\x32' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10 + 0o61) + '\062' + chr(0b100101 + 0o17), 54791 - 54783), ehT0Px3KOsy9(chr(376 - 328) + chr(391 - 280) + '\062' + chr(692 - 643) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111 + 0o150) + chr(50) + chr(0b11101 + 0o25) + '\x31', 60352 - 60344), ehT0Px3KOsy9(chr(0b110000) + chr(0b111 + 0o150) + '\x33' + chr(288 - 239) + chr(0b101101 + 0o10), 12161 - 12153), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1376 - 1326) + chr(52) + chr(52), 36934 - 36926), ehT0Px3KOsy9('\060' + chr(0b10101 + 0o132) + chr(0b110001) + chr(0b11111 + 0o21) + '\x35', 19305 - 19297), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(0b1001100 + 0o43) + '\063' + chr(53), 0b1000), ehT0Px3KOsy9(chr(2111 - 2063) + '\157' + chr(107 - 57) + chr(0b110110), 17362 - 17354), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\x34' + chr(2460 - 2407), ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1101111) + '\064' + '\x36', 36150 - 36142), ehT0Px3KOsy9(chr(0b110000) + chr(0b10111 + 0o130) + chr(0b10100 + 0o35) + chr(0b110011) + '\061', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(53) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + '\x33' + '\062', 8), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(1981 - 1926) + chr(2671 - 2619), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001 + 0o2) + chr(0b110101) + chr(1480 - 1430), 0o10), ehT0Px3KOsy9('\x30' + chr(7850 - 7739) + chr(1978 - 1928) + chr(0b110011 + 0o0) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(0b111111 + 0o60) + chr(734 - 683) + '\064' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b1110 + 0o51) + chr(0b1110 + 0o47), 0o10), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1001 + 0o146) + '\x34' + '\061', 55544 - 55536)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(111) + chr(53) + chr(0b10101 + 0o33), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2'), chr(0b10101 + 0o117) + chr(101) + '\143' + '\x6f' + chr(0b1100100) + chr(0b1001100 + 0o31))(chr(0b1110101) + chr(0b1110100 + 0o0) + chr(2588 - 2486) + chr(0b101101) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def R5ZTcq6uIjKL(RqocVGOryNPv, OQH4GncYTgKq) -> xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1\x7f\x93E6\xfd\xc4\xa6\xf7-'), chr(7120 - 7020) + chr(3282 - 3181) + '\x63' + '\x6f' + chr(6851 - 6751) + chr(0b100 + 0o141))(chr(117) + '\x74' + '\146' + chr(45) + chr(183 - 127))):
return xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1\x7f\x93E6\xfd\xc4\xa6\xf7-'), chr(0b100001 + 0o103) + chr(101) + chr(0b11110 + 0o105) + chr(111) + '\x64' + chr(5174 - 5073))(chr(117) + chr(116) + chr(5026 - 4924) + '\055' + chr(2816 - 2760)))([xafqLlk3kkUe(igThHS4jwVsa, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf8u\x92@9\xf7\xf8\xb6'), '\144' + chr(101) + '\x63' + chr(7010 - 6899) + '\144' + chr(0b1100101))(chr(0b1110101) + chr(11478 - 11362) + chr(0b11111 + 0o107) + '\055' + chr(0b111000)))(RqocVGOryNPv) for VNGQdHSFPrso in vQr8gNKaIaWE(OQH4GncYTgKq)])
|
allenai/allennlp
|
allennlp/nn/util.py
|
combine_initial_dims
|
def combine_initial_dims(tensor: torch.Tensor) -> torch.Tensor:
"""
Given a (possibly higher order) tensor of ids with shape
(d1, ..., dn, sequence_length)
Return a view that's (d1 * ... * dn, sequence_length).
If original tensor is 1-d or 2-d, return it as is.
"""
if tensor.dim() <= 2:
return tensor
else:
return tensor.view(-1, tensor.size(-1))
|
python
|
def combine_initial_dims(tensor: torch.Tensor) -> torch.Tensor:
"""
Given a (possibly higher order) tensor of ids with shape
(d1, ..., dn, sequence_length)
Return a view that's (d1 * ... * dn, sequence_length).
If original tensor is 1-d or 2-d, return it as is.
"""
if tensor.dim() <= 2:
return tensor
else:
return tensor.view(-1, tensor.size(-1))
|
[
"def",
"combine_initial_dims",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"tensor",
".",
"dim",
"(",
")",
"<=",
"2",
":",
"return",
"tensor",
"else",
":",
"return",
"tensor",
".",
"view",
"(",
"-",
"1",
",",
"tensor",
".",
"size",
"(",
"-",
"1",
")",
")"
] |
Given a (possibly higher order) tensor of ids with shape
(d1, ..., dn, sequence_length)
Return a view that's (d1 * ... * dn, sequence_length).
If original tensor is 1-d or 2-d, return it as is.
|
[
"Given",
"a",
"(",
"possibly",
"higher",
"order",
")",
"tensor",
"of",
"ids",
"with",
"shape",
"(",
"d1",
"...",
"dn",
"sequence_length",
")",
"Return",
"a",
"view",
"that",
"s",
"(",
"d1",
"*",
"...",
"*",
"dn",
"sequence_length",
")",
".",
"If",
"original",
"tensor",
"is",
"1",
"-",
"d",
"or",
"2",
"-",
"d",
"return",
"it",
"as",
"is",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1294-L1304
|
train
|
Combine initial dimensions of a sequence of ids with shape
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,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mV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(0b100010 + 0o22) + chr(0b1100 + 0o52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(51), 13443 - 13435), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b1101111) + chr(51) + chr(1618 - 1564) + '\x36', 59317 - 59309), ehT0Px3KOsy9('\060' + chr(4665 - 4554) + chr(0b11101 + 0o25) + chr(0b110111) + chr(1178 - 1126), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + '\060' + chr(1612 - 1557), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(727 - 676) + '\063', 0o10), ehT0Px3KOsy9(chr(2104 - 2056) + chr(0b110100 + 0o73) + '\066' + '\x31', 0o10), ehT0Px3KOsy9(chr(48) + chr(10329 - 10218) + '\x32' + chr(0b110001) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(6409 - 6298) + '\061' + chr(1083 - 1034) + chr(1289 - 1235), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(48) + chr(55), 8), ehT0Px3KOsy9('\060' + chr(0b1010 + 0o145) + chr(50) + chr(0b110010) + chr(49), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x37' + chr(49), 14528 - 14520), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b100100 + 0o22) + chr(0b110010), 36085 - 36077), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\064' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(7512 - 7401) + chr(51) + '\x35' + chr(0b1011 + 0o52), 0b1000), ehT0Px3KOsy9(chr(1641 - 1593) + '\157' + chr(0b100001 + 0o22) + chr(2686 - 2631) + chr(988 - 939), 14159 - 14151), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + chr(0b110001 + 0o6) + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(53) + '\065', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\x35' + chr(1322 - 1274), 51656 - 51648), ehT0Px3KOsy9(chr(48) + chr(0b1101101 + 0o2) + '\x33' + chr(50) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + '\063', 27348 - 27340), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + '\x31' + '\065', 0o10), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + '\x33' + chr(1834 - 1782) + '\x35', 48413 - 48405), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1101 + 0o46) + chr(385 - 337) + chr(0b1 + 0o64), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10001 + 0o45) + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(55), 37371 - 37363), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010 + 0o0) + '\x32' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\060' + chr(6006 - 5895) + chr(0b101110 + 0o4) + chr(0b110011) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\157' + chr(0b110010) + chr(1287 - 1237) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(51) + chr(51) + chr(0b11110 + 0o27), 24647 - 24639), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + '\x31' + '\x37', 61179 - 61171), ehT0Px3KOsy9('\x30' + chr(1896 - 1785) + '\062' + chr(0b10111 + 0o40) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(5175 - 5064) + chr(49) + '\062' + chr(0b1 + 0o57), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(457 - 346) + chr(0b110001) + chr(53), 0o10), ehT0Px3KOsy9('\x30' + chr(9417 - 9306) + chr(0b101111 + 0o4) + chr(0b11010 + 0o34) + chr(0b100000 + 0o23), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b10010 + 0o135) + chr(0b1000 + 0o52) + '\062' + chr(2095 - 2040), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(0b1 + 0o63) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\x6f' + chr(0b100110 + 0o21) + chr(0b101010 + 0o6), 0b1000), ehT0Px3KOsy9(chr(1293 - 1245) + chr(111) + '\062' + chr(1403 - 1354) + '\067', 8), ehT0Px3KOsy9('\060' + '\157' + '\065' + chr(49), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b1101111) + '\x35' + chr(0b10000 + 0o40), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc8'), '\x64' + chr(4173 - 4072) + '\x63' + chr(0b1101111) + chr(0b1100100) + chr(9158 - 9057))('\x75' + chr(116) + chr(0b1100110) + chr(0b11001 + 0o24) + chr(0b101010 + 0o16)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def JX5Llv_TBmt8(LK3cpXJU3UM0) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2n\x98\xcf\xe8i'), '\x64' + chr(0b1100101) + chr(518 - 419) + '\x6f' + '\x64' + chr(0b1100101))('\165' + '\164' + '\x66' + chr(45) + '\x38')):
if xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x82b\x9b'), '\144' + chr(101) + '\143' + chr(0b1011011 + 0o24) + chr(1041 - 941) + chr(101))(chr(0b1001011 + 0o52) + '\164' + chr(7017 - 6915) + chr(45) + '\070'))() <= ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + chr(2153 - 2103), ord("\x08")):
return LK3cpXJU3UM0
else:
return xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\x90b\x93\xcb'), '\x64' + chr(357 - 256) + '\143' + chr(0b1101111) + '\144' + chr(0b1100101))('\x75' + chr(0b1000101 + 0o57) + '\146' + chr(0b11001 + 0o24) + '\x38'))(-ehT0Px3KOsy9('\060' + '\x6f' + '\061', 50995 - 50987), xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8G\x95\xdf\xb4Yr\xc6 \xd6\xfaX'), '\144' + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(0b1100100) + chr(101))('\165' + '\164' + chr(9697 - 9595) + chr(0b101101) + '\x38'))(-ehT0Px3KOsy9(chr(48) + chr(0b110111 + 0o70) + '\x31', 8)))
|
allenai/allennlp
|
allennlp/nn/util.py
|
uncombine_initial_dims
|
def uncombine_initial_dims(tensor: torch.Tensor, original_size: torch.Size) -> torch.Tensor:
"""
Given a tensor of embeddings with shape
(d1 * ... * dn, sequence_length, embedding_dim)
and the original shape
(d1, ..., dn, sequence_length),
return the reshaped tensor of embeddings with shape
(d1, ..., dn, sequence_length, embedding_dim).
If original size is 1-d or 2-d, return it as is.
"""
if len(original_size) <= 2:
return tensor
else:
view_args = list(original_size) + [tensor.size(-1)]
return tensor.view(*view_args)
|
python
|
def uncombine_initial_dims(tensor: torch.Tensor, original_size: torch.Size) -> torch.Tensor:
"""
Given a tensor of embeddings with shape
(d1 * ... * dn, sequence_length, embedding_dim)
and the original shape
(d1, ..., dn, sequence_length),
return the reshaped tensor of embeddings with shape
(d1, ..., dn, sequence_length, embedding_dim).
If original size is 1-d or 2-d, return it as is.
"""
if len(original_size) <= 2:
return tensor
else:
view_args = list(original_size) + [tensor.size(-1)]
return tensor.view(*view_args)
|
[
"def",
"uncombine_initial_dims",
"(",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"original_size",
":",
"torch",
".",
"Size",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"len",
"(",
"original_size",
")",
"<=",
"2",
":",
"return",
"tensor",
"else",
":",
"view_args",
"=",
"list",
"(",
"original_size",
")",
"+",
"[",
"tensor",
".",
"size",
"(",
"-",
"1",
")",
"]",
"return",
"tensor",
".",
"view",
"(",
"*",
"view_args",
")"
] |
Given a tensor of embeddings with shape
(d1 * ... * dn, sequence_length, embedding_dim)
and the original shape
(d1, ..., dn, sequence_length),
return the reshaped tensor of embeddings with shape
(d1, ..., dn, sequence_length, embedding_dim).
If original size is 1-d or 2-d, return it as is.
|
[
"Given",
"a",
"tensor",
"of",
"embeddings",
"with",
"shape",
"(",
"d1",
"*",
"...",
"*",
"dn",
"sequence_length",
"embedding_dim",
")",
"and",
"the",
"original",
"shape",
"(",
"d1",
"...",
"dn",
"sequence_length",
")",
"return",
"the",
"reshaped",
"tensor",
"of",
"embeddings",
"with",
"shape",
"(",
"d1",
"...",
"dn",
"sequence_length",
"embedding_dim",
")",
".",
"If",
"original",
"size",
"is",
"1",
"-",
"d",
"or",
"2",
"-",
"d",
"return",
"it",
"as",
"is",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/util.py#L1307-L1321
|
train
|
Unbine initial dimensions of a single node.
|
Pu7Z6IJCgH3a,vcEHXBQX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Uz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b110000) + chr(48), 0b1000), ehT0Px3KOsy9(chr(243 - 195) + chr(0b111011 + 0o64) + chr(0b110010 + 0o2) + chr(1088 - 1039), ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(0b1101111) + chr(0b110011) + '\062' + chr(0b10100 + 0o41), 57573 - 57565), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + '\x33' + chr(50), 28549 - 28541), ehT0Px3KOsy9(chr(184 - 136) + chr(0b1101111) + chr(1380 - 1330) + chr(54) + chr(0b1001 + 0o51), 0o10), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + chr(0b101010 + 0o7) + chr(0b110110) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(1049 - 996) + chr(0b1000 + 0o56), ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(50) + chr(0b101001 + 0o10) + chr(0b110110), 32970 - 32962), ehT0Px3KOsy9(chr(1163 - 1115) + chr(0b1101111) + chr(0b110010) + '\x32' + chr(0b100000 + 0o26), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(2637 - 2583) + '\x34', 0b1000), ehT0Px3KOsy9(chr(913 - 865) + '\157' + chr(50) + chr(0b110111) + chr(55), 64136 - 64128), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(0b100100 + 0o15) + chr(2226 - 2171), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(7510 - 7399) + '\x32' + chr(0b110010) + chr(49), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b110011) + chr(0b110010) + '\x36', 0o10), ehT0Px3KOsy9(chr(566 - 518) + '\x6f' + chr(0b110001) + chr(1945 - 1895) + '\063', 29649 - 29641), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(454 - 399) + '\x31', 0o10), ehT0Px3KOsy9(chr(1791 - 1743) + chr(9002 - 8891) + chr(51) + chr(0b1000 + 0o53), 52353 - 52345), ehT0Px3KOsy9(chr(48) + chr(0b1010 + 0o145) + '\063' + chr(378 - 327) + chr(1798 - 1746), 0o10), ehT0Px3KOsy9(chr(758 - 710) + '\x6f' + chr(0b110011) + chr(568 - 519) + '\062', 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + '\x33' + chr(0b110010 + 0o0) + '\064', 44820 - 44812), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + '\066' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10280 - 10169) + chr(49) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110011) + '\061', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x33' + '\x36' + chr(48), 0b1000), ehT0Px3KOsy9(chr(2009 - 1961) + chr(111) + '\x35' + chr(48), 29134 - 29126), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + chr(0b10011 + 0o41) + '\063', 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(54) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6423 - 6312) + chr(1740 - 1689) + chr(0b100100 + 0o17) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(1885 - 1832), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + '\x31', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x37' + '\067', 20425 - 20417), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x37' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(2149 - 2101) + chr(0b1101111) + chr(0b110011) + '\x30', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100011 + 0o23) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b101110 + 0o101) + chr(0b11111 + 0o22) + chr(0b101010 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + chr(0b11101 + 0o26) + '\064', 36878 - 36870), ehT0Px3KOsy9(chr(1778 - 1730) + chr(10105 - 9994) + chr(2546 - 2495) + chr(0b110111) + '\061', 24822 - 24814), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(2437 - 2385) + chr(2419 - 2366), 0o10), ehT0Px3KOsy9('\060' + '\157' + '\063' + '\060' + chr(817 - 768), 41996 - 41988), ehT0Px3KOsy9(chr(48) + chr(0b1101010 + 0o5) + '\061' + '\x34' + '\x31', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(4678 - 4567) + '\x35' + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'n'), chr(0b1011010 + 0o12) + '\145' + chr(99) + chr(0b1101111) + chr(100) + '\145')(chr(0b101000 + 0o115) + '\x74' + chr(0b1100110) + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def boG575GZZt1b(LK3cpXJU3UM0, wzsAhoEWGc01) -> xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'\x14D\xbb\xe9\xdd\x05'), '\x64' + '\145' + '\143' + chr(111) + chr(0b11101 + 0o107) + chr(0b1100101))('\x75' + '\164' + '\x66' + chr(45) + chr(56))):
if c2A0yzQpDQB3(wzsAhoEWGc01) <= ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50), 42295 - 42287):
return LK3cpXJU3UM0
else:
SO0Gr8syL7pm = YyaZ4tpXu4lf(wzsAhoEWGc01) + [LK3cpXJU3UM0.NLcc3BCJnQka(-ehT0Px3KOsy9(chr(1884 - 1836) + chr(12133 - 12022) + chr(0b11 + 0o56), 49001 - 48993))]
return xafqLlk3kkUe(LK3cpXJU3UM0, xafqLlk3kkUe(SXOLrMavuUCe(b'6H\xb0\xed'), '\144' + chr(0b101001 + 0o74) + chr(0b1100011) + '\157' + chr(0b1100010 + 0o2) + chr(0b1000000 + 0o45))('\165' + chr(0b1110100) + chr(9197 - 9095) + chr(593 - 548) + chr(56)))(*SO0Gr8syL7pm)
|
allenai/allennlp
|
allennlp/semparse/contexts/table_question_context.py
|
TableQuestionContext._string_in_table
|
def _string_in_table(self, candidate: str) -> List[str]:
"""
Checks if the string occurs in the table, and if it does, returns the names of the columns
under which it occurs. If it does not, returns an empty list.
"""
candidate_column_names: List[str] = []
# First check if the entire candidate occurs as a cell.
if candidate in self._string_column_mapping:
candidate_column_names = self._string_column_mapping[candidate]
# If not, check if it is a substring pf any cell value.
if not candidate_column_names:
for cell_value, column_names in self._string_column_mapping.items():
if candidate in cell_value:
candidate_column_names.extend(column_names)
candidate_column_names = list(set(candidate_column_names))
return candidate_column_names
|
python
|
def _string_in_table(self, candidate: str) -> List[str]:
"""
Checks if the string occurs in the table, and if it does, returns the names of the columns
under which it occurs. If it does not, returns an empty list.
"""
candidate_column_names: List[str] = []
# First check if the entire candidate occurs as a cell.
if candidate in self._string_column_mapping:
candidate_column_names = self._string_column_mapping[candidate]
# If not, check if it is a substring pf any cell value.
if not candidate_column_names:
for cell_value, column_names in self._string_column_mapping.items():
if candidate in cell_value:
candidate_column_names.extend(column_names)
candidate_column_names = list(set(candidate_column_names))
return candidate_column_names
|
[
"def",
"_string_in_table",
"(",
"self",
",",
"candidate",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"candidate_column_names",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"# First check if the entire candidate occurs as a cell.",
"if",
"candidate",
"in",
"self",
".",
"_string_column_mapping",
":",
"candidate_column_names",
"=",
"self",
".",
"_string_column_mapping",
"[",
"candidate",
"]",
"# If not, check if it is a substring pf any cell value.",
"if",
"not",
"candidate_column_names",
":",
"for",
"cell_value",
",",
"column_names",
"in",
"self",
".",
"_string_column_mapping",
".",
"items",
"(",
")",
":",
"if",
"candidate",
"in",
"cell_value",
":",
"candidate_column_names",
".",
"extend",
"(",
"column_names",
")",
"candidate_column_names",
"=",
"list",
"(",
"set",
"(",
"candidate_column_names",
")",
")",
"return",
"candidate_column_names"
] |
Checks if the string occurs in the table, and if it does, returns the names of the columns
under which it occurs. If it does not, returns an empty list.
|
[
"Checks",
"if",
"the",
"string",
"occurs",
"in",
"the",
"table",
"and",
"if",
"it",
"does",
"returns",
"the",
"names",
"of",
"the",
"columns",
"under",
"which",
"it",
"occurs",
".",
"If",
"it",
"does",
"not",
"returns",
"an",
"empty",
"list",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/table_question_context.py#L342-L357
|
train
|
Checks if the string occurs in the table and returns the names of the columns that occur in the table.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,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ZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(781 - 733) + '\x6f' + chr(2401 - 2351) + chr(55) + '\x34', 0o10), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(111) + '\061' + chr(0b1111 + 0o42) + '\066', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(0b10000 + 0o40), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100101 + 0o112) + chr(51) + '\x37' + chr(712 - 660), 0o10), ehT0Px3KOsy9(chr(1535 - 1487) + '\157' + chr(0b110011) + chr(0b110111) + chr(0b11001 + 0o33), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11010 + 0o31) + chr(0b110000) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1900 - 1851) + chr(0b10011 + 0o35) + chr(49), 40212 - 40204), ehT0Px3KOsy9('\x30' + chr(6537 - 6426) + chr(0b110010) + '\061' + chr(55), 0o10), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b11111 + 0o120) + chr(0b101011 + 0o7) + chr(0b11011 + 0o34) + chr(824 - 775), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\065' + chr(0b101101 + 0o7), 11465 - 11457), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + chr(555 - 506) + chr(0b11110 + 0o30), 8), ehT0Px3KOsy9('\060' + chr(0b1000010 + 0o55) + chr(0b1000 + 0o57) + '\x35', 34105 - 34097), ehT0Px3KOsy9('\060' + chr(0b1001011 + 0o44) + '\x32' + '\062' + chr(336 - 283), ord("\x08")), ehT0Px3KOsy9(chr(811 - 763) + chr(0b1010110 + 0o31) + '\x32' + '\x36' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(12303 - 12192) + '\062' + chr(2349 - 2300) + chr(50), 28366 - 28358), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101101 + 0o4) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1607 - 1558) + '\063', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(2782 - 2727) + '\065', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(945 - 896) + chr(0b100110 + 0o15) + chr(1758 - 1709), 0o10), ehT0Px3KOsy9('\x30' + chr(0b100000 + 0o117) + chr(2487 - 2436) + chr(0b11 + 0o55) + '\064', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(109 - 58) + chr(55) + chr(1822 - 1771), ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(51) + '\067' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\060' + chr(2041 - 1930) + chr(0b110001) + chr(51), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\x30' + chr(2203 - 2152), 0o10), ehT0Px3KOsy9(chr(2251 - 2203) + chr(5013 - 4902) + '\062' + '\x30' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(53) + chr(141 - 90), 0b1000), ehT0Px3KOsy9(chr(2047 - 1999) + chr(2168 - 2057) + chr(0b110010) + chr(0b101110 + 0o2) + chr(50), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1917 - 1863) + chr(52), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(0b110100) + chr(862 - 807), 0o10), ehT0Px3KOsy9(chr(1707 - 1659) + chr(6843 - 6732) + chr(0b110001) + '\064' + chr(0b11010 + 0o26), 46732 - 46724), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + '\x32', 8), ehT0Px3KOsy9(chr(655 - 607) + chr(0b1101111) + '\x32' + '\x35' + chr(955 - 907), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + '\x31' + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x34' + '\x32', 2556 - 2548), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1011 + 0o47) + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(0b110000), 8), ehT0Px3KOsy9('\x30' + chr(0b111110 + 0o61) + '\064' + '\067', 35711 - 35703), ehT0Px3KOsy9(chr(2225 - 2177) + '\x6f' + chr(49) + '\x33' + chr(344 - 289), 31614 - 31606), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(49) + '\x31' + '\065', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(0b110000 + 0o77) + chr(0b110000 + 0o5) + chr(863 - 815), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x92'), '\x64' + '\145' + chr(99) + '\x6f' + '\x64' + chr(101))(chr(0b1110101) + chr(0b1110100) + chr(102) + '\055' + chr(0b101 + 0o63)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def E8e6OtR_wJsx(oVre8I6UXc3b, X3DOc7TuFLS2) -> qRxF7OQ0y39T[M8_cKLkHVB2V]:
UdIoA5SncGHe = []
if X3DOc7TuFLS2 in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3=~b\x95\x92\xa4\x1e\xec\xd6@;P\xfb\xe9\xe7l{\xcd0\xaa\x9c'), chr(100) + '\145' + chr(0b1100011) + '\157' + '\144' + chr(101))(chr(117) + chr(116) + '\x66' + chr(283 - 238) + '\x38')):
UdIoA5SncGHe = oVre8I6UXc3b._string_column_mapping[X3DOc7TuFLS2]
if not UdIoA5SncGHe:
for (aD_2yKARQV60, Xw0ldSZpFZe4) in xafqLlk3kkUe(oVre8I6UXc3b._string_column_mapping, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf24|u\xb5\xa6\xf0\x08\xe3\xeadw'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(0b10111 + 0o130) + chr(0b1011000 + 0o14) + chr(0b1010111 + 0o16))('\165' + chr(0b1011110 + 0o26) + '\x66' + chr(45) + chr(2056 - 2000)))():
if X3DOc7TuFLS2 in aD_2yKARQV60:
xafqLlk3kkUe(UdIoA5SncGHe, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd96~u\x92\x98'), chr(0b1100100) + '\x65' + chr(0b1001011 + 0o30) + chr(0b1010010 + 0o35) + '\x64' + '\145')(chr(6851 - 6734) + chr(3689 - 3573) + '\146' + '\055' + chr(56)))(Xw0ldSZpFZe4)
UdIoA5SncGHe = YyaZ4tpXu4lf(MVEN8G6CxlvR(UdIoA5SncGHe))
return UdIoA5SncGHe
|
allenai/allennlp
|
allennlp/semparse/contexts/table_question_context.py
|
TableQuestionContext.normalize_string
|
def normalize_string(string: str) -> str:
"""
These are the transformation rules used to normalize cell in column names in Sempre. See
``edu.stanford.nlp.sempre.tables.StringNormalizationUtils.characterNormalize`` and
``edu.stanford.nlp.sempre.tables.TableTypeSystem.canonicalizeName``. We reproduce those
rules here to normalize and canonicalize cells and columns in the same way so that we can
match them against constants in logical forms appropriately.
"""
# Normalization rules from Sempre
# \u201A -> ,
string = re.sub("‚", ",", string)
string = re.sub("„", ",,", string)
string = re.sub("[·・]", ".", string)
string = re.sub("…", "...", string)
string = re.sub("ˆ", "^", string)
string = re.sub("˜", "~", string)
string = re.sub("‹", "<", string)
string = re.sub("›", ">", string)
string = re.sub("[‘’´`]", "'", string)
string = re.sub("[“”«»]", "\"", string)
string = re.sub("[•†‡²³]", "", string)
string = re.sub("[‐‑–—−]", "-", string)
# Oddly, some unicode characters get converted to _ instead of being stripped. Not really
# sure how sempre decides what to do with these... TODO(mattg): can we just get rid of the
# need for this function somehow? It's causing a whole lot of headaches.
string = re.sub("[ðø′″€⁄ªΣ]", "_", string)
# This is such a mess. There isn't just a block of unicode that we can strip out, because
# sometimes sempre just strips diacritics... We'll try stripping out a few separate
# blocks, skipping the ones that sempre skips...
string = re.sub("[\\u0180-\\u0210]", "", string).strip()
string = re.sub("[\\u0220-\\uFFFF]", "", string).strip()
string = string.replace("\\n", "_")
string = re.sub("\\s+", " ", string)
# Canonicalization rules from Sempre.
string = re.sub("[^\\w]", "_", string)
string = re.sub("_+", "_", string)
string = re.sub("_$", "", string)
return unidecode(string.lower())
|
python
|
def normalize_string(string: str) -> str:
"""
These are the transformation rules used to normalize cell in column names in Sempre. See
``edu.stanford.nlp.sempre.tables.StringNormalizationUtils.characterNormalize`` and
``edu.stanford.nlp.sempre.tables.TableTypeSystem.canonicalizeName``. We reproduce those
rules here to normalize and canonicalize cells and columns in the same way so that we can
match them against constants in logical forms appropriately.
"""
# Normalization rules from Sempre
# \u201A -> ,
string = re.sub("‚", ",", string)
string = re.sub("„", ",,", string)
string = re.sub("[·・]", ".", string)
string = re.sub("…", "...", string)
string = re.sub("ˆ", "^", string)
string = re.sub("˜", "~", string)
string = re.sub("‹", "<", string)
string = re.sub("›", ">", string)
string = re.sub("[‘’´`]", "'", string)
string = re.sub("[“”«»]", "\"", string)
string = re.sub("[•†‡²³]", "", string)
string = re.sub("[‐‑–—−]", "-", string)
# Oddly, some unicode characters get converted to _ instead of being stripped. Not really
# sure how sempre decides what to do with these... TODO(mattg): can we just get rid of the
# need for this function somehow? It's causing a whole lot of headaches.
string = re.sub("[ðø′″€⁄ªΣ]", "_", string)
# This is such a mess. There isn't just a block of unicode that we can strip out, because
# sometimes sempre just strips diacritics... We'll try stripping out a few separate
# blocks, skipping the ones that sempre skips...
string = re.sub("[\\u0180-\\u0210]", "", string).strip()
string = re.sub("[\\u0220-\\uFFFF]", "", string).strip()
string = string.replace("\\n", "_")
string = re.sub("\\s+", " ", string)
# Canonicalization rules from Sempre.
string = re.sub("[^\\w]", "_", string)
string = re.sub("_+", "_", string)
string = re.sub("_$", "", string)
return unidecode(string.lower())
|
[
"def",
"normalize_string",
"(",
"string",
":",
"str",
")",
"->",
"str",
":",
"# Normalization rules from Sempre",
"# \\u201A -> ,",
"string",
"=",
"re",
".",
"sub",
"(",
"\"‚\", ",
"\"",
"\", ",
"s",
"ring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"„\", ",
"\"",
",\", ",
"s",
"ring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[·・]\", \"",
".",
", s",
"t",
"ing)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"…\", ",
"\"",
"..\", ",
"s",
"ring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"ˆ\",",
" ",
"^\",",
" ",
"tring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"˜\",",
" ",
"~\",",
" ",
"tring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"‹\", ",
"\"",
"\", ",
"s",
"ring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"›\", ",
"\"",
"\", ",
"s",
"ring)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[‘’´`]\", \"'\"",
",",
"str",
"i",
"g)",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[“”«»]\", \"\\\"\"",
",",
"stri",
"n",
")",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[•†‡²³]\", \"\", st",
"r",
"ng",
")",
"",
"",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[‐‑–—−]\", \"-\", str",
"i",
"g)",
"",
"",
"",
"# Oddly, some unicode characters get converted to _ instead of being stripped. Not really",
"# sure how sempre decides what to do with these... TODO(mattg): can we just get rid of the",
"# need for this function somehow? It's causing a whole lot of headaches.",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[ðø′″€⁄ªΣ]\", \"_\", strin",
"g",
"",
"",
"",
"",
"# This is such a mess. There isn't just a block of unicode that we can strip out, because",
"# sometimes sempre just strips diacritics... We'll try stripping out a few separate",
"# blocks, skipping the ones that sempre skips...",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[\\\\u0180-\\\\u0210]\"",
",",
"\"\"",
",",
"string",
")",
".",
"strip",
"(",
")",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[\\\\u0220-\\\\uFFFF]\"",
",",
"\"\"",
",",
"string",
")",
".",
"strip",
"(",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"\"\\\\n\"",
",",
"\"_\"",
")",
"string",
"=",
"re",
".",
"sub",
"(",
"\"\\\\s+\"",
",",
"\" \"",
",",
"string",
")",
"# Canonicalization rules from Sempre.",
"string",
"=",
"re",
".",
"sub",
"(",
"\"[^\\\\w]\"",
",",
"\"_\"",
",",
"string",
")",
"string",
"=",
"re",
".",
"sub",
"(",
"\"_+\"",
",",
"\"_\"",
",",
"string",
")",
"string",
"=",
"re",
".",
"sub",
"(",
"\"_$\"",
",",
"\"\"",
",",
"string",
")",
"return",
"unidecode",
"(",
"string",
".",
"lower",
"(",
")",
")"
] |
These are the transformation rules used to normalize cell in column names in Sempre. See
``edu.stanford.nlp.sempre.tables.StringNormalizationUtils.characterNormalize`` and
``edu.stanford.nlp.sempre.tables.TableTypeSystem.canonicalizeName``. We reproduce those
rules here to normalize and canonicalize cells and columns in the same way so that we can
match them against constants in logical forms appropriately.
|
[
"These",
"are",
"the",
"transformation",
"rules",
"used",
"to",
"normalize",
"cell",
"in",
"column",
"names",
"in",
"Sempre",
".",
"See",
"edu",
".",
"stanford",
".",
"nlp",
".",
"sempre",
".",
"tables",
".",
"StringNormalizationUtils",
".",
"characterNormalize",
"and",
"edu",
".",
"stanford",
".",
"nlp",
".",
"sempre",
".",
"tables",
".",
"TableTypeSystem",
".",
"canonicalizeName",
".",
"We",
"reproduce",
"those",
"rules",
"here",
"to",
"normalize",
"and",
"canonicalize",
"cells",
"and",
"columns",
"in",
"the",
"same",
"way",
"so",
"that",
"we",
"can",
"match",
"them",
"against",
"constants",
"in",
"logical",
"forms",
"appropriately",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/table_question_context.py#L400-L437
|
train
|
Normalizes a string according to Sempre s rules.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXw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9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b111000 + 0o67) + chr(50) + chr(2208 - 2159) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + chr(0b1 + 0o60) + chr(0b110010) + '\x34', 60161 - 60153), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1037 - 984) + chr(0b10011 + 0o40), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1100111 + 0o10) + '\x32' + chr(0b110100) + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + chr(0b1001111 + 0o40) + '\067' + chr(842 - 788), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110100) + chr(850 - 802), 61557 - 61549), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + chr(0b110110) + chr(55), 36114 - 36106), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1391 - 1340) + '\x35' + chr(0b1 + 0o60), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100010 + 0o17) + '\061' + chr(0b101100 + 0o6), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + '\065' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(50) + chr(1354 - 1299), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101010 + 0o11) + '\067' + chr(0b110101), 21675 - 21667), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(0b1110 + 0o46) + chr(0b110101), 44697 - 44689), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100010 + 0o21) + chr(935 - 885) + '\x32', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100011 + 0o20) + chr(1597 - 1547) + '\065', 28271 - 28263), ehT0Px3KOsy9(chr(0b110000) + chr(0b111011 + 0o64) + '\062' + chr(0b10110 + 0o35) + '\061', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + chr(0b10 + 0o60) + chr(241 - 193), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + chr(50) + '\063' + '\067', 0b1000), ehT0Px3KOsy9('\060' + chr(6823 - 6712) + '\x33' + chr(0b110010) + chr(0b11101 + 0o25), 8), ehT0Px3KOsy9('\x30' + chr(0b1011011 + 0o24) + '\066' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + chr(0b110111) + '\x37', 29559 - 29551), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b110111) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(3885 - 3774) + chr(1376 - 1326) + chr(0b110010) + chr(0b11001 + 0o35), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + chr(626 - 571) + chr(48), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10101 + 0o40) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(4050 - 3939) + chr(0b110001) + chr(822 - 774), 0b1000), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\157' + chr(0b110001) + chr(0b10001 + 0o43) + '\x31', 10045 - 10037), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + '\x37' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(409 - 360) + chr(0b101010 + 0o7) + chr(0b10100 + 0o34), 0b1000), ehT0Px3KOsy9(chr(1144 - 1096) + '\x6f' + chr(265 - 215) + chr(55) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1011 + 0o53) + chr(0b100101 + 0o15), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b111100 + 0o63) + chr(0b11 + 0o56) + chr(48) + '\064', 0o10), ehT0Px3KOsy9(chr(199 - 151) + chr(4508 - 4397) + chr(0b101100 + 0o6) + chr(0b110010) + chr(408 - 353), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2302 - 2251) + chr(1734 - 1684) + '\x34', 17969 - 17961), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + chr(1326 - 1272), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001011 + 0o44) + chr(2279 - 2230) + '\061' + chr(50), 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + '\x37' + chr(0b110011), 8), ehT0Px3KOsy9(chr(2248 - 2200) + chr(5886 - 5775) + chr(0b110001) + chr(0b100110 + 0o20) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(1211 - 1163) + '\x6f' + chr(0b10000 + 0o42) + chr(1283 - 1235) + chr(0b11 + 0o61), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(828 - 778) + '\x32' + chr(55), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\157' + chr(0b100111 + 0o16) + '\x30', 40563 - 40555)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), '\x64' + '\145' + '\143' + chr(386 - 275) + '\x64' + chr(101))('\x75' + '\164' + chr(0b110 + 0o140) + chr(1464 - 1419) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def USN8fP7ywzS7(YfpuhF1UI1FC) -> M8_cKLkHVB2V:
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'm\xd4\xb1'), chr(0b1000010 + 0o42) + '\145' + chr(99) + chr(979 - 868) + '\x64' + chr(1820 - 1719))('\165' + '\164' + chr(0b1100110) + chr(1944 - 1899) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa3'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(0b111110 + 0o61) + chr(100) + chr(0b110101 + 0o60))(chr(9567 - 9450) + chr(0b1100111 + 0o15) + '\146' + chr(0b101001 + 0o4) + chr(0b111000)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'm\xd4\xb5'), chr(0b1100100) + chr(0b1100101) + chr(0b110110 + 0o55) + chr(111) + chr(4445 - 4345) + chr(0b1001010 + 0o33))(chr(117) + chr(0b1110100) + '\x66' + chr(0b110 + 0o47) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa3x'), chr(7241 - 7141) + chr(0b1000101 + 0o40) + chr(0b1100011) + chr(8623 - 8512) + chr(0b1100100) + chr(5591 - 5490))(chr(383 - 266) + '\164' + chr(7817 - 7715) + '\055' + chr(0b11011 + 0o35)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\x96\x9cC\xbd\x9b\xea'), chr(100) + chr(101) + '\143' + chr(111) + '\x64' + chr(0b0 + 0o145))('\165' + chr(0b1 + 0o163) + chr(0b1100110) + '\055' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), '\144' + '\145' + chr(99) + chr(111) + chr(0b1100100) + chr(4607 - 4506))('\x75' + chr(10546 - 10430) + chr(6238 - 6136) + chr(0b1010 + 0o43) + '\070'), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'm\xd4\x8d'), chr(0b1100100) + chr(0b110101 + 0o60) + chr(0b111110 + 0o45) + chr(1032 - 921) + chr(0b1010 + 0o132) + chr(8366 - 8265))(chr(0b1110101) + '\x74' + '\146' + chr(0b101101) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1z\x05'), '\x64' + chr(0b110100 + 0o61) + '\x63' + chr(0b110011 + 0o74) + '\x64' + chr(0b1100101))('\165' + chr(116) + '\x66' + chr(0b101101) + chr(0b111000)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'D\xd2'), chr(100) + '\145' + '\143' + chr(0b101101 + 0o102) + '\x64' + chr(6574 - 6473))('\x75' + chr(0b1110100) + chr(599 - 497) + chr(0b100000 + 0o15) + chr(1339 - 1283)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1'), '\x64' + chr(0b1100101) + chr(0b11010 + 0o111) + '\157' + chr(0b100001 + 0o103) + chr(0b1010110 + 0o17))(chr(0b1110101) + chr(116) + chr(5473 - 5371) + chr(45) + chr(0b111000 + 0o0)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'D\xc8'), '\144' + chr(0b1010100 + 0o21) + chr(9380 - 9281) + chr(0b1011 + 0o144) + chr(0b1001111 + 0o25) + chr(101))('\165' + '\164' + '\x66' + '\x2d' + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xf1'), chr(100) + '\x65' + chr(2206 - 2107) + chr(111) + chr(0b1100100) + '\145')(chr(0b1001011 + 0o52) + chr(0b1110100) + chr(0b111 + 0o137) + '\x2d' + chr(0b0 + 0o70)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'm\xd4\x92'), '\x64' + chr(0b1100101) + '\143' + '\x6f' + chr(100) + chr(0b1100101))(chr(1829 - 1712) + chr(116) + '\146' + chr(0b101101) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xb3'), chr(100) + chr(0b1100101) + '\x63' + chr(0b101111 + 0o100) + chr(0b1100100) + '\x65')(chr(117) + '\164' + chr(102) + chr(359 - 314) + chr(56)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'm\xd4\x91'), '\x64' + chr(0b1011010 + 0o13) + chr(3711 - 3612) + chr(0b1101111) + chr(100) + '\x65')(chr(0b1110101) + '\x74' + chr(7560 - 7458) + chr(0b101101) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xb1'), chr(0b1010110 + 0o16) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(101))(chr(0b100000 + 0o125) + chr(0b1110100) + chr(0b1100011 + 0o3) + '\x2d' + chr(0b101001 + 0o17)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\xb6\xab8\xdc\xa0.+\xfe\x8c\xca'), chr(0b1011001 + 0o13) + chr(0b1110 + 0o127) + chr(99) + chr(111) + chr(0b1001100 + 0o30) + '\145')('\x75' + chr(1573 - 1457) + chr(5730 - 5628) + chr(0b101101) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), chr(4536 - 4436) + chr(101) + chr(0b101010 + 0o71) + chr(0b1101111) + chr(100) + chr(10173 - 10072))(chr(117) + chr(0b1000 + 0o154) + '\x66' + chr(45) + chr(0b10001 + 0o47)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\xb6\xab<\xdc\xa0*+\xe1.,\xa0'), chr(0b1001011 + 0o31) + chr(0b1100101) + chr(6606 - 6507) + chr(839 - 728) + '\x64' + chr(0b1000 + 0o135))('\165' + '\164' + chr(0b1100110) + chr(82 - 37) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xad'), chr(0b100110 + 0o76) + '\x65' + '\x63' + '\x6f' + '\x64' + '\x65')(chr(0b1110101) + chr(0b1010110 + 0o36) + '\146' + '\055' + '\070'), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b"\xd4\xb6\xab\x02\xdc\xa0\x17\x0b\xcaMUO'a\x88"), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(0b1101100 + 0o3) + chr(100) + '\145')('\165' + '\x74' + chr(0b1100110) + chr(798 - 753) + chr(0b11000 + 0o40)), xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1010100 + 0o20) + '\x65' + '\x63' + chr(8121 - 8010) + chr(7386 - 7286) + '\x65')(chr(117) + '\164' + chr(0b1011100 + 0o12) + '\x2d' + chr(1873 - 1817)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\xb6\xab0\xdc\xa0&\x0b\xca\x7fu}q0]\x0b\xcd'), chr(2749 - 2649) + chr(0b1100101) + '\x63' + chr(7595 - 7484) + chr(100) + chr(0b1100101))(chr(0b1101110 + 0o7) + '\x74' + chr(0b10011 + 0o123) + chr(593 - 548) + chr(1575 - 1519)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa2'), chr(0b1010010 + 0o22) + chr(2316 - 2215) + chr(0b1011100 + 0o7) + chr(6916 - 6805) + chr(0b1001011 + 0o31) + chr(0b1100101))('\165' + '\x74' + chr(2249 - 2147) + '\055' + '\x38'), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\x97\x9bc\x86\xc27[\xa8l$\x1fg~7\x18\x14]x\xf9\x9c\xe6'), chr(0b10100 + 0o120) + chr(0b1100101) + chr(0b1000111 + 0o34) + chr(0b1101111) + chr(100) + chr(6381 - 6280))(chr(117) + '\164' + chr(0b11001 + 0o115) + '\055' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0'), '\144' + chr(0b1100101) + '\x63' + '\x6f' + '\x64' + chr(101))('\x75' + '\164' + chr(0b1100110) + chr(0b101101) + '\x38'), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\x08^\x90\x0f\x18\x87\xc4\x16\x99\xa7\xcf\xd4\xe2\x88'), chr(6622 - 6522) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(1276 - 1176) + '\x65')('\165' + chr(0b111011 + 0o71) + chr(0b1011110 + 0o10) + chr(1590 - 1545) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(100) + chr(6115 - 6014) + '\143' + chr(0b1101111) + '\144' + chr(0b1100101))(chr(117) + chr(0b1000 + 0o154) + '\x66' + chr(0b11010 + 0o23) + chr(1397 - 1341)), YfpuhF1UI1FC).strip()
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\x08^\x90\x0c\x12\x87\xc4\x16\x99\xd1\xbb\xa3\x94\x88'), chr(0b100100 + 0o100) + chr(0b1100101) + chr(7878 - 7779) + chr(111) + '\144' + chr(0b1100101))(chr(6359 - 6242) + chr(0b1110100) + chr(0b1100110) + chr(45) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b''), '\144' + chr(0b1100101) + chr(8809 - 8710) + chr(111) + '\x64' + '\145')(chr(133 - 16) + '\x74' + '\146' + '\055' + '\070'), YfpuhF1UI1FC).strip()
YfpuhF1UI1FC = YfpuhF1UI1FC.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd3:'), '\x64' + chr(2298 - 2197) + '\143' + chr(2573 - 2462) + chr(100) + '\x65')(chr(117) + '\x74' + '\146' + chr(0b101101) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0'), chr(4417 - 4317) + '\145' + chr(0b111000 + 0o53) + chr(7131 - 7020) + chr(1118 - 1018) + chr(101))(chr(117) + chr(0b100101 + 0o117) + chr(9006 - 8904) + chr(0b101101) + chr(0b10110 + 0o42)))
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b"\xd3'\x00"), '\x64' + chr(0b100110 + 0o77) + chr(0b1100011) + '\157' + '\144' + chr(8917 - 8816))(chr(0b11111 + 0o126) + chr(0b1110011 + 0o1) + chr(0b101011 + 0o73) + chr(0b100111 + 0o6) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xaf'), chr(100) + chr(0b1100101) + chr(0b1100011) + chr(1415 - 1304) + '\x64' + chr(0b1010100 + 0o21))(chr(7300 - 7183) + '\x74' + chr(102) + chr(0b100011 + 0o12) + chr(0b10101 + 0o43)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\nw\xd7c'), chr(0b1100100) + chr(6767 - 6666) + chr(0b1100011) + '\x6f' + chr(100) + chr(0b1100101))(chr(117) + '\x74' + chr(1654 - 1552) + chr(45) + chr(0b1111 + 0o51)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0'), '\144' + chr(0b1010000 + 0o25) + chr(0b1100011) + '\x6f' + chr(100) + chr(6954 - 6853))('\x75' + chr(12558 - 12442) + chr(102) + chr(0b1101 + 0o40) + chr(56)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0\x7f'), chr(100) + chr(2141 - 2040) + '\143' + chr(0b11101 + 0o122) + chr(0b1100100) + '\145')(chr(0b1010010 + 0o43) + chr(0b100000 + 0o124) + '\x66' + '\x2d' + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0'), chr(0b1100100) + '\145' + '\x63' + '\157' + chr(0b1100010 + 0o2) + chr(101))('\165' + chr(4679 - 4563) + '\146' + '\055' + chr(0b1011 + 0o55)), YfpuhF1UI1FC)
YfpuhF1UI1FC = _7u55U49WwX2.sub(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0p'), chr(2191 - 2091) + chr(2553 - 2452) + chr(99) + chr(0b100000 + 0o117) + '\144' + chr(0b1100101))('\165' + chr(116) + '\x66' + chr(0b100000 + 0o15) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b''), '\144' + chr(101) + chr(99) + chr(111) + '\x64' + chr(9806 - 9705))(chr(13430 - 13313) + chr(0b1100100 + 0o20) + '\146' + '\x2d' + chr(2581 - 2525)), YfpuhF1UI1FC)
return o8bdhk6FbmGI(xafqLlk3kkUe(YfpuhF1UI1FC, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3;\\\xc5L'), chr(2364 - 2264) + '\x65' + chr(0b11001 + 0o112) + '\x6f' + chr(0b101110 + 0o66) + '\x65')(chr(117) + chr(0b1110100) + chr(8958 - 8856) + chr(1093 - 1048) + chr(0b110000 + 0o10)))())
|
allenai/allennlp
|
allennlp/semparse/util.py
|
lisp_to_nested_expression
|
def lisp_to_nested_expression(lisp_string: str) -> List:
"""
Takes a logical form as a lisp string and returns a nested list representation of the lisp.
For example, "(count (division first))" would get mapped to ['count', ['division', 'first']].
"""
stack: List = []
current_expression: List = []
tokens = lisp_string.split()
for token in tokens:
while token[0] == '(':
nested_expression: List = []
current_expression.append(nested_expression)
stack.append(current_expression)
current_expression = nested_expression
token = token[1:]
current_expression.append(token.replace(')', ''))
while token[-1] == ')':
current_expression = stack.pop()
token = token[:-1]
return current_expression[0]
|
python
|
def lisp_to_nested_expression(lisp_string: str) -> List:
"""
Takes a logical form as a lisp string and returns a nested list representation of the lisp.
For example, "(count (division first))" would get mapped to ['count', ['division', 'first']].
"""
stack: List = []
current_expression: List = []
tokens = lisp_string.split()
for token in tokens:
while token[0] == '(':
nested_expression: List = []
current_expression.append(nested_expression)
stack.append(current_expression)
current_expression = nested_expression
token = token[1:]
current_expression.append(token.replace(')', ''))
while token[-1] == ')':
current_expression = stack.pop()
token = token[:-1]
return current_expression[0]
|
[
"def",
"lisp_to_nested_expression",
"(",
"lisp_string",
":",
"str",
")",
"->",
"List",
":",
"stack",
":",
"List",
"=",
"[",
"]",
"current_expression",
":",
"List",
"=",
"[",
"]",
"tokens",
"=",
"lisp_string",
".",
"split",
"(",
")",
"for",
"token",
"in",
"tokens",
":",
"while",
"token",
"[",
"0",
"]",
"==",
"'('",
":",
"nested_expression",
":",
"List",
"=",
"[",
"]",
"current_expression",
".",
"append",
"(",
"nested_expression",
")",
"stack",
".",
"append",
"(",
"current_expression",
")",
"current_expression",
"=",
"nested_expression",
"token",
"=",
"token",
"[",
"1",
":",
"]",
"current_expression",
".",
"append",
"(",
"token",
".",
"replace",
"(",
"')'",
",",
"''",
")",
")",
"while",
"token",
"[",
"-",
"1",
"]",
"==",
"')'",
":",
"current_expression",
"=",
"stack",
".",
"pop",
"(",
")",
"token",
"=",
"token",
"[",
":",
"-",
"1",
"]",
"return",
"current_expression",
"[",
"0",
"]"
] |
Takes a logical form as a lisp string and returns a nested list representation of the lisp.
For example, "(count (division first))" would get mapped to ['count', ['division', 'first']].
|
[
"Takes",
"a",
"logical",
"form",
"as",
"a",
"lisp",
"string",
"and",
"returns",
"a",
"nested",
"list",
"representation",
"of",
"the",
"lisp",
".",
"For",
"example",
"(",
"count",
"(",
"division",
"first",
"))",
"would",
"get",
"mapped",
"to",
"[",
"count",
"[",
"division",
"first",
"]]",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/util.py#L4-L23
|
train
|
Takes a logical form as a lisp string and returns a nested list representation of the lisp string.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,q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Error,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10000 + 0o43) + '\065' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(51) + chr(2404 - 2354), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(0b110001), 42401 - 42393), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\x30' + chr(0b100100 + 0o21), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2148 - 2098) + chr(54), 0o10), ehT0Px3KOsy9(chr(429 - 381) + chr(4988 - 4877) + chr(51) + chr(650 - 598) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(486 - 438) + chr(111) + chr(0b11010 + 0o30) + chr(0b110111) + chr(0b110101), 44123 - 44115), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + '\063' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(550 - 439) + chr(51) + chr(48) + chr(1861 - 1806), ord("\x08")), ehT0Px3KOsy9('\060' + chr(5206 - 5095) + chr(50) + chr(0b10010 + 0o43) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + '\x37' + chr(0b101110 + 0o11), 62055 - 62047), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2475 - 2424) + chr(0b111 + 0o54) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + '\062' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(1817 - 1769) + chr(111) + chr(49) + chr(1767 - 1713) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + '\x37' + chr(0b110101 + 0o1), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(10854 - 10743) + chr(0b110010) + chr(0b10111 + 0o31), 50680 - 50672), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(0b1000 + 0o55) + chr(1084 - 1036), 0o10), ehT0Px3KOsy9(chr(68 - 20) + '\157' + '\x33' + chr(559 - 510) + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10000 + 0o43) + chr(48) + chr(51), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1101 + 0o44) + chr(0b110011) + chr(1758 - 1707), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110000 + 0o1) + '\067', 0o10), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + '\x32' + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b101110 + 0o4) + chr(638 - 587) + '\x35', 0b1000), ehT0Px3KOsy9(chr(1563 - 1515) + chr(111) + chr(49) + chr(55) + '\x34', 63626 - 63618), ehT0Px3KOsy9(chr(0b110000) + chr(6761 - 6650) + chr(0b110001) + '\066' + '\063', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(55) + chr(0b101110 + 0o2), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11100 + 0o26) + '\x36' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(1762 - 1714) + '\157' + chr(0b10100 + 0o37) + chr(1988 - 1940) + '\x37', 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b100100 + 0o17) + chr(477 - 429) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + chr(168 - 118) + chr(0b110100), 0b1000), ehT0Px3KOsy9('\060' + chr(0b11110 + 0o121) + chr(0b110010) + '\061' + chr(0b11001 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(960 - 912) + chr(111) + chr(0b110101) + chr(0b110001), 58826 - 58818), ehT0Px3KOsy9('\060' + '\157' + chr(0b11100 + 0o32), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + '\064' + chr(0b110001), 29779 - 29771), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1100000 + 0o17) + chr(524 - 472), 0o10), ehT0Px3KOsy9(chr(298 - 250) + chr(111) + '\061' + '\x33' + '\x35', 23448 - 23440), ehT0Px3KOsy9('\060' + chr(10689 - 10578) + chr(0b101010 + 0o15) + chr(49), 0o10), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111) + chr(50) + chr(0b110010) + '\x35', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\067' + '\065', 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(680 - 631) + '\x31' + chr(50), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(1985 - 1874) + '\065' + chr(0b110000), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc1'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(10037 - 9926) + '\x64' + '\145')(chr(0b1011110 + 0o27) + chr(0b1001010 + 0o52) + '\146' + chr(45) + chr(0b10111 + 0o41)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Qq37JFYCn6tU(d29tHM7TMUR9) -> qRxF7OQ0y39T:
rFoCQMjVYqWa = []
SWYiyYTkcMDb = []
Sz7tXxaCGqJ1 = d29tHM7TMUR9.split()
for mTy3fac_AqJ5 in Sz7tXxaCGqJ1:
while mTy3fac_AqJ5[ehT0Px3KOsy9(chr(0b11100 + 0o24) + '\157' + chr(2012 - 1964), 0b1000)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7'), chr(100) + chr(0b1100101) + chr(8537 - 8438) + '\157' + chr(0b1100100) + '\x65')('\165' + '\164' + '\x66' + '\055' + chr(450 - 394)):
VPxpcCgBDRAf = []
xafqLlk3kkUe(SWYiyYTkcMDb, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xeay\xa0x\x83'), chr(100) + chr(0b1100101) + chr(0b1011111 + 0o4) + '\x6f' + chr(100) + chr(0b1100101))(chr(0b1010000 + 0o45) + '\x74' + '\x66' + '\x2d' + chr(0b111000)))(VPxpcCgBDRAf)
xafqLlk3kkUe(rFoCQMjVYqWa, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xeay\xa0x\x83'), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(0b11110 + 0o121) + chr(0b1100100) + chr(101))(chr(0b1110101) + '\x74' + '\x66' + chr(0b101101) + chr(56)))(SWYiyYTkcMDb)
SWYiyYTkcMDb = VPxpcCgBDRAf
mTy3fac_AqJ5 = mTy3fac_AqJ5[ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001), 0b1000):]
xafqLlk3kkUe(SWYiyYTkcMDb, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8e\xeay\xa0x\x83'), chr(0b1111 + 0o125) + chr(4231 - 4130) + chr(3225 - 3126) + chr(10292 - 10181) + '\144' + '\145')(chr(0b1000110 + 0o57) + chr(0b101011 + 0o111) + '\x66' + chr(534 - 489) + chr(0b111000)))(xafqLlk3kkUe(mTy3fac_AqJ5, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\xffy\xa9w\x84\xd8'), chr(0b1100011 + 0o1) + chr(8751 - 8650) + '\143' + '\x6f' + '\144' + chr(0b1001011 + 0o32))('\165' + chr(0b1101011 + 0o11) + chr(0b10011 + 0o123) + chr(45) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc6'), '\x64' + '\145' + chr(99) + '\157' + chr(100) + chr(0b1100101))(chr(756 - 639) + chr(0b1110100) + '\146' + '\055' + chr(2296 - 2240)), xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + chr(0b1000011 + 0o42) + '\143' + '\x6f' + chr(100) + chr(101))('\x75' + chr(990 - 874) + '\x66' + '\055' + chr(1826 - 1770))))
while mTy3fac_AqJ5[-ehT0Px3KOsy9(chr(2065 - 2017) + chr(0b1101111) + '\061', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xc6'), '\144' + '\145' + '\143' + '\157' + '\x64' + chr(101))(chr(0b1110101) + '\164' + '\x66' + chr(45) + chr(0b101001 + 0o17)):
SWYiyYTkcMDb = rFoCQMjVYqWa.pop()
mTy3fac_AqJ5 = mTy3fac_AqJ5[:-ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(6675 - 6564) + chr(2061 - 2012), 8)]
return SWYiyYTkcMDb[ehT0Px3KOsy9('\060' + '\x6f' + chr(1124 - 1076), 8)]
|
allenai/allennlp
|
allennlp/commands/elmo.py
|
ElmoEmbedder.batch_to_embeddings
|
def batch_to_embeddings(self, batch: List[List[str]]) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A tuple of tensors, the first representing activations (batch_size, 3, num_timesteps, 1024) and
the second a mask (batch_size, num_timesteps).
"""
character_ids = batch_to_ids(batch)
if self.cuda_device >= 0:
character_ids = character_ids.cuda(device=self.cuda_device)
bilm_output = self.elmo_bilm(character_ids)
layer_activations = bilm_output['activations']
mask_with_bos_eos = bilm_output['mask']
# without_bos_eos is a 3 element list of (activation, mask) tensor pairs,
# each with size (batch_size, num_timesteps, dim and (batch_size, num_timesteps)
# respectively.
without_bos_eos = [remove_sentence_boundaries(layer, mask_with_bos_eos)
for layer in layer_activations]
# Converts a list of pairs (activation, mask) tensors to a single tensor of activations.
activations = torch.cat([ele[0].unsqueeze(1) for ele in without_bos_eos], dim=1)
# The mask is the same for each ELMo vector, so just take the first.
mask = without_bos_eos[0][1]
return activations, mask
|
python
|
def batch_to_embeddings(self, batch: List[List[str]]) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A tuple of tensors, the first representing activations (batch_size, 3, num_timesteps, 1024) and
the second a mask (batch_size, num_timesteps).
"""
character_ids = batch_to_ids(batch)
if self.cuda_device >= 0:
character_ids = character_ids.cuda(device=self.cuda_device)
bilm_output = self.elmo_bilm(character_ids)
layer_activations = bilm_output['activations']
mask_with_bos_eos = bilm_output['mask']
# without_bos_eos is a 3 element list of (activation, mask) tensor pairs,
# each with size (batch_size, num_timesteps, dim and (batch_size, num_timesteps)
# respectively.
without_bos_eos = [remove_sentence_boundaries(layer, mask_with_bos_eos)
for layer in layer_activations]
# Converts a list of pairs (activation, mask) tensors to a single tensor of activations.
activations = torch.cat([ele[0].unsqueeze(1) for ele in without_bos_eos], dim=1)
# The mask is the same for each ELMo vector, so just take the first.
mask = without_bos_eos[0][1]
return activations, mask
|
[
"def",
"batch_to_embeddings",
"(",
"self",
",",
"batch",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"character_ids",
"=",
"batch_to_ids",
"(",
"batch",
")",
"if",
"self",
".",
"cuda_device",
">=",
"0",
":",
"character_ids",
"=",
"character_ids",
".",
"cuda",
"(",
"device",
"=",
"self",
".",
"cuda_device",
")",
"bilm_output",
"=",
"self",
".",
"elmo_bilm",
"(",
"character_ids",
")",
"layer_activations",
"=",
"bilm_output",
"[",
"'activations'",
"]",
"mask_with_bos_eos",
"=",
"bilm_output",
"[",
"'mask'",
"]",
"# without_bos_eos is a 3 element list of (activation, mask) tensor pairs,",
"# each with size (batch_size, num_timesteps, dim and (batch_size, num_timesteps)",
"# respectively.",
"without_bos_eos",
"=",
"[",
"remove_sentence_boundaries",
"(",
"layer",
",",
"mask_with_bos_eos",
")",
"for",
"layer",
"in",
"layer_activations",
"]",
"# Converts a list of pairs (activation, mask) tensors to a single tensor of activations.",
"activations",
"=",
"torch",
".",
"cat",
"(",
"[",
"ele",
"[",
"0",
"]",
".",
"unsqueeze",
"(",
"1",
")",
"for",
"ele",
"in",
"without_bos_eos",
"]",
",",
"dim",
"=",
"1",
")",
"# The mask is the same for each ELMo vector, so just take the first.",
"mask",
"=",
"without_bos_eos",
"[",
"0",
"]",
"[",
"1",
"]",
"return",
"activations",
",",
"mask"
] |
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A tuple of tensors, the first representing activations (batch_size, 3, num_timesteps, 1024) and
the second a mask (batch_size, num_timesteps).
|
[
"Parameters",
"----------",
"batch",
":",
"List",
"[",
"List",
"[",
"str",
"]]",
"required",
"A",
"list",
"of",
"tokenized",
"sentences",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/elmo.py#L171-L201
|
train
|
Converts a batch of sentences to an embeddings.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfb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S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(2235 - 2187) + '\x6f' + chr(0b100010 + 0o17) + chr(55) + chr(54), 0b1000), ehT0Px3KOsy9(chr(212 - 164) + '\157' + '\x33' + chr(0b11101 + 0o31) + chr(0b11000 + 0o32), 0o10), ehT0Px3KOsy9(chr(751 - 703) + '\157' + chr(0b110010) + chr(55), 0b1000), ehT0Px3KOsy9(chr(1887 - 1839) + chr(9799 - 9688) + '\063' + chr(48) + '\x31', 0b1000), ehT0Px3KOsy9(chr(1756 - 1708) + chr(0b1101111 + 0o0) + chr(0b110001) + '\x36' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\157' + chr(0b100011 + 0o20) + chr(0b1001 + 0o52) + chr(1330 - 1279), 0b1000), ehT0Px3KOsy9(chr(1593 - 1545) + chr(0b1010011 + 0o34) + chr(0b101000 + 0o11) + '\060' + chr(49), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1011001 + 0o26) + '\x31' + '\067' + '\060', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1930 - 1880) + '\x31' + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + '\067' + chr(272 - 219), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b10001 + 0o46) + chr(50), 9210 - 9202), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(52) + chr(55), 0o10), ehT0Px3KOsy9(chr(1710 - 1662) + chr(0b110000 + 0o77) + chr(0b1001 + 0o52) + '\x32' + chr(0b10011 + 0o43), 0o10), ehT0Px3KOsy9(chr(48) + chr(11910 - 11799) + '\x31' + chr(1390 - 1338) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + chr(54) + chr(50), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(49) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10010 + 0o135) + chr(1127 - 1077) + '\x34' + chr(0b1100 + 0o46), 0o10), ehT0Px3KOsy9('\x30' + chr(315 - 204) + '\062' + '\x30' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1976 - 1928) + '\157' + chr(0b10011 + 0o37) + chr(1583 - 1532) + '\063', 8910 - 8902), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x35' + chr(0b1011 + 0o47), 62200 - 62192), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(266 - 216) + chr(0b110000 + 0o5), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1241 - 1192) + chr(53), 62437 - 62429), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110111) + chr(50), 47897 - 47889), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + chr(0b110001) + chr(54), 58721 - 58713), ehT0Px3KOsy9(chr(1797 - 1749) + chr(6313 - 6202) + chr(0b110011) + '\x36' + chr(1883 - 1835), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(1940 - 1890) + chr(2451 - 2401) + chr(53), 8), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\157' + chr(653 - 603) + chr(0b110001) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + '\063' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(6663 - 6552) + chr(0b110111) + chr(0b100101 + 0o21), 0b1000), ehT0Px3KOsy9(chr(508 - 460) + '\157' + chr(1587 - 1536) + chr(0b11000 + 0o30) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100101 + 0o22) + chr(0b100011 + 0o22), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010000 + 0o37) + chr(1181 - 1131) + '\x31', 59052 - 59044), ehT0Px3KOsy9('\060' + chr(0b1100110 + 0o11) + chr(0b1101 + 0o52) + chr(1611 - 1560), 0o10), ehT0Px3KOsy9('\x30' + chr(4382 - 4271) + chr(53) + chr(50), 8), ehT0Px3KOsy9(chr(367 - 319) + chr(0b1101111) + '\x31' + chr(0b110010) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\157' + chr(50) + chr(0b110101) + '\x31', 43152 - 43144), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + '\061' + chr(0b110101) + chr(1326 - 1272), 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b110111 + 0o70) + chr(284 - 235) + chr(51) + chr(0b100010 + 0o24), 0b1000), ehT0Px3KOsy9(chr(390 - 342) + chr(0b1101111) + chr(0b10100 + 0o35) + chr(53), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(431 - 383) + '\x6f' + chr(0b110101) + '\x30', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'P'), chr(100) + chr(101) + chr(99) + chr(0b100111 + 0o110) + chr(434 - 334) + chr(101))('\165' + chr(116) + chr(924 - 822) + chr(0b11000 + 0o25) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def OURYYYIC5CxA(oVre8I6UXc3b, dNwAahu8tvoY) -> MRK8Uzg2En3D[xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'*\x97y\xb2\x1c\xa9'), '\x64' + chr(0b1100101) + chr(9709 - 9610) + chr(0b1101111) + '\x64' + '\145')('\x75' + chr(275 - 159) + '\146' + chr(737 - 692) + '\x38')), xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'*\x97y\xb2\x1c\xa9'), '\x64' + chr(7365 - 7264) + '\143' + chr(7454 - 7343) + chr(0b1011111 + 0o5) + chr(6893 - 6792))('\165' + chr(0b11111 + 0o125) + chr(9315 - 9213) + chr(0b101101) + '\x38'))]:
z3BeNs67xLNp = KBB0yWyM0_TU(dNwAahu8tvoY)
if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\x87s\xa0,\xbf$\x0e\xe4\x9e\xdf'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(0b1000111 + 0o50) + chr(0b1100100) + chr(5528 - 5427))(chr(0b1110101) + chr(0b1110100) + chr(102) + '\055' + '\x38')) >= ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101100 + 0o4), 0b1000):
z3BeNs67xLNp = z3BeNs67xLNp.cuda(device=oVre8I6UXc3b.cuda_device)
nxnHFrega4Jh = oVre8I6UXc3b.elmo_bilm(z3BeNs67xLNp)
pFsv81douvkT = nxnHFrega4Jh[xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f\x91c\xa8\x05\xba5\x11\xe2\x93\xc9'), '\x64' + chr(9051 - 8950) + chr(0b1100001 + 0o2) + chr(0b1101100 + 0o3) + chr(0b1100100) + chr(0b101011 + 0o72))(chr(117) + chr(9429 - 9313) + '\146' + chr(1764 - 1719) + chr(56))]
dZLQ7q1PiDHZ = nxnHFrega4Jh[xafqLlk3kkUe(SXOLrMavuUCe(b'\x13\x93d\xaa'), '\x64' + chr(0b1001100 + 0o31) + chr(99) + '\157' + chr(0b1010111 + 0o15) + '\145')(chr(255 - 138) + chr(116) + '\146' + chr(45) + '\x38')]
S0tHhCqEeyCi = [ooqEa__WcZPK(wgamNHppspXj, dZLQ7q1PiDHZ) for wgamNHppspXj in pFsv81douvkT]
mgDWDDVSXPyH = cEkFpYktkSeK.cat([YLt_fbniEC23[ehT0Px3KOsy9(chr(1095 - 1047) + chr(0b100011 + 0o114) + chr(48), 8)].unsqueeze(ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49), ord("\x08"))) for YLt_fbniEC23 in S0tHhCqEeyCi], dim=ehT0Px3KOsy9(chr(794 - 746) + '\157' + '\x31', 8))
Iz1jSgUKZDvt = S0tHhCqEeyCi[ehT0Px3KOsy9(chr(1089 - 1041) + chr(11396 - 11285) + chr(1180 - 1132), 8)][ehT0Px3KOsy9('\060' + '\157' + '\061', 8)]
return (mgDWDDVSXPyH, Iz1jSgUKZDvt)
|
allenai/allennlp
|
allennlp/commands/elmo.py
|
ElmoEmbedder.embed_sentence
|
def embed_sentence(self, sentence: List[str]) -> numpy.ndarray:
"""
Computes the ELMo embeddings for a single tokenized sentence.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentence : ``List[str]``, required
A tokenized sentence.
Returns
-------
A tensor containing the ELMo vectors.
"""
return self.embed_batch([sentence])[0]
|
python
|
def embed_sentence(self, sentence: List[str]) -> numpy.ndarray:
"""
Computes the ELMo embeddings for a single tokenized sentence.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentence : ``List[str]``, required
A tokenized sentence.
Returns
-------
A tensor containing the ELMo vectors.
"""
return self.embed_batch([sentence])[0]
|
[
"def",
"embed_sentence",
"(",
"self",
",",
"sentence",
":",
"List",
"[",
"str",
"]",
")",
"->",
"numpy",
".",
"ndarray",
":",
"return",
"self",
".",
"embed_batch",
"(",
"[",
"sentence",
"]",
")",
"[",
"0",
"]"
] |
Computes the ELMo embeddings for a single tokenized sentence.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentence : ``List[str]``, required
A tokenized sentence.
Returns
-------
A tensor containing the ELMo vectors.
|
[
"Computes",
"the",
"ELMo",
"embeddings",
"for",
"a",
"single",
"tokenized",
"sentence",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/elmo.py#L203-L220
|
train
|
Computes the ELMo embeddings for a single tokenized sentence.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1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,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\x6f' + chr(50) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101 + 0o142) + chr(787 - 737) + chr(0b11111 + 0o27) + chr(2309 - 2256), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(53) + chr(0b101101 + 0o12), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\157' + chr(51) + chr(0b110010) + '\067', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100011 + 0o16) + '\x32' + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\x37' + chr(0b11010 + 0o35), 52229 - 52221), ehT0Px3KOsy9('\060' + '\x6f' + chr(1931 - 1878) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1318 - 1269) + chr(0b110001) + chr(867 - 814), 19304 - 19296), ehT0Px3KOsy9('\060' + '\157' + chr(765 - 715) + chr(190 - 140) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(6760 - 6649) + chr(2394 - 2345) + chr(0b110000 + 0o4) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(0b110001) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(1658 - 1610) + chr(0b110000 + 0o77) + chr(49) + '\064' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(4344 - 4233) + '\063' + '\061' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6676 - 6565) + chr(1612 - 1563) + chr(55) + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1 + 0o156) + chr(0b110011) + '\x33' + chr(1197 - 1142), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(54) + '\x30', 0o10), ehT0Px3KOsy9('\060' + chr(5327 - 5216) + '\x33' + '\x36' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(534 - 481) + chr(0b100101 + 0o16), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(50) + chr(0b110000) + chr(0b100010 + 0o22), 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(1617 - 1567), 38343 - 38335), ehT0Px3KOsy9('\060' + '\x6f' + '\x33' + chr(0b100001 + 0o17), 37197 - 37189), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\x34' + chr(0b10010 + 0o41), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11251 - 11140) + chr(928 - 878) + chr(0b10100 + 0o43), 0b1000), ehT0Px3KOsy9(chr(48) + chr(3847 - 3736) + chr(0b110010) + chr(0b11110 + 0o24) + chr(2369 - 2317), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(0b1010 + 0o53) + chr(0b1001 + 0o47), 12595 - 12587), ehT0Px3KOsy9(chr(553 - 505) + chr(111) + chr(0b110011) + '\x37' + chr(646 - 598), 16695 - 16687), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10000 + 0o41) + '\x30' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(11417 - 11306) + chr(0b110001) + chr(0b110 + 0o57) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2227 - 2174) + chr(0b100101 + 0o13), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110010) + chr(0b110011) + chr(0b1110 + 0o50), 55962 - 55954), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\157' + chr(1285 - 1235) + chr(0b110010) + '\x32', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(718 - 669) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(1830 - 1782) + chr(8461 - 8350) + chr(51) + chr(1258 - 1208) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(2622 - 2570) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x35' + chr(0b1000 + 0o51), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b11010 + 0o32) + chr(0b101110 + 0o5), 8), ehT0Px3KOsy9(chr(1986 - 1938) + chr(0b111010 + 0o65) + chr(49) + '\061' + '\061', 49187 - 49179), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1101111) + chr(0b11011 + 0o26) + chr(0b110011) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(49) + '\061' + chr(2262 - 2207), 0b1000), ehT0Px3KOsy9(chr(1161 - 1113) + chr(4395 - 4284) + '\061' + chr(0b110001) + chr(49), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(2182 - 2134), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b';'), '\144' + '\145' + chr(99) + chr(0b101 + 0o152) + '\144' + chr(7921 - 7820))(chr(5046 - 4929) + chr(0b1100111 + 0o15) + chr(102) + chr(0b101101) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def utCynTzugLu_(oVre8I6UXc3b, pamQPTGoym5v) -> xafqLlk3kkUe(n8mpNwkrxOdz, xafqLlk3kkUe(SXOLrMavuUCe(b'{\xd1\xce\xa5"\x1eW'), chr(0b1100100) + chr(101) + '\x63' + chr(0b1101111) + chr(8246 - 8146) + chr(4688 - 4587))('\165' + '\x74' + chr(6630 - 6528) + chr(45) + '\070')):
return xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'p\xd8\xcd\xb24 L,\xe3\x02$'), chr(4360 - 4260) + chr(101) + chr(0b1110 + 0o125) + chr(0b1101111) + '\144' + chr(0b1100101))('\x75' + chr(0b1000001 + 0o63) + chr(0b1100110) + chr(0b1 + 0o54) + chr(1024 - 968)))([pamQPTGoym5v])[ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(48), 0b1000)]
|
allenai/allennlp
|
allennlp/commands/elmo.py
|
ElmoEmbedder.embed_batch
|
def embed_batch(self, batch: List[List[str]]) -> List[numpy.ndarray]:
"""
Computes the ELMo embeddings for a batch of tokenized sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
"""
elmo_embeddings = []
# Batches with only an empty sentence will throw an exception inside AllenNLP, so we handle this case
# and return an empty embedding instead.
if batch == [[]]:
elmo_embeddings.append(empty_embedding())
else:
embeddings, mask = self.batch_to_embeddings(batch)
for i in range(len(batch)):
length = int(mask[i, :].sum())
# Slicing the embedding :0 throws an exception so we need to special case for empty sentences.
if length == 0:
elmo_embeddings.append(empty_embedding())
else:
elmo_embeddings.append(embeddings[i, :, :length, :].detach().cpu().numpy())
return elmo_embeddings
|
python
|
def embed_batch(self, batch: List[List[str]]) -> List[numpy.ndarray]:
"""
Computes the ELMo embeddings for a batch of tokenized sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
"""
elmo_embeddings = []
# Batches with only an empty sentence will throw an exception inside AllenNLP, so we handle this case
# and return an empty embedding instead.
if batch == [[]]:
elmo_embeddings.append(empty_embedding())
else:
embeddings, mask = self.batch_to_embeddings(batch)
for i in range(len(batch)):
length = int(mask[i, :].sum())
# Slicing the embedding :0 throws an exception so we need to special case for empty sentences.
if length == 0:
elmo_embeddings.append(empty_embedding())
else:
elmo_embeddings.append(embeddings[i, :, :length, :].detach().cpu().numpy())
return elmo_embeddings
|
[
"def",
"embed_batch",
"(",
"self",
",",
"batch",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"List",
"[",
"numpy",
".",
"ndarray",
"]",
":",
"elmo_embeddings",
"=",
"[",
"]",
"# Batches with only an empty sentence will throw an exception inside AllenNLP, so we handle this case",
"# and return an empty embedding instead.",
"if",
"batch",
"==",
"[",
"[",
"]",
"]",
":",
"elmo_embeddings",
".",
"append",
"(",
"empty_embedding",
"(",
")",
")",
"else",
":",
"embeddings",
",",
"mask",
"=",
"self",
".",
"batch_to_embeddings",
"(",
"batch",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"batch",
")",
")",
":",
"length",
"=",
"int",
"(",
"mask",
"[",
"i",
",",
":",
"]",
".",
"sum",
"(",
")",
")",
"# Slicing the embedding :0 throws an exception so we need to special case for empty sentences.",
"if",
"length",
"==",
"0",
":",
"elmo_embeddings",
".",
"append",
"(",
"empty_embedding",
"(",
")",
")",
"else",
":",
"elmo_embeddings",
".",
"append",
"(",
"embeddings",
"[",
"i",
",",
":",
",",
":",
"length",
",",
":",
"]",
".",
"detach",
"(",
")",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
")",
"return",
"elmo_embeddings"
] |
Computes the ELMo embeddings for a batch of tokenized sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
batch : ``List[List[str]]``, required
A list of tokenized sentences.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
|
[
"Computes",
"the",
"ELMo",
"embeddings",
"for",
"a",
"batch",
"of",
"tokenized",
"sentences",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e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y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11111 + 0o22) + chr(55) + chr(0b100111 + 0o15), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(5614 - 5503) + chr(0b11 + 0o63) + '\x33', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(0b110110) + chr(0b110000 + 0o0), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b10000 + 0o137) + chr(0b110011) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1010011 + 0o34) + chr(0b100010 + 0o17) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110101 + 0o72) + '\063' + chr(1682 - 1630) + chr(0b10010 + 0o43), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101011 + 0o7) + chr(49) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(52) + chr(51), 56433 - 56425), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\065' + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1 + 0o156) + chr(50) + chr(0b110110) + chr(0b110001), 45916 - 45908), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b101100 + 0o12) + chr(0b110111), 25894 - 25886), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + '\x32' + chr(0b1000 + 0o52), 57008 - 57000), ehT0Px3KOsy9(chr(861 - 813) + chr(0b1001100 + 0o43) + '\x31' + chr(0b110000 + 0o2) + chr(0b11111 + 0o23), 8), ehT0Px3KOsy9('\060' + chr(111) + '\061' + '\x37' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11010 + 0o125) + '\061' + chr(0b110111) + chr(0b101110 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(1517 - 1469) + chr(8382 - 8271) + '\x37', 46777 - 46769), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b11101 + 0o122) + chr(0b110010) + chr(685 - 636), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x34' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + chr(5754 - 5643) + '\062' + chr(0b10110 + 0o36) + '\060', 31850 - 31842), ehT0Px3KOsy9(chr(1444 - 1396) + chr(0b1101111) + chr(2340 - 2290) + '\063' + chr(55), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10111 + 0o32) + '\065' + chr(1122 - 1070), 35530 - 35522), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(281 - 227) + chr(0b11010 + 0o32), 4040 - 4032), ehT0Px3KOsy9(chr(856 - 808) + '\x6f' + '\x31' + chr(48) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(2193 - 2082) + chr(0b110 + 0o54) + chr(55) + chr(52), 0b1000), ehT0Px3KOsy9(chr(598 - 550) + chr(0b101010 + 0o105) + chr(519 - 468) + chr(49) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11100 + 0o26) + chr(54) + chr(0b11 + 0o60), 0o10), ehT0Px3KOsy9(chr(270 - 222) + chr(0b1101111) + chr(0b1000 + 0o52) + chr(50) + '\x31', 17760 - 17752), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11100 + 0o27) + chr(0b1000 + 0o54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(7798 - 7687) + chr(0b110010) + '\061' + chr(2516 - 2465), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(2193 - 2142) + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\x31' + '\x32', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1 + 0o156) + '\x33' + '\x35' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b101110 + 0o101) + chr(0b110011) + chr(0b110110) + chr(0b100111 + 0o11), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + '\063' + chr(0b110010) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(0b110000) + chr(348 - 297), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b11101 + 0o24) + chr(54) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b10100 + 0o133) + chr(133 - 82) + chr(1720 - 1669) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + chr(0b11100 + 0o25) + chr(52) + '\x35', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2269 - 2216) + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'R'), chr(0b1010010 + 0o22) + chr(0b1100101) + '\x63' + chr(111) + '\x64' + chr(7152 - 7051))(chr(117) + chr(0b110111 + 0o75) + chr(102) + '\x2d' + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def IwEG48DMyP7C(oVre8I6UXc3b, dNwAahu8tvoY) -> qRxF7OQ0y39T[xafqLlk3kkUe(n8mpNwkrxOdz, xafqLlk3kkUe(SXOLrMavuUCe(b'\x12W\x11jy\x84\xf6'), '\x64' + '\x65' + chr(99) + chr(111) + chr(0b101 + 0o137) + chr(5909 - 5808))('\x75' + chr(0b1001010 + 0o52) + chr(0b1100110) + chr(45) + chr(0b10000 + 0o50)))]:
jHIqT3oSc3ch = []
if dNwAahu8tvoY == [[]]:
xafqLlk3kkUe(jHIqT3oSc3ch, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1dC\x00}e\x81'), chr(5021 - 4921) + chr(0b100101 + 0o100) + chr(725 - 626) + chr(111) + chr(100) + '\x65')('\165' + chr(0b101111 + 0o105) + '\x66' + '\055' + '\070'))(q16QlBHTsbi5())
else:
(vGsbpWMaAThj, Iz1jSgUKZDvt) = oVre8I6UXc3b.batch_to_embeddings(dNwAahu8tvoY)
for WVxHKyX45z_L in vQr8gNKaIaWE(c2A0yzQpDQB3(dNwAahu8tvoY)):
CHAOgk5VCHH_ = ehT0Px3KOsy9(Iz1jSgUKZDvt[WVxHKyX45z_L, :].xkxBmo49x2An())
if CHAOgk5VCHH_ == ehT0Px3KOsy9('\060' + '\157' + chr(0b110000), 8):
xafqLlk3kkUe(jHIqT3oSc3ch, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1dC\x00}e\x81'), '\144' + chr(2380 - 2279) + '\x63' + chr(1078 - 967) + chr(9225 - 9125) + '\145')('\x75' + '\164' + chr(0b110100 + 0o62) + chr(0b10110 + 0o27) + '\x38'))(q16QlBHTsbi5())
else:
xafqLlk3kkUe(jHIqT3oSc3ch, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1dC\x00}e\x81'), chr(4152 - 4052) + chr(101) + '\143' + '\157' + chr(2281 - 2181) + '\145')(chr(117) + chr(116) + chr(0b1100110) + '\055' + '\070'))(xafqLlk3kkUe(vGsbpWMaAThj[WVxHKyX45z_L, :, :CHAOgk5VCHH_, :].detach().cpu(), xafqLlk3kkUe(SXOLrMavuUCe(b'\x12F\x1dhr'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(111) + chr(6080 - 5980) + '\x65')(chr(0b1110101) + chr(7233 - 7117) + chr(0b1100110) + '\055' + chr(56)))())
return jHIqT3oSc3ch
|
allenai/allennlp
|
allennlp/commands/elmo.py
|
ElmoEmbedder.embed_sentences
|
def embed_sentences(self,
sentences: Iterable[List[str]],
batch_size: int = DEFAULT_BATCH_SIZE) -> Iterable[numpy.ndarray]:
"""
Computes the ELMo embeddings for a iterable of sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentences : ``Iterable[List[str]]``, required
An iterable of tokenized sentences.
batch_size : ``int``, required
The number of sentences ELMo should process at once.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
"""
for batch in lazy_groups_of(iter(sentences), batch_size):
yield from self.embed_batch(batch)
|
python
|
def embed_sentences(self,
sentences: Iterable[List[str]],
batch_size: int = DEFAULT_BATCH_SIZE) -> Iterable[numpy.ndarray]:
"""
Computes the ELMo embeddings for a iterable of sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentences : ``Iterable[List[str]]``, required
An iterable of tokenized sentences.
batch_size : ``int``, required
The number of sentences ELMo should process at once.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
"""
for batch in lazy_groups_of(iter(sentences), batch_size):
yield from self.embed_batch(batch)
|
[
"def",
"embed_sentences",
"(",
"self",
",",
"sentences",
":",
"Iterable",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"batch_size",
":",
"int",
"=",
"DEFAULT_BATCH_SIZE",
")",
"->",
"Iterable",
"[",
"numpy",
".",
"ndarray",
"]",
":",
"for",
"batch",
"in",
"lazy_groups_of",
"(",
"iter",
"(",
"sentences",
")",
",",
"batch_size",
")",
":",
"yield",
"from",
"self",
".",
"embed_batch",
"(",
"batch",
")"
] |
Computes the ELMo embeddings for a iterable of sentences.
Please note that ELMo has internal state and will give different results for the same input.
See the comment under the class definition.
Parameters
----------
sentences : ``Iterable[List[str]]``, required
An iterable of tokenized sentences.
batch_size : ``int``, required
The number of sentences ELMo should process at once.
Returns
-------
A list of tensors, each representing the ELMo vectors for the input sentence at the same index.
|
[
"Computes",
"the",
"ELMo",
"embeddings",
"for",
"a",
"iterable",
"of",
"sentences",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/el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Ee,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + chr(689 - 640) + chr(0b110110) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100010 + 0o20) + '\063' + '\x36', 19527 - 19519), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10000 + 0o43) + '\064' + chr(49), 49834 - 49826), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + '\x30' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(1099 - 1051) + chr(111) + chr(0b11110 + 0o24) + chr(0b110000) + chr(291 - 243), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(54) + '\x30', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001101 + 0o42) + '\x33' + chr(0b110011) + chr(307 - 255), 49945 - 49937), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10100 + 0o36) + '\063' + chr(0b101011 + 0o13), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101111 + 0o2) + chr(51) + chr(756 - 701), 0o10), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(0b1101111) + chr(50) + chr(49) + chr(0b101100 + 0o4), 33046 - 33038), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + '\067' + '\062', 0o10), ehT0Px3KOsy9('\060' + chr(9238 - 9127) + '\x37', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001) + chr(0b110010) + chr(2102 - 2052), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(11724 - 11613) + chr(0b110011) + chr(0b110100 + 0o1) + '\x35', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1010101 + 0o32) + chr(0b101100 + 0o13) + '\062', 39903 - 39895), ehT0Px3KOsy9(chr(48) + chr(5187 - 5076) + '\x32' + chr(55) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9('\060' + chr(10168 - 10057) + '\x35' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(853 - 742) + chr(667 - 618) + '\x30' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(5191 - 5080) + '\x33' + chr(2616 - 2563) + chr(246 - 196), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b11001 + 0o126) + chr(0b110101 + 0o2) + chr(207 - 153), 0o10), ehT0Px3KOsy9('\x30' + chr(130 - 19) + '\x31' + '\x32' + '\067', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110110) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b101110 + 0o5), 57879 - 57871), ehT0Px3KOsy9(chr(1548 - 1500) + '\157' + '\x31' + chr(0b110010) + chr(0b101100 + 0o13), 8), ehT0Px3KOsy9('\x30' + chr(0b1101101 + 0o2) + '\x32' + chr(543 - 493) + chr(0b10 + 0o65), 0o10), ehT0Px3KOsy9(chr(766 - 718) + chr(2108 - 1997) + chr(0b10011 + 0o40) + chr(2352 - 2298) + chr(52), 52762 - 52754), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + '\062' + chr(50) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100110 + 0o111) + chr(620 - 569) + chr(0b110000 + 0o4) + '\x36', 0o10), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b110101 + 0o72) + chr(0b110001) + chr(0b100010 + 0o17) + chr(55), 48297 - 48289), ehT0Px3KOsy9('\x30' + chr(111) + '\065' + '\x33', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b110010) + chr(0b110111), 8), ehT0Px3KOsy9('\x30' + chr(0b11111 + 0o120) + chr(0b110010) + chr(0b101010 + 0o14) + chr(54), 19518 - 19510), ehT0Px3KOsy9(chr(0b101100 + 0o4) + '\x6f' + chr(2286 - 2235) + '\x36' + chr(0b110110), 41704 - 41696), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + '\060' + chr(0b100101 + 0o20), 24298 - 24290), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b1101 + 0o46) + chr(51) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(52) + chr(1650 - 1598), 0b1000), ehT0Px3KOsy9('\060' + chr(0b100101 + 0o112) + chr(52) + chr(863 - 814), 0b1000), ehT0Px3KOsy9(chr(1422 - 1374) + chr(7702 - 7591) + '\064' + chr(2424 - 2369), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b110000 + 0o77) + '\063' + chr(0b110100) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(184 - 136) + chr(0b100101 + 0o112) + chr(0b1011 + 0o50) + '\061' + '\x33', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1704 - 1656) + chr(111) + chr(53) + chr(908 - 860), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'Z'), chr(100) + chr(0b1100101) + '\x63' + '\x6f' + chr(3971 - 3871) + chr(0b10 + 0o143))('\x75' + chr(116) + chr(0b1011000 + 0o16) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def tIxHsUpJlr1q(oVre8I6UXc3b, tqdrVw7QhW0i, ix9dZyeAmUxY=Q0NblwW6ljVC) -> U1nE7SA1iyUR[xafqLlk3kkUe(n8mpNwkrxOdz, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1a\xfa\x803\xf2\x11\xa5'), '\144' + chr(101) + chr(0b111111 + 0o44) + '\157' + chr(0b111000 + 0o54) + '\145')('\165' + chr(116) + '\x66' + chr(2004 - 1959) + chr(0b1100 + 0o54)))]:
for dNwAahu8tvoY in A7kxV2FuX2_9(ZdP978XkGspL(tqdrVw7QhW0i), ix9dZyeAmUxY):
yield from xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11\xf3\x83$\xe4/\xbe\xff+\xeb\x92'), '\144' + '\145' + chr(0b1100011) + chr(0b1011011 + 0o24) + chr(0b1000000 + 0o44) + '\145')(chr(117) + chr(0b1110100) + '\146' + '\055' + '\070'))(dNwAahu8tvoY)
|
allenai/allennlp
|
allennlp/commands/elmo.py
|
ElmoEmbedder.embed_file
|
def embed_file(self,
input_file: IO,
output_file_path: str,
output_format: str = "all",
batch_size: int = DEFAULT_BATCH_SIZE,
forget_sentences: bool = False,
use_sentence_keys: bool = False) -> None:
"""
Computes ELMo embeddings from an input_file where each line contains a sentence tokenized by whitespace.
The ELMo embeddings are written out in HDF5 format, where each sentence embedding
is saved in a dataset with the line number in the original file as the key.
Parameters
----------
input_file : ``IO``, required
A file with one tokenized sentence per line.
output_file_path : ``str``, required
A path to the output hdf5 file.
output_format : ``str``, optional, (default = "all")
The embeddings to output. Must be one of "all", "top", or "average".
batch_size : ``int``, optional, (default = 64)
The number of sentences to process in ELMo at one time.
forget_sentences : ``bool``, optional, (default = False).
If use_sentence_keys is False, whether or not to include a string
serialized JSON dictionary that associates sentences with their
line number (its HDF5 key). The mapping is placed in the
"sentence_to_index" HDF5 key. This is useful if
you want to use the embeddings without keeping the original file
of sentences around.
use_sentence_keys : ``bool``, optional, (default = False).
Whether or not to use full sentences as keys. By default,
the line numbers of the input file are used as ids, which is more robust.
"""
assert output_format in ["all", "top", "average"]
# Tokenizes the sentences.
sentences = [line.strip() for line in input_file]
blank_lines = [i for (i, line) in enumerate(sentences) if line == ""]
if blank_lines:
raise ConfigurationError(f"Your input file contains empty lines at indexes "
f"{blank_lines}. Please remove them.")
split_sentences = [sentence.split() for sentence in sentences]
# Uses the sentence index as the key.
if use_sentence_keys:
logger.warning("Using sentences as keys can fail if sentences "
"contain forward slashes or colons. Use with caution.")
embedded_sentences = zip(sentences, self.embed_sentences(split_sentences, batch_size))
else:
embedded_sentences = ((str(i), x) for i, x in
enumerate(self.embed_sentences(split_sentences, batch_size)))
sentence_to_index = {}
logger.info("Processing sentences.")
with h5py.File(output_file_path, 'w') as fout:
for key, embeddings in Tqdm.tqdm(embedded_sentences):
if use_sentence_keys and key in fout.keys():
raise ConfigurationError(f"Key already exists in {output_file_path}. "
f"To encode duplicate sentences, do not pass "
f"the --use-sentence-keys flag.")
if not forget_sentences and not use_sentence_keys:
sentence = sentences[int(key)]
sentence_to_index[sentence] = key
if output_format == "all":
output = embeddings
elif output_format == "top":
output = embeddings[-1]
elif output_format == "average":
output = numpy.average(embeddings, axis=0)
fout.create_dataset(
str(key),
output.shape, dtype='float32',
data=output
)
if not forget_sentences and not use_sentence_keys:
sentence_index_dataset = fout.create_dataset(
"sentence_to_index",
(1,),
dtype=h5py.special_dtype(vlen=str))
sentence_index_dataset[0] = json.dumps(sentence_to_index)
input_file.close()
|
python
|
def embed_file(self,
input_file: IO,
output_file_path: str,
output_format: str = "all",
batch_size: int = DEFAULT_BATCH_SIZE,
forget_sentences: bool = False,
use_sentence_keys: bool = False) -> None:
"""
Computes ELMo embeddings from an input_file where each line contains a sentence tokenized by whitespace.
The ELMo embeddings are written out in HDF5 format, where each sentence embedding
is saved in a dataset with the line number in the original file as the key.
Parameters
----------
input_file : ``IO``, required
A file with one tokenized sentence per line.
output_file_path : ``str``, required
A path to the output hdf5 file.
output_format : ``str``, optional, (default = "all")
The embeddings to output. Must be one of "all", "top", or "average".
batch_size : ``int``, optional, (default = 64)
The number of sentences to process in ELMo at one time.
forget_sentences : ``bool``, optional, (default = False).
If use_sentence_keys is False, whether or not to include a string
serialized JSON dictionary that associates sentences with their
line number (its HDF5 key). The mapping is placed in the
"sentence_to_index" HDF5 key. This is useful if
you want to use the embeddings without keeping the original file
of sentences around.
use_sentence_keys : ``bool``, optional, (default = False).
Whether or not to use full sentences as keys. By default,
the line numbers of the input file are used as ids, which is more robust.
"""
assert output_format in ["all", "top", "average"]
# Tokenizes the sentences.
sentences = [line.strip() for line in input_file]
blank_lines = [i for (i, line) in enumerate(sentences) if line == ""]
if blank_lines:
raise ConfigurationError(f"Your input file contains empty lines at indexes "
f"{blank_lines}. Please remove them.")
split_sentences = [sentence.split() for sentence in sentences]
# Uses the sentence index as the key.
if use_sentence_keys:
logger.warning("Using sentences as keys can fail if sentences "
"contain forward slashes or colons. Use with caution.")
embedded_sentences = zip(sentences, self.embed_sentences(split_sentences, batch_size))
else:
embedded_sentences = ((str(i), x) for i, x in
enumerate(self.embed_sentences(split_sentences, batch_size)))
sentence_to_index = {}
logger.info("Processing sentences.")
with h5py.File(output_file_path, 'w') as fout:
for key, embeddings in Tqdm.tqdm(embedded_sentences):
if use_sentence_keys and key in fout.keys():
raise ConfigurationError(f"Key already exists in {output_file_path}. "
f"To encode duplicate sentences, do not pass "
f"the --use-sentence-keys flag.")
if not forget_sentences and not use_sentence_keys:
sentence = sentences[int(key)]
sentence_to_index[sentence] = key
if output_format == "all":
output = embeddings
elif output_format == "top":
output = embeddings[-1]
elif output_format == "average":
output = numpy.average(embeddings, axis=0)
fout.create_dataset(
str(key),
output.shape, dtype='float32',
data=output
)
if not forget_sentences and not use_sentence_keys:
sentence_index_dataset = fout.create_dataset(
"sentence_to_index",
(1,),
dtype=h5py.special_dtype(vlen=str))
sentence_index_dataset[0] = json.dumps(sentence_to_index)
input_file.close()
|
[
"def",
"embed_file",
"(",
"self",
",",
"input_file",
":",
"IO",
",",
"output_file_path",
":",
"str",
",",
"output_format",
":",
"str",
"=",
"\"all\"",
",",
"batch_size",
":",
"int",
"=",
"DEFAULT_BATCH_SIZE",
",",
"forget_sentences",
":",
"bool",
"=",
"False",
",",
"use_sentence_keys",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"assert",
"output_format",
"in",
"[",
"\"all\"",
",",
"\"top\"",
",",
"\"average\"",
"]",
"# Tokenizes the sentences.",
"sentences",
"=",
"[",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"input_file",
"]",
"blank_lines",
"=",
"[",
"i",
"for",
"(",
"i",
",",
"line",
")",
"in",
"enumerate",
"(",
"sentences",
")",
"if",
"line",
"==",
"\"\"",
"]",
"if",
"blank_lines",
":",
"raise",
"ConfigurationError",
"(",
"f\"Your input file contains empty lines at indexes \"",
"f\"{blank_lines}. Please remove them.\"",
")",
"split_sentences",
"=",
"[",
"sentence",
".",
"split",
"(",
")",
"for",
"sentence",
"in",
"sentences",
"]",
"# Uses the sentence index as the key.",
"if",
"use_sentence_keys",
":",
"logger",
".",
"warning",
"(",
"\"Using sentences as keys can fail if sentences \"",
"\"contain forward slashes or colons. Use with caution.\"",
")",
"embedded_sentences",
"=",
"zip",
"(",
"sentences",
",",
"self",
".",
"embed_sentences",
"(",
"split_sentences",
",",
"batch_size",
")",
")",
"else",
":",
"embedded_sentences",
"=",
"(",
"(",
"str",
"(",
"i",
")",
",",
"x",
")",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"self",
".",
"embed_sentences",
"(",
"split_sentences",
",",
"batch_size",
")",
")",
")",
"sentence_to_index",
"=",
"{",
"}",
"logger",
".",
"info",
"(",
"\"Processing sentences.\"",
")",
"with",
"h5py",
".",
"File",
"(",
"output_file_path",
",",
"'w'",
")",
"as",
"fout",
":",
"for",
"key",
",",
"embeddings",
"in",
"Tqdm",
".",
"tqdm",
"(",
"embedded_sentences",
")",
":",
"if",
"use_sentence_keys",
"and",
"key",
"in",
"fout",
".",
"keys",
"(",
")",
":",
"raise",
"ConfigurationError",
"(",
"f\"Key already exists in {output_file_path}. \"",
"f\"To encode duplicate sentences, do not pass \"",
"f\"the --use-sentence-keys flag.\"",
")",
"if",
"not",
"forget_sentences",
"and",
"not",
"use_sentence_keys",
":",
"sentence",
"=",
"sentences",
"[",
"int",
"(",
"key",
")",
"]",
"sentence_to_index",
"[",
"sentence",
"]",
"=",
"key",
"if",
"output_format",
"==",
"\"all\"",
":",
"output",
"=",
"embeddings",
"elif",
"output_format",
"==",
"\"top\"",
":",
"output",
"=",
"embeddings",
"[",
"-",
"1",
"]",
"elif",
"output_format",
"==",
"\"average\"",
":",
"output",
"=",
"numpy",
".",
"average",
"(",
"embeddings",
",",
"axis",
"=",
"0",
")",
"fout",
".",
"create_dataset",
"(",
"str",
"(",
"key",
")",
",",
"output",
".",
"shape",
",",
"dtype",
"=",
"'float32'",
",",
"data",
"=",
"output",
")",
"if",
"not",
"forget_sentences",
"and",
"not",
"use_sentence_keys",
":",
"sentence_index_dataset",
"=",
"fout",
".",
"create_dataset",
"(",
"\"sentence_to_index\"",
",",
"(",
"1",
",",
")",
",",
"dtype",
"=",
"h5py",
".",
"special_dtype",
"(",
"vlen",
"=",
"str",
")",
")",
"sentence_index_dataset",
"[",
"0",
"]",
"=",
"json",
".",
"dumps",
"(",
"sentence_to_index",
")",
"input_file",
".",
"close",
"(",
")"
] |
Computes ELMo embeddings from an input_file where each line contains a sentence tokenized by whitespace.
The ELMo embeddings are written out in HDF5 format, where each sentence embedding
is saved in a dataset with the line number in the original file as the key.
Parameters
----------
input_file : ``IO``, required
A file with one tokenized sentence per line.
output_file_path : ``str``, required
A path to the output hdf5 file.
output_format : ``str``, optional, (default = "all")
The embeddings to output. Must be one of "all", "top", or "average".
batch_size : ``int``, optional, (default = 64)
The number of sentences to process in ELMo at one time.
forget_sentences : ``bool``, optional, (default = False).
If use_sentence_keys is False, whether or not to include a string
serialized JSON dictionary that associates sentences with their
line number (its HDF5 key). The mapping is placed in the
"sentence_to_index" HDF5 key. This is useful if
you want to use the embeddings without keeping the original file
of sentences around.
use_sentence_keys : ``bool``, optional, (default = False).
Whether or not to use full sentences as keys. By default,
the line numbers of the input file are used as ids, which is more robust.
|
[
"Computes",
"ELMo",
"embeddings",
"from",
"an",
"input_file",
"where",
"each",
"line",
"contains",
"a",
"sentence",
"tokenized",
"by",
"whitespace",
".",
"The",
"ELMo",
"embeddings",
"are",
"written",
"out",
"in",
"HDF5",
"format",
"where",
"each",
"sentence",
"embedding",
"is",
"saved",
"in",
"a",
"dataset",
"with",
"the",
"line",
"number",
"in",
"the",
"original",
"file",
"as",
"the",
"key",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/elmo.py#L279-L365
|
train
|
Embeds a file into a new hdf5 file.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,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Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(2337 - 2284) + '\066', 38823 - 38815), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(49) + chr(2245 - 2192) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(2881 - 2827) + chr(48), 15398 - 15390), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(0b110100) + chr(50), 0o10), ehT0Px3KOsy9(chr(1350 - 1302) + chr(111) + chr(0b100101 + 0o16) + '\063' + chr(0b11010 + 0o30), 19142 - 19134), ehT0Px3KOsy9('\x30' + chr(12010 - 11899) + '\x31' + chr(1759 - 1705) + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x31' + chr(2403 - 2353) + '\x36', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(1495 - 1384) + chr(149 - 100) + chr(0b110100) + '\x34', 25049 - 25041), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(0b1101111) + '\061' + chr(2214 - 2159) + '\066', 61377 - 61369), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1239 - 1190) + '\x32' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(4678 - 4567) + chr(2057 - 2008) + chr(48) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b0 + 0o64) + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(189 - 134) + '\x31', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b101101 + 0o5) + chr(1559 - 1505) + '\x35', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(1081 - 1029) + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101011 + 0o104) + chr(55) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(161 - 112) + chr(0b110100) + chr(0b11011 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(653 - 542) + '\x35' + '\061', 2730 - 2722), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110011) + chr(51) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + chr(128 - 73) + chr(1349 - 1300), 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(0b110100 + 0o73) + chr(0b110011) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(1495 - 1447) + chr(111) + chr(1232 - 1181) + '\061' + '\063', 34305 - 34297), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110011) + '\x32' + chr(2085 - 2031), ord("\x08")), ehT0Px3KOsy9(chr(1942 - 1894) + '\157' + chr(0b110101) + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b11100 + 0o123) + chr(0b11000 + 0o33) + '\x36' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b1010 + 0o51) + '\062', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b0 + 0o63) + chr(53) + '\060', 50123 - 50115), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100001 + 0o16) + chr(0b10010 + 0o40) + chr(0b101 + 0o60) + chr(0b11001 + 0o27), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1214 - 1165) + '\067' + '\064', 57307 - 57299), ehT0Px3KOsy9('\x30' + '\157' + chr(55) + chr(2272 - 2219), 6082 - 6074), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110000), 48963 - 48955), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(0b110100) + chr(49), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110101) + chr(0b10100 + 0o35), 8), ehT0Px3KOsy9(chr(0b10100 + 0o34) + '\157' + chr(55) + chr(240 - 191), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x32' + chr(0b11111 + 0o23) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(50) + chr(0b110000) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110011) + chr(1111 - 1058), 0b1000), ehT0Px3KOsy9(chr(1199 - 1151) + chr(0b1101111) + chr(0b1100 + 0o46) + chr(0b110000) + chr(1906 - 1855), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001100 + 0o43) + chr(0b110010) + chr(0b110100) + chr(0b1111 + 0o46), 21830 - 21822), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(111) + chr(0b110001), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110101) + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0'), '\x64' + chr(101) + '\x63' + '\x6f' + '\144' + chr(3235 - 3134))(chr(0b1110101) + chr(0b1110100) + chr(8659 - 8557) + chr(0b100011 + 0o12) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def GKlcTSa_7NTP(oVre8I6UXc3b, ZS43hVvGhK4C, XJ76KUYEmhMf, OHzcAT5vsRQV=xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f\x01\xdc'), chr(0b1000 + 0o134) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + '\x64' + chr(1337 - 1236))('\165' + chr(0b1110100) + chr(582 - 480) + chr(820 - 775) + '\x38'), ix9dZyeAmUxY=Q0NblwW6ljVC, SUSu_MseepZu=ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110000), 8), hfGNkU0_VJcL=ehT0Px3KOsy9(chr(495 - 447) + chr(111) + '\x30', 8)) -> None:
assert OHzcAT5vsRQV in [xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f\x01\xdc'), chr(1199 - 1099) + chr(101) + '\x63' + chr(0b1010 + 0o145) + '\144' + '\x65')(chr(604 - 487) + chr(9348 - 9232) + chr(102) + chr(0b101101) + chr(0b101100 + 0o14)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a\x02\xc0'), chr(0b10001 + 0o123) + chr(9936 - 9835) + chr(4553 - 4454) + '\157' + '\144' + chr(1681 - 1580))(chr(0b1110101) + chr(0b11011 + 0o131) + chr(102) + chr(0b100001 + 0o14) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f\x1b\xd5\x10\xbb\x163'), chr(0b1100100) + '\x65' + chr(0b110001 + 0o62) + '\x6f' + '\144' + chr(0b1010100 + 0o21))(chr(6349 - 6232) + '\164' + chr(0b100110 + 0o100) + '\055' + chr(3013 - 2957))]
tqdrVw7QhW0i = [LycYkDpyelF6.strip() for LycYkDpyelF6 in ZS43hVvGhK4C]
E49hwp6r7ZJv = [WVxHKyX45z_L for (WVxHKyX45z_L, LycYkDpyelF6) in YlkZvXL8qwsX(tqdrVw7QhW0i) if LycYkDpyelF6 == xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(3709 - 3609) + chr(101) + chr(5950 - 5851) + '\x6f' + chr(0b110111 + 0o55) + chr(4022 - 3921))(chr(0b1110101) + chr(0b1110100) + chr(0b1100110) + '\x2d' + '\x38')]
if E49hwp6r7ZJv:
raise h0iXqtiKVeKg(f'Your input file contains empty lines at indexes {E49hwp6r7ZJv}. Please remove them.')
fARvahc52zzh = [pamQPTGoym5v.split() for pamQPTGoym5v in tqdrVw7QhW0i]
if hfGNkU0_VJcL:
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x99\x0c\xc2\x0c\xb3\x1f1'), '\x64' + chr(101) + chr(0b1100011) + chr(0b101010 + 0o105) + '\144' + '\x65')(chr(0b1110101) + chr(9968 - 9852) + '\x66' + chr(0b101101) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xbb\x1e\xd9\x0c\xbdQ%\x01\x10 I\x9a\xd0\xd3\x1b\x00Z\xfc\xd2y\xb2\xa5\x08\x93{\x86\x88\x1a\\i\r\tP\xf7\xa1n\xe6\xcbu\x8b\x03\xd3\x07\xa9Q5\x0b\x10 $N\x97\x95\xc6T\x13^\xbd\xcbx\xeb\xa5D\x91i\x80\xcd\x0f\x1do\x13\tZ\xfe\xedr\xed\xd6/\xce8\xc3\x07\xfa\x06?\x10\x16t&F\x8c\xc1\xc9T\x0f\x07'), chr(0b11 + 0o141) + '\x65' + '\x63' + '\x6f' + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(12246 - 12130) + chr(0b1100110) + '\055' + chr(56)))
mtu5Hhb02iMn = pZ0NK2y6HRbn(tqdrVw7QhW0i, oVre8I6UXc3b.embed_sentences(fARvahc52zzh, ix9dZyeAmUxY))
else:
mtu5Hhb02iMn = ((M8_cKLkHVB2V(WVxHKyX45z_L), OeWW0F1dBPRQ) for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(oVre8I6UXc3b.embed_sentences(fARvahc52zzh, ix9dZyeAmUxY)))
I2hqQOLHkcCj = {}
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xbdZ\xf8\x1a\xaf\x121S\x148\x1fL'), '\x64' + chr(0b1100101) + '\143' + chr(0b1010101 + 0o32) + chr(5972 - 5872) + '\x65')(chr(2317 - 2200) + '\164' + '\146' + '\x2d' + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xbe\x1f\xdf\x01\xbf\x02%\r\x103eT\x9c\xdb\xd4^\x0fJ\xb9\xca2'), chr(0b1110 + 0o126) + '\x65' + '\143' + '\157' + chr(0b1100100) + '\x65')(chr(0b111011 + 0o72) + chr(12689 - 12573) + chr(8630 - 8528) + chr(0b101101) + chr(0b1000 + 0o60)))
with xafqLlk3kkUe(aKlwkq0m2IdK, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8\x04\xdc\x07'), '\144' + chr(0b1100101) + chr(1347 - 1248) + chr(0b1101111) + '\x64' + '\x65')(chr(0b110110 + 0o77) + chr(4749 - 4633) + chr(102) + chr(0b101101) + '\x38'))(XJ76KUYEmhMf, xafqLlk3kkUe(SXOLrMavuUCe(b'\x99'), '\x64' + chr(101) + '\x63' + '\157' + chr(0b1010110 + 0o16) + '\x65')(chr(0b1110101) + chr(0b1001110 + 0o46) + '\146' + '\x2d' + '\x38')) as jd8s7Uh8ek48:
for (K3J4ZwSlE0sT, vGsbpWMaAThj) in xafqLlk3kkUe(l5DR0A5LiDJi, xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a\x1c\xd4\x0f'), '\144' + '\145' + '\x63' + '\157' + chr(5427 - 5327) + chr(7377 - 7276))('\x75' + chr(0b1100100 + 0o20) + chr(1085 - 983) + chr(0b11000 + 0o25) + chr(56)))(mtu5Hhb02iMn):
if hfGNkU0_VJcL and K3J4ZwSlE0sT in xafqLlk3kkUe(jd8s7Uh8ek48, xafqLlk3kkUe(SXOLrMavuUCe(b'\x85\x08\xc9\x11'), chr(0b1100100) + chr(9943 - 9842) + '\143' + chr(0b1101111) + chr(0b1000110 + 0o36) + '\145')(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(2011 - 1966) + '\070'))():
raise h0iXqtiKVeKg(f'Key already exists in {XJ76KUYEmhMf}. To encode duplicate sentences, do not pass the --use-sentence-keys flag.')
if not SUSu_MseepZu and (not hfGNkU0_VJcL):
pamQPTGoym5v = tqdrVw7QhW0i[ehT0Px3KOsy9(K3J4ZwSlE0sT)]
I2hqQOLHkcCj[pamQPTGoym5v] = K3J4ZwSlE0sT
if OHzcAT5vsRQV == xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f\x01\xdc'), '\x64' + '\x65' + '\143' + '\157' + chr(0b1100100) + chr(6768 - 6667))(chr(117) + chr(0b1110100) + '\146' + chr(45) + chr(56)):
e1jVqMSBZ01Y = vGsbpWMaAThj
elif OHzcAT5vsRQV == xafqLlk3kkUe(SXOLrMavuUCe(b'\x9a\x02\xc0'), chr(0b1100100) + chr(2765 - 2664) + '\143' + chr(0b1100111 + 0o10) + chr(4558 - 4458) + chr(0b101000 + 0o75))('\165' + chr(0b1110100) + chr(102) + chr(0b11001 + 0o24) + chr(56)):
e1jVqMSBZ01Y = vGsbpWMaAThj[-ehT0Px3KOsy9('\x30' + '\157' + '\061', 8)]
elif OHzcAT5vsRQV == xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f\x1b\xd5\x10\xbb\x163'), chr(100) + '\x65' + '\x63' + '\157' + chr(6108 - 6008) + chr(0b101101 + 0o70))('\165' + '\164' + chr(0b101011 + 0o73) + '\x2d' + '\070'):
e1jVqMSBZ01Y = n8mpNwkrxOdz.average(vGsbpWMaAThj, axis=ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100000 + 0o20), 8))
xafqLlk3kkUe(jd8s7Uh8ek48, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8d\x1f\xd5\x03\xae\x14\t\x00\x1f $T\x9c\xc1'), '\144' + chr(101) + chr(99) + chr(0b1101111) + '\144' + '\145')(chr(117) + chr(116) + chr(1627 - 1525) + '\055' + chr(0b111000)))(M8_cKLkHVB2V(K3J4ZwSlE0sT), xafqLlk3kkUe(e1jVqMSBZ01Y, xafqLlk3kkUe(SXOLrMavuUCe(b'\x80\x0c\xc5;\xbc=1\x08*$&E'), chr(0b101011 + 0o71) + chr(8112 - 8011) + '\143' + chr(0b1101111) + chr(4842 - 4742) + chr(4922 - 4821))(chr(0b100 + 0o161) + chr(3115 - 2999) + '\146' + chr(0b1001 + 0o44) + '\x38')), dtype=xafqLlk3kkUe(SXOLrMavuUCe(b'\x88\x01\xdf\x03\xaeBd'), '\144' + '\145' + chr(0b1100011) + chr(0b1101000 + 0o7) + chr(0b1100100) + '\145')(chr(0b1110101) + '\x74' + chr(8597 - 8495) + chr(45) + chr(56)), data=e1jVqMSBZ01Y)
if not SUSu_MseepZu and (not hfGNkU0_VJcL):
OgYqGxobnfLo = jd8s7Uh8ek48.create_dataset(xafqLlk3kkUe(SXOLrMavuUCe(b'\x9d\x08\xde\x16\xbf\x1f5\x01! *x\x90\xdb\xc4^\x19'), chr(2005 - 1905) + chr(101) + chr(1527 - 1428) + '\x6f' + chr(100) + chr(8965 - 8864))(chr(117) + '\164' + '\146' + '\x2d' + chr(56)), (ehT0Px3KOsy9(chr(1024 - 976) + chr(0b1101111) + chr(0b100000 + 0o21), 8),), dtype=aKlwkq0m2IdK.special_dtype(vlen=M8_cKLkHVB2V))
OgYqGxobnfLo[ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b100 + 0o54), 8)] = fXk443epxtd5.dumps(I2hqQOLHkcCj)
xafqLlk3kkUe(ZS43hVvGhK4C, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8d\x01\xdf\x11\xbf'), chr(0b1100100) + chr(0b1100101) + chr(7853 - 7754) + '\157' + chr(100) + '\145')(chr(0b10010 + 0o143) + chr(0b111000 + 0o74) + chr(102) + chr(0b1010 + 0o43) + chr(56)))()
|
allenai/allennlp
|
allennlp/data/instance.py
|
Instance.add_field
|
def add_field(self, field_name: str, field: Field, vocab: Vocabulary = None) -> None:
"""
Add the field to the existing fields mapping.
If we have already indexed the Instance, then we also index `field`, so
it is necessary to supply the vocab.
"""
self.fields[field_name] = field
if self.indexed:
field.index(vocab)
|
python
|
def add_field(self, field_name: str, field: Field, vocab: Vocabulary = None) -> None:
"""
Add the field to the existing fields mapping.
If we have already indexed the Instance, then we also index `field`, so
it is necessary to supply the vocab.
"""
self.fields[field_name] = field
if self.indexed:
field.index(vocab)
|
[
"def",
"add_field",
"(",
"self",
",",
"field_name",
":",
"str",
",",
"field",
":",
"Field",
",",
"vocab",
":",
"Vocabulary",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"fields",
"[",
"field_name",
"]",
"=",
"field",
"if",
"self",
".",
"indexed",
":",
"field",
".",
"index",
"(",
"vocab",
")"
] |
Add the field to the existing fields mapping.
If we have already indexed the Instance, then we also index `field`, so
it is necessary to supply the vocab.
|
[
"Add",
"the",
"field",
"to",
"the",
"existing",
"fields",
"mapping",
".",
"If",
"we",
"have",
"already",
"indexed",
"the",
"Instance",
"then",
"we",
"also",
"index",
"field",
"so",
"it",
"is",
"necessary",
"to",
"supply",
"the",
"vocab",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L41-L49
|
train
|
Add the field to the existing fields mapping.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ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_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + chr(2313 - 2263) + chr(0b110100) + '\x31', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(1124 - 1070) + chr(48), 35794 - 35786), ehT0Px3KOsy9(chr(1594 - 1546) + '\x6f' + chr(54) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101110 + 0o1) + chr(686 - 635) + chr(1844 - 1792) + '\061', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(0b110010) + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1001 + 0o146) + chr(51) + '\066' + '\x31', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(11969 - 11858) + chr(2659 - 2607) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\062' + chr(1773 - 1725) + chr(0b11111 + 0o23), 18661 - 18653), ehT0Px3KOsy9(chr(1055 - 1007) + chr(3463 - 3352) + chr(0b110011) + '\062' + chr(48), 8), ehT0Px3KOsy9(chr(48) + chr(11617 - 11506) + '\x35' + '\065', 0b1000), ehT0Px3KOsy9('\060' + chr(0b10110 + 0o131) + '\062' + '\062' + chr(1872 - 1818), 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(0b110001) + '\x33' + '\062', 44528 - 44520), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(3420 - 3309) + '\061' + '\x37' + '\062', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + '\x33' + chr(1809 - 1759), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1641 - 1591) + '\062' + '\x37', 5281 - 5273), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(0b110101) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(2469 - 2358) + '\x33' + chr(0b100011 + 0o15) + chr(54), 0b1000), ehT0Px3KOsy9(chr(949 - 901) + chr(111) + chr(0b11101 + 0o24) + '\x30' + chr(1227 - 1175), ord("\x08")), ehT0Px3KOsy9(chr(1151 - 1103) + chr(0b11000 + 0o127) + chr(0b110011) + chr(0b110010) + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(50) + chr(0b110000) + '\x32', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x32' + '\066' + chr(48), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1958 - 1908) + chr(0b101011 + 0o13) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(53) + '\065', 49101 - 49093), ehT0Px3KOsy9(chr(0b110000) + chr(2005 - 1894) + chr(0b1000 + 0o56) + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11219 - 11108) + '\x31' + '\x30' + chr(0b110000), 14061 - 14053), ehT0Px3KOsy9('\060' + chr(111) + '\062' + '\060', 57920 - 57912), ehT0Px3KOsy9(chr(2147 - 2099) + '\157' + chr(905 - 853) + chr(601 - 547), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\067' + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1100111 + 0o10) + chr(0b110001) + chr(0b110010) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(10600 - 10489) + '\x32' + chr(0b11100 + 0o30) + '\x34', 0o10), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\157' + '\061' + '\067' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + '\065' + '\x33', 52692 - 52684), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(0b110000) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110110) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4770 - 4659) + '\065' + '\x34', 0o10), ehT0Px3KOsy9(chr(1832 - 1784) + '\x6f' + chr(51) + chr(2095 - 2041) + chr(2116 - 2065), 19061 - 19053), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101101 + 0o4) + '\x35' + chr(0b1010 + 0o52), 65158 - 65150), ehT0Px3KOsy9(chr(48) + chr(0b111110 + 0o61) + chr(2387 - 2338) + chr(0b110000 + 0o0) + chr(0b11101 + 0o24), 0o10), ehT0Px3KOsy9(chr(263 - 215) + '\157' + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(818 - 769) + chr(2186 - 2131) + chr(2727 - 2672), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1787 - 1739) + '\x6f' + '\x35' + chr(1831 - 1783), 61284 - 61276)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8f'), '\x64' + '\x65' + '\x63' + '\x6f' + chr(0b1000111 + 0o35) + chr(101))(chr(0b1110101) + '\164' + chr(445 - 343) + chr(45) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def pENpWC8kBddP(oVre8I6UXc3b, eLFXQGzYXo5B, fEcfxx4smAdS, mSU6gEqYPk2T=None) -> None:
oVre8I6UXc3b._yavFU6VJ0wY[eLFXQGzYXo5B] = fEcfxx4smAdS
if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc8\xdeS\x84\xa8\x94E'), '\144' + '\x65' + chr(99) + chr(0b1011001 + 0o26) + '\x64' + chr(0b1101 + 0o130))(chr(117) + chr(0b1100 + 0o150) + chr(0b1010100 + 0o22) + chr(784 - 739) + '\x38')):
xafqLlk3kkUe(fEcfxx4smAdS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf9\xd4X\x96\x82\x93k\xc9\x8az\xdac'), '\x64' + chr(0b110110 + 0o57) + '\x63' + chr(2249 - 2138) + chr(4385 - 4285) + chr(0b1001001 + 0o34))('\x75' + '\x74' + '\146' + chr(45) + chr(1485 - 1429)))(mSU6gEqYPk2T)
|
allenai/allennlp
|
allennlp/data/instance.py
|
Instance.count_vocab_items
|
def count_vocab_items(self, counter: Dict[str, Dict[str, int]]):
"""
Increments counts in the given ``counter`` for all of the vocabulary items in all of the
``Fields`` in this ``Instance``.
"""
for field in self.fields.values():
field.count_vocab_items(counter)
|
python
|
def count_vocab_items(self, counter: Dict[str, Dict[str, int]]):
"""
Increments counts in the given ``counter`` for all of the vocabulary items in all of the
``Fields`` in this ``Instance``.
"""
for field in self.fields.values():
field.count_vocab_items(counter)
|
[
"def",
"count_vocab_items",
"(",
"self",
",",
"counter",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
")",
":",
"for",
"field",
"in",
"self",
".",
"fields",
".",
"values",
"(",
")",
":",
"field",
".",
"count_vocab_items",
"(",
"counter",
")"
] |
Increments counts in the given ``counter`` for all of the vocabulary items in all of the
``Fields`` in this ``Instance``.
|
[
"Increments",
"counts",
"in",
"the",
"given",
"counter",
"for",
"all",
"of",
"the",
"vocabulary",
"items",
"in",
"all",
"of",
"the",
"Fields",
"in",
"this",
"Instance",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L51-L57
|
train
|
Increments counts in the given counter for all of the vocabul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0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(0b1101111 + 0o0) + chr(0b110010) + chr(0b110100) + chr(0b100000 + 0o24), 0o10), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b1011100 + 0o23) + chr(51) + '\x33' + chr(49), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(1005 - 954) + chr(0b110001), 37166 - 37158), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2220 - 2169) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(0b11101 + 0o26) + chr(0b11011 + 0o30) + chr(1917 - 1865), 19091 - 19083), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(0b1101111) + chr(51) + chr(0b100101 + 0o15), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1001 + 0o54) + chr(0b10 + 0o57), ord("\x08")), ehT0Px3KOsy9(chr(1827 - 1779) + chr(0b101000 + 0o107) + chr(0b110001) + chr(0b100000 + 0o27) + chr(0b100111 + 0o11), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(55) + chr(1887 - 1834), ord("\x08")), ehT0Px3KOsy9(chr(346 - 298) + '\157' + chr(0b1000 + 0o52) + chr(52) + '\x36', 0b1000), ehT0Px3KOsy9(chr(2153 - 2105) + '\x6f' + chr(1288 - 1234), 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(11651 - 11540) + '\x33' + '\x31' + chr(52), 15273 - 15265), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + chr(0b110001) + chr(0b100110 + 0o20), 64869 - 64861), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100101 + 0o15) + chr(126 - 73) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10011 + 0o37) + chr(50) + '\065', 38827 - 38819), ehT0Px3KOsy9(chr(1893 - 1845) + '\x6f' + '\x33' + chr(51) + chr(0b100011 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(946 - 898) + chr(7150 - 7039) + '\061' + chr(0b110001) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(49) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(0b11011 + 0o25) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(4595 - 4484) + '\x33' + chr(1350 - 1299) + chr(596 - 546), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(49) + chr(49) + chr(0b10010 + 0o42), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + '\x34' + chr(1842 - 1790), 906 - 898), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(0b10 + 0o155) + chr(51) + chr(50) + chr(888 - 835), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\067' + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(3274 - 3163) + '\063' + '\x32' + chr(0b110101), 8), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\x6f' + chr(0b11001 + 0o31) + '\060' + chr(0b110001), 8), ehT0Px3KOsy9('\x30' + chr(0b1 + 0o156) + '\x32' + '\x34' + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(10113 - 10002) + '\061' + chr(0b1001 + 0o53) + chr(0b11101 + 0o23), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(2175 - 2126) + chr(1706 - 1654) + '\x34', 8), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(111) + '\x31' + '\065' + chr(2681 - 2628), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(0b1101111) + chr(49) + chr(0b11101 + 0o31) + chr(0b110010), 38098 - 38090), ehT0Px3KOsy9('\060' + chr(10444 - 10333) + chr(0b1100 + 0o45) + '\063' + '\x31', 38419 - 38411), ehT0Px3KOsy9(chr(0b110000) + chr(236 - 125) + chr(0b0 + 0o62) + chr(782 - 728) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11 + 0o56) + chr(49) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(1101 - 1047) + '\063', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11010 + 0o31) + chr(2141 - 2091) + chr(1673 - 1624), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b100011 + 0o17) + '\x30' + chr(1420 - 1370), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\062' + '\065' + chr(0b1111 + 0o42), 4570 - 4562), ehT0Px3KOsy9(chr(244 - 196) + chr(11238 - 11127) + chr(49) + chr(0b110110) + chr(1495 - 1442), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1700 - 1647) + '\x30', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8a'), '\x64' + '\145' + chr(0b1001010 + 0o31) + chr(6687 - 6576) + chr(0b1100100) + '\x65')('\x75' + chr(0b1110100) + chr(102) + '\x2d' + chr(2516 - 2460)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def NlxqfEifGvWu(oVre8I6UXc3b, pD5Ye7vZLivj):
for fEcfxx4smAdS in xafqLlk3kkUe(oVre8I6UXc3b.fields, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7\x89w]\x92o\x1cLu\x97b\xae'), chr(0b100101 + 0o77) + '\x65' + chr(99) + '\x6f' + chr(0b100001 + 0o103) + chr(0b1000011 + 0o42))(chr(4985 - 4868) + chr(0b1110100) + '\x66' + chr(0b1000 + 0o45) + chr(0b1001 + 0o57)))():
xafqLlk3kkUe(fEcfxx4smAdS, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7\xb6lp\xa8E_\x17^\xc7d\x93\xa7\xdb\xf0\xb7?'), chr(0b111100 + 0o50) + '\x65' + chr(1530 - 1431) + '\x6f' + '\144' + '\145')(chr(0b1110101) + '\x74' + '\146' + chr(0b11111 + 0o16) + chr(56)))(pD5Ye7vZLivj)
|
allenai/allennlp
|
allennlp/data/instance.py
|
Instance.index_fields
|
def index_fields(self, vocab: Vocabulary) -> None:
"""
Indexes all fields in this ``Instance`` using the provided ``Vocabulary``.
This `mutates` the current object, it does not return a new ``Instance``.
A ``DataIterator`` will call this on each pass through a dataset; we use the ``indexed``
flag to make sure that indexing only happens once.
This means that if for some reason you modify your vocabulary after you've
indexed your instances, you might get unexpected behavior.
"""
if not self.indexed:
self.indexed = True
for field in self.fields.values():
field.index(vocab)
|
python
|
def index_fields(self, vocab: Vocabulary) -> None:
"""
Indexes all fields in this ``Instance`` using the provided ``Vocabulary``.
This `mutates` the current object, it does not return a new ``Instance``.
A ``DataIterator`` will call this on each pass through a dataset; we use the ``indexed``
flag to make sure that indexing only happens once.
This means that if for some reason you modify your vocabulary after you've
indexed your instances, you might get unexpected behavior.
"""
if not self.indexed:
self.indexed = True
for field in self.fields.values():
field.index(vocab)
|
[
"def",
"index_fields",
"(",
"self",
",",
"vocab",
":",
"Vocabulary",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"indexed",
":",
"self",
".",
"indexed",
"=",
"True",
"for",
"field",
"in",
"self",
".",
"fields",
".",
"values",
"(",
")",
":",
"field",
".",
"index",
"(",
"vocab",
")"
] |
Indexes all fields in this ``Instance`` using the provided ``Vocabulary``.
This `mutates` the current object, it does not return a new ``Instance``.
A ``DataIterator`` will call this on each pass through a dataset; we use the ``indexed``
flag to make sure that indexing only happens once.
This means that if for some reason you modify your vocabulary after you've
indexed your instances, you might get unexpected behavior.
|
[
"Indexes",
"all",
"fields",
"in",
"this",
"Instance",
"using",
"the",
"provided",
"Vocabulary",
".",
"This",
"mutates",
"the",
"current",
"object",
"it",
"does",
"not",
"return",
"a",
"new",
"Instance",
".",
"A",
"DataIterator",
"will",
"call",
"this",
"on",
"each",
"pass",
"through",
"a",
"dataset",
";",
"we",
"use",
"the",
"indexed",
"flag",
"to",
"make",
"sure",
"that",
"indexing",
"only",
"happens",
"once",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L59-L72
|
train
|
Indexes all fields in this instance using the provided vocabulary.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bik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aIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1631 - 1583) + chr(10096 - 9985) + '\062' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(0b1101111) + chr(0b110011) + '\x37' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1 + 0o62) + chr(0b110001) + chr(1894 - 1840), 3631 - 3623), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(0b101100 + 0o4) + chr(0b1 + 0o65), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(1881 - 1832) + chr(0b110011) + '\x36', 32411 - 32403), ehT0Px3KOsy9(chr(1881 - 1833) + '\x6f' + chr(0b110101) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(840 - 792) + chr(111) + '\062' + chr(0b110101) + '\065', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\067', 5251 - 5243), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1000110 + 0o51) + chr(50) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + chr(11170 - 11059) + chr(1681 - 1630) + chr(0b110010) + '\060', 0o10), ehT0Px3KOsy9(chr(1412 - 1364) + chr(0b101011 + 0o104) + chr(1436 - 1385) + chr(0b110100) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(0b110110 + 0o71) + chr(0b110010) + chr(838 - 783) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\065' + chr(50), 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110010) + chr(0b110011) + chr(1391 - 1339), 56366 - 56358), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + '\063' + '\x34', 59469 - 59461), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\157' + '\061' + chr(1951 - 1900) + chr(53), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2245 - 2196) + '\062' + chr(0b100011 + 0o17), 6885 - 6877), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(0b100011 + 0o22) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11110 + 0o23) + chr(1000 - 947) + chr(0b101100 + 0o13), 22122 - 22114), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100101 + 0o15) + chr(0b110111) + chr(1057 - 1007), 0o10), ehT0Px3KOsy9(chr(327 - 279) + chr(0b11100 + 0o123) + '\063' + '\x35' + chr(1431 - 1382), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101010 + 0o5) + chr(50) + '\064' + '\065', 6050 - 6042), ehT0Px3KOsy9('\x30' + chr(0b1011111 + 0o20) + chr(0b110011) + '\062' + chr(0b110111), 38958 - 38950), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + '\062' + chr(1498 - 1450) + chr(2438 - 2388), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1111 + 0o140) + chr(0b110001) + '\066' + '\063', 7375 - 7367), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(0b1101111) + chr(2955 - 2900), 8), ehT0Px3KOsy9(chr(48) + chr(0b1000001 + 0o56) + '\062' + '\x31' + '\x34', 53649 - 53641), ehT0Px3KOsy9(chr(1780 - 1732) + '\157' + '\x32' + chr(0b110101) + chr(0b110101), 8), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(956 - 901) + chr(48), 60701 - 60693), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(0b1001 + 0o146) + chr(50) + '\x37' + '\x36', 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110011) + '\x31' + chr(0b110101 + 0o0), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10010 + 0o135) + chr(0b1111 + 0o42) + chr(367 - 313) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b10101 + 0o34) + chr(0b100010 + 0o22) + '\061', 0o10), ehT0Px3KOsy9(chr(0b100010 + 0o16) + chr(8429 - 8318) + '\061' + '\x33' + chr(1557 - 1505), 8), ehT0Px3KOsy9(chr(0b10010 + 0o36) + '\157' + chr(49) + chr(0b100110 + 0o14) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(111) + chr(0b110101) + chr(0b1001 + 0o54), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11110 + 0o31) + chr(2309 - 2259), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + chr(0b110111 + 0o0) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(1035 - 985) + chr(53) + chr(0b101010 + 0o7), 64424 - 64416), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b110011), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(111) + '\x35' + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'='), chr(3529 - 3429) + '\x65' + chr(0b1010101 + 0o16) + '\x6f' + chr(0b101101 + 0o67) + '\x65')(chr(13266 - 13149) + chr(116) + chr(102) + '\x2d' + chr(0b1010 + 0o56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def tsmnFHZJNNf9(oVre8I6UXc3b, mSU6gEqYPk2T) -> None:
if not xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'z\x94\xaa\xa3&O\xc9'), chr(100) + '\145' + chr(0b1100011) + chr(2758 - 2647) + '\144' + chr(0b1100101))(chr(117) + '\x74' + chr(0b1100110) + chr(0b101011 + 0o2) + chr(0b101010 + 0o16))):
oVre8I6UXc3b.UUC4A3NP3xD_ = ehT0Px3KOsy9(chr(0b110000) + chr(0b100110 + 0o111) + chr(0b0 + 0o61), 892 - 884)
for fEcfxx4smAdS in xafqLlk3kkUe(oVre8I6UXc3b.fields, xafqLlk3kkUe(SXOLrMavuUCe(b'@\xaa\xa0\x85\x10_\x983]\xe1\x81\xdc'), '\144' + '\145' + chr(0b1100011) + chr(5841 - 5730) + chr(0b111001 + 0o53) + chr(1796 - 1695))('\165' + chr(0b1111 + 0o145) + chr(0b10110 + 0o120) + chr(0b10101 + 0o30) + '\x38'))():
xafqLlk3kkUe(fEcfxx4smAdS, xafqLlk3kkUe(SXOLrMavuUCe(b'K\x9e\xa1\xb1\x0cH\xe7LO\x87\xa9\x87'), chr(100) + chr(101) + chr(8637 - 8538) + chr(111) + chr(0b1100100) + '\x65')('\x75' + chr(0b1110100) + chr(102) + chr(0b1010 + 0o43) + chr(671 - 615)))(mSU6gEqYPk2T)
|
allenai/allennlp
|
allennlp/data/instance.py
|
Instance.get_padding_lengths
|
def get_padding_lengths(self) -> Dict[str, Dict[str, int]]:
"""
Returns a dictionary of padding lengths, keyed by field name. Each ``Field`` returns a
mapping from padding keys to actual lengths, and we just key that dictionary by field name.
"""
lengths = {}
for field_name, field in self.fields.items():
lengths[field_name] = field.get_padding_lengths()
return lengths
|
python
|
def get_padding_lengths(self) -> Dict[str, Dict[str, int]]:
"""
Returns a dictionary of padding lengths, keyed by field name. Each ``Field`` returns a
mapping from padding keys to actual lengths, and we just key that dictionary by field name.
"""
lengths = {}
for field_name, field in self.fields.items():
lengths[field_name] = field.get_padding_lengths()
return lengths
|
[
"def",
"get_padding_lengths",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
":",
"lengths",
"=",
"{",
"}",
"for",
"field_name",
",",
"field",
"in",
"self",
".",
"fields",
".",
"items",
"(",
")",
":",
"lengths",
"[",
"field_name",
"]",
"=",
"field",
".",
"get_padding_lengths",
"(",
")",
"return",
"lengths"
] |
Returns a dictionary of padding lengths, keyed by field name. Each ``Field`` returns a
mapping from padding keys to actual lengths, and we just key that dictionary by field name.
|
[
"Returns",
"a",
"dictionary",
"of",
"padding",
"lengths",
"keyed",
"by",
"field",
"name",
".",
"Each",
"Field",
"returns",
"a",
"mapping",
"from",
"padding",
"keys",
"to",
"actual",
"lengths",
"and",
"we",
"just",
"key",
"that",
"dictionary",
"by",
"field",
"name",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L74-L82
|
train
|
Returns a dictionary of padding lengths keyed by field name.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OT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4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(4397 - 4286) + '\062' + '\065' + chr(0b1000 + 0o55), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x32' + chr(0b101001 + 0o13) + chr(0b101011 + 0o5), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(2306 - 2254) + '\x30', 29205 - 29197), ehT0Px3KOsy9(chr(48) + chr(0b1010111 + 0o30) + chr(49) + '\x33' + chr(0b110001), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b100101 + 0o14) + '\x33' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(2272 - 2224) + chr(0b1101111) + chr(51) + '\066' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(1447 - 1399) + chr(111) + chr(0b110001) + chr(0b110100) + chr(53), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110010) + chr(0b11001 + 0o31) + '\062', 138 - 130), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b1101111) + chr(0b110001) + chr(0b110001) + chr(0b110010), 31664 - 31656), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\157' + '\062' + '\x34' + '\x30', 8), ehT0Px3KOsy9('\x30' + chr(4039 - 3928) + chr(50) + '\x33' + chr(460 - 407), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\067' + chr(48), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101011 + 0o7) + chr(0b10 + 0o64) + chr(0b101000 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + chr(2586 - 2535) + '\x32' + chr(0b110101), 10523 - 10515), ehT0Px3KOsy9(chr(1342 - 1294) + chr(0b11011 + 0o124) + chr(2301 - 2250) + chr(49) + '\061', 44397 - 44389), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(4741 - 4630) + chr(53), 191 - 183), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b1101111) + chr(255 - 206) + '\062' + chr(53), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(54), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11100 + 0o26) + chr(0b100011 + 0o23) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(269 - 221) + chr(111) + chr(53) + chr(0b110011), 4680 - 4672), ehT0Px3KOsy9(chr(48) + chr(2639 - 2528) + chr(0b110011) + '\x33' + chr(2949 - 2894), 0o10), ehT0Px3KOsy9('\x30' + chr(2798 - 2687) + '\x36' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(5619 - 5508) + '\x33' + chr(1743 - 1693) + '\067', 34680 - 34672), ehT0Px3KOsy9('\x30' + chr(0b111000 + 0o67) + chr(0b10111 + 0o32) + chr(54) + chr(2538 - 2487), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\x37' + '\061', 0b1000), ehT0Px3KOsy9(chr(2288 - 2240) + chr(0b1101111) + chr(0b110001) + chr(54) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(8542 - 8431) + '\061' + chr(55) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b101110 + 0o101) + '\x31' + chr(0b1001 + 0o53) + chr(1560 - 1507), 8), ehT0Px3KOsy9(chr(655 - 607) + chr(0b100001 + 0o116) + '\062' + chr(916 - 862), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + '\065' + chr(49), 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + chr(51) + '\065' + chr(108 - 55), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110101) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\157' + '\061' + chr(0b110011) + chr(0b100101 + 0o17), 47769 - 47761), ehT0Px3KOsy9(chr(377 - 329) + chr(0b100110 + 0o111) + chr(0b1011 + 0o46) + chr(0b1110 + 0o50) + chr(51), 8), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b1010111 + 0o30) + '\x32' + chr(0b1011 + 0o45) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(0b110010) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11010 + 0o31) + '\067' + chr(1812 - 1759), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(0b110110) + chr(50), 0b1000), ehT0Px3KOsy9(chr(475 - 427) + '\x6f' + chr(2280 - 2229) + chr(0b110100), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\065' + chr(0b11110 + 0o22), 7793 - 7785)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x83'), chr(6294 - 6194) + chr(0b1100101) + chr(6693 - 6594) + '\x6f' + chr(6766 - 6666) + '\145')('\x75' + '\x74' + '\x66' + chr(1210 - 1165) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def jxwDKpUD8RBv(oVre8I6UXc3b) -> zBnV56fc6HrA[M8_cKLkHVB2V, zBnV56fc6HrA[M8_cKLkHVB2V, ehT0Px3KOsy9]]:
dvel49fT6_fT = {}
for (eLFXQGzYXo5B, fEcfxx4smAdS) in xafqLlk3kkUe(oVre8I6UXc3b.fields, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe3\xdaV<\x11\xabV\xdb&\xf3\xd5&'), chr(0b100001 + 0o103) + chr(0b1000011 + 0o42) + '\143' + chr(111) + chr(4340 - 4240) + chr(0b1011101 + 0o10))(chr(0b110100 + 0o101) + chr(0b1110100) + '\146' + chr(151 - 106) + chr(0b110011 + 0o5)))():
dvel49fT6_fT[eLFXQGzYXo5B] = fEcfxx4smAdS.get_padding_lengths()
return dvel49fT6_fT
|
allenai/allennlp
|
allennlp/data/instance.py
|
Instance.as_tensor_dict
|
def as_tensor_dict(self,
padding_lengths: Dict[str, Dict[str, int]] = None) -> Dict[str, DataArray]:
"""
Pads each ``Field`` in this instance to the lengths given in ``padding_lengths`` (which is
keyed by field name, then by padding key, the same as the return value in
:func:`get_padding_lengths`), returning a list of torch tensors for each field.
If ``padding_lengths`` is omitted, we will call ``self.get_padding_lengths()`` to get the
sizes of the tensors to create.
"""
padding_lengths = padding_lengths or self.get_padding_lengths()
tensors = {}
for field_name, field in self.fields.items():
tensors[field_name] = field.as_tensor(padding_lengths[field_name])
return tensors
|
python
|
def as_tensor_dict(self,
padding_lengths: Dict[str, Dict[str, int]] = None) -> Dict[str, DataArray]:
"""
Pads each ``Field`` in this instance to the lengths given in ``padding_lengths`` (which is
keyed by field name, then by padding key, the same as the return value in
:func:`get_padding_lengths`), returning a list of torch tensors for each field.
If ``padding_lengths`` is omitted, we will call ``self.get_padding_lengths()`` to get the
sizes of the tensors to create.
"""
padding_lengths = padding_lengths or self.get_padding_lengths()
tensors = {}
for field_name, field in self.fields.items():
tensors[field_name] = field.as_tensor(padding_lengths[field_name])
return tensors
|
[
"def",
"as_tensor_dict",
"(",
"self",
",",
"padding_lengths",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"DataArray",
"]",
":",
"padding_lengths",
"=",
"padding_lengths",
"or",
"self",
".",
"get_padding_lengths",
"(",
")",
"tensors",
"=",
"{",
"}",
"for",
"field_name",
",",
"field",
"in",
"self",
".",
"fields",
".",
"items",
"(",
")",
":",
"tensors",
"[",
"field_name",
"]",
"=",
"field",
".",
"as_tensor",
"(",
"padding_lengths",
"[",
"field_name",
"]",
")",
"return",
"tensors"
] |
Pads each ``Field`` in this instance to the lengths given in ``padding_lengths`` (which is
keyed by field name, then by padding key, the same as the return value in
:func:`get_padding_lengths`), returning a list of torch tensors for each field.
If ``padding_lengths`` is omitted, we will call ``self.get_padding_lengths()`` to get the
sizes of the tensors to create.
|
[
"Pads",
"each",
"Field",
"in",
"this",
"instance",
"to",
"the",
"lengths",
"given",
"in",
"padding_lengths",
"(",
"which",
"is",
"keyed",
"by",
"field",
"name",
"then",
"by",
"padding",
"key",
"the",
"same",
"as",
"the",
"return",
"value",
"in",
":",
"func",
":",
"get_padding_lengths",
")",
"returning",
"a",
"list",
"of",
"torch",
"tensors",
"for",
"each",
"field",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L84-L98
|
train
|
Returns a dictionary of torch tensors for each field in this instance.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G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ZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1010010 + 0o35) + chr(51) + chr(0b10000 + 0o40) + chr(998 - 949), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(310 - 259) + chr(0b1110 + 0o50), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(3516 - 3405) + '\x32' + chr(796 - 745) + chr(0b1000 + 0o56), 64198 - 64190), ehT0Px3KOsy9(chr(48) + chr(8165 - 8054) + chr(49) + chr(1292 - 1243) + '\x35', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b100110 + 0o15) + '\062' + chr(0b11110 + 0o23), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100111 + 0o12) + chr(2327 - 2277) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(49) + chr(2051 - 2001), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(191 - 80) + chr(54) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(0b110111) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110111) + '\x31', 0o10), ehT0Px3KOsy9(chr(342 - 294) + '\157' + '\063' + chr(53) + chr(0b110000), 38910 - 38902), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(50) + chr(50) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b1 + 0o66), 27681 - 27673), ehT0Px3KOsy9('\x30' + chr(0b1011111 + 0o20) + '\x33' + chr(0b110010) + chr(0b1 + 0o65), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(54) + chr(1099 - 1048), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(50) + '\x34', 65411 - 65403), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b11 + 0o60) + '\062' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + '\x33' + '\067', 0b1000), ehT0Px3KOsy9(chr(2030 - 1982) + chr(10998 - 10887) + chr(49) + '\x37' + chr(55), 14498 - 14490), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b11101 + 0o30) + '\062', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + '\x30' + '\064', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1001100 + 0o43) + '\061' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110110 + 0o71) + chr(0b100100 + 0o20) + chr(856 - 804), 22430 - 22422), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(4438 - 4327) + chr(0b110011) + chr(0b101000 + 0o16) + chr(0b10111 + 0o34), 5862 - 5854), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + chr(0b110101) + chr(1104 - 1056), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x36' + '\063', 8), ehT0Px3KOsy9(chr(48) + chr(9342 - 9231) + chr(51) + chr(315 - 266) + '\x31', 0b1000), ehT0Px3KOsy9(chr(614 - 566) + chr(9853 - 9742) + chr(0b1110 + 0o45) + chr(0b101010 + 0o11) + chr(138 - 85), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1001111 + 0o40) + chr(0b110011) + chr(0b110001) + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(9801 - 9690) + '\x32' + chr(526 - 471) + chr(1757 - 1705), 0b1000), ehT0Px3KOsy9(chr(48) + chr(3463 - 3352) + '\x31' + chr(0b110101) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b10001 + 0o43) + '\065', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b100110 + 0o17) + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2410 - 2359) + chr(0b101001 + 0o11) + '\065', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1652 - 1600) + chr(175 - 126), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10111 + 0o33) + chr(0b110100), 45196 - 45188), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + chr(0b10110 + 0o36) + '\066', 0b1000), ehT0Px3KOsy9('\x30' + chr(1199 - 1088) + chr(0b110001) + '\060' + chr(0b110111), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10 + 0o61) + chr(0b110000) + '\x30', 0b1000), ehT0Px3KOsy9('\060' + chr(440 - 329) + '\061' + chr(0b11100 + 0o27) + chr(68 - 17), 22946 - 22938)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(53) + '\x30', 61102 - 61094)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xef'), chr(5777 - 5677) + chr(0b100100 + 0o101) + chr(99) + chr(0b1100110 + 0o11) + '\144' + chr(101))('\165' + chr(0b1000011 + 0o61) + chr(0b1100110) + chr(0b101101) + chr(2082 - 2026)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def ESFi2Dvx6FGJ(oVre8I6UXc3b, QJBZYYPtla9t=None) -> zBnV56fc6HrA[M8_cKLkHVB2V, NKIz0QM3z0ms]:
QJBZYYPtla9t = QJBZYYPtla9t or oVre8I6UXc3b.get_padding_lengths()
Tyy4rche81dW = {}
for (eLFXQGzYXo5B, fEcfxx4smAdS) in xafqLlk3kkUe(oVre8I6UXc3b.fields, xafqLlk3kkUe(SXOLrMavuUCe(b'\x8fd\xe8(\x98\x0f\xb9|\xd3j\xa0\xaa'), '\144' + '\x65' + chr(0b1100011) + '\157' + '\144' + chr(101))(chr(117) + chr(0b1110100) + chr(102) + chr(0b1011 + 0o42) + '\070'))():
Tyy4rche81dW[eLFXQGzYXo5B] = fEcfxx4smAdS.as_tensor(QJBZYYPtla9t[eLFXQGzYXo5B])
return Tyy4rche81dW
|
allenai/allennlp
|
allennlp/common/configuration.py
|
full_name
|
def full_name(cla55: Optional[type]) -> str:
"""
Return the full name (including module) of the given class.
"""
# Special case to handle None:
if cla55 is None:
return "?"
if issubclass(cla55, Initializer) and cla55 not in [Initializer, PretrainedModelInitializer]:
init_fn = cla55()._init_function
return f"{init_fn.__module__}.{init_fn.__name__}"
origin = getattr(cla55, '__origin__', None)
args = getattr(cla55, '__args__', ())
# Special handling for compound types
if origin in (Dict, dict):
key_type, value_type = args
return f"""Dict[{full_name(key_type)}, {full_name(value_type)}]"""
elif origin in (Tuple, tuple, List, list, Sequence, collections.abc.Sequence):
return f"""{_remove_prefix(str(origin))}[{", ".join(full_name(arg) for arg in args)}]"""
elif origin == Union:
# Special special case to handle optional types:
if len(args) == 2 and args[-1] == type(None):
return f"""Optional[{full_name(args[0])}]"""
else:
return f"""Union[{", ".join(full_name(arg) for arg in args)}]"""
else:
return _remove_prefix(f"{cla55.__module__}.{cla55.__name__}")
|
python
|
def full_name(cla55: Optional[type]) -> str:
"""
Return the full name (including module) of the given class.
"""
# Special case to handle None:
if cla55 is None:
return "?"
if issubclass(cla55, Initializer) and cla55 not in [Initializer, PretrainedModelInitializer]:
init_fn = cla55()._init_function
return f"{init_fn.__module__}.{init_fn.__name__}"
origin = getattr(cla55, '__origin__', None)
args = getattr(cla55, '__args__', ())
# Special handling for compound types
if origin in (Dict, dict):
key_type, value_type = args
return f"""Dict[{full_name(key_type)}, {full_name(value_type)}]"""
elif origin in (Tuple, tuple, List, list, Sequence, collections.abc.Sequence):
return f"""{_remove_prefix(str(origin))}[{", ".join(full_name(arg) for arg in args)}]"""
elif origin == Union:
# Special special case to handle optional types:
if len(args) == 2 and args[-1] == type(None):
return f"""Optional[{full_name(args[0])}]"""
else:
return f"""Union[{", ".join(full_name(arg) for arg in args)}]"""
else:
return _remove_prefix(f"{cla55.__module__}.{cla55.__name__}")
|
[
"def",
"full_name",
"(",
"cla55",
":",
"Optional",
"[",
"type",
"]",
")",
"->",
"str",
":",
"# Special case to handle None:",
"if",
"cla55",
"is",
"None",
":",
"return",
"\"?\"",
"if",
"issubclass",
"(",
"cla55",
",",
"Initializer",
")",
"and",
"cla55",
"not",
"in",
"[",
"Initializer",
",",
"PretrainedModelInitializer",
"]",
":",
"init_fn",
"=",
"cla55",
"(",
")",
".",
"_init_function",
"return",
"f\"{init_fn.__module__}.{init_fn.__name__}\"",
"origin",
"=",
"getattr",
"(",
"cla55",
",",
"'__origin__'",
",",
"None",
")",
"args",
"=",
"getattr",
"(",
"cla55",
",",
"'__args__'",
",",
"(",
")",
")",
"# Special handling for compound types",
"if",
"origin",
"in",
"(",
"Dict",
",",
"dict",
")",
":",
"key_type",
",",
"value_type",
"=",
"args",
"return",
"f\"\"\"Dict[{full_name(key_type)}, {full_name(value_type)}]\"\"\"",
"elif",
"origin",
"in",
"(",
"Tuple",
",",
"tuple",
",",
"List",
",",
"list",
",",
"Sequence",
",",
"collections",
".",
"abc",
".",
"Sequence",
")",
":",
"return",
"f\"\"\"{_remove_prefix(str(origin))}[{\", \".join(full_name(arg) for arg in args)}]\"\"\"",
"elif",
"origin",
"==",
"Union",
":",
"# Special special case to handle optional types:",
"if",
"len",
"(",
"args",
")",
"==",
"2",
"and",
"args",
"[",
"-",
"1",
"]",
"==",
"type",
"(",
"None",
")",
":",
"return",
"f\"\"\"Optional[{full_name(args[0])}]\"\"\"",
"else",
":",
"return",
"f\"\"\"Union[{\", \".join(full_name(arg) for arg in args)}]\"\"\"",
"else",
":",
"return",
"_remove_prefix",
"(",
"f\"{cla55.__module__}.{cla55.__name__}\"",
")"
] |
Return the full name (including module) of the given class.
|
[
"Return",
"the",
"full",
"name",
"(",
"including",
"module",
")",
"of",
"the",
"given",
"class",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L34-L62
|
train
|
Returns the full name of the given class.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,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qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(0b11000 + 0o35) + chr(0b1010 + 0o46), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110111) + chr(49), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(0b110001) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(5397 - 5286) + '\061' + chr(503 - 454) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + '\061' + chr(0b1001 + 0o52), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + '\066' + '\x35', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100110 + 0o111) + chr(49) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x36' + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(1318 - 1265) + chr(574 - 526), 0o10), ehT0Px3KOsy9(chr(1433 - 1385) + '\157' + chr(0b110010) + chr(0b11100 + 0o24) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + '\063' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(726 - 615) + chr(49) + '\x37' + '\x33', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + '\061' + chr(49), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + '\x35' + chr(1119 - 1069), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + chr(0b110101) + chr(0b110110), 2536 - 2528), ehT0Px3KOsy9(chr(241 - 193) + chr(6670 - 6559) + chr(1645 - 1594) + chr(0b110111) + '\060', 0b1000), ehT0Px3KOsy9(chr(676 - 628) + chr(0b1101111) + chr(0b110001) + chr(0b110011 + 0o0) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b100100 + 0o113) + chr(55) + chr(52), 0b1000), ehT0Px3KOsy9('\060' + chr(0b111000 + 0o67) + '\x32' + '\x35' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b101011 + 0o104) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\157' + '\x33' + chr(49) + chr(52), 50888 - 50880), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(1324 - 1213) + '\x36' + '\x32', 61058 - 61050), ehT0Px3KOsy9(chr(1252 - 1204) + '\x6f' + chr(57 - 7) + chr(0b110001) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(3778 - 3667) + '\062' + chr(50) + chr(1314 - 1265), 21824 - 21816), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(111) + '\x31' + '\067' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(1104 - 1056) + '\157' + chr(2350 - 2301) + chr(1501 - 1452) + chr(1010 - 962), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(51) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100100 + 0o16) + chr(0b1011 + 0o51) + chr(54), 47291 - 47283), ehT0Px3KOsy9(chr(48) + chr(8970 - 8859) + chr(2135 - 2084) + chr(0b110110) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(673 - 620) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b111100 + 0o63) + chr(52) + chr(0b101100 + 0o10), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b100101 + 0o112) + chr(51) + chr(51) + chr(0b110 + 0o56), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010100 + 0o33) + '\x31' + chr(0b10001 + 0o37) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(1234 - 1179) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(0b1101111) + chr(51) + chr(0b110110) + '\x31', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(55) + chr(49), 8), ehT0Px3KOsy9(chr(575 - 527) + chr(0b1101111) + '\063' + '\x30' + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(629 - 581) + chr(111) + chr(0b110110) + '\x36', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(1193 - 1145) + '\157' + '\x35' + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x06'), '\x64' + chr(101) + chr(7902 - 7803) + chr(111) + chr(100) + '\145')('\165' + '\x74' + chr(5298 - 5196) + '\055' + chr(1443 - 1387)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def je7_3_Zvuq2o(is9TD1F9z7G2) -> M8_cKLkHVB2V:
if is9TD1F9z7G2 is None:
return xafqLlk3kkUe(SXOLrMavuUCe(b'\x17'), '\144' + chr(101) + '\143' + chr(0b101111 + 0o100) + chr(0b1011011 + 0o11) + '\145')(chr(0b111001 + 0o74) + chr(12396 - 12280) + chr(0b10001 + 0o125) + '\055' + chr(56))
if J6u1YyThfhgG(is9TD1F9z7G2, UwnGn3ARwzIE) and is9TD1F9z7G2 not in [UwnGn3ARwzIE, MhCq_CAYsS3U]:
TdbuOl6uKAC4 = is9TD1F9z7G2()._init_function
return f"{xafqLlk3kkUe(TdbuOl6uKAC4, chr(0b1000100 + 0o5) + chr(3942 - 3874) + chr(0b1001010) + chr(55) + chr(0b11011 + 0o133) + chr(0b1001101 + 0o3) + chr(112) + chr(74) + chr(102) + chr(111) + chr(2158 - 2109) + chr(0b1000101))}.{xafqLlk3kkUe(TdbuOl6uKAC4, chr(0b1101 + 0o72) + chr(7802 - 7704) + chr(101) + chr(0b1101010) + chr(0b100110 + 0o16) + chr(111) + chr(0b101010 + 0o60) + chr(113) + chr(1403 - 1328) + chr(0b1001100) + chr(65) + chr(0b110110))}"
YJV9ndirAHBI = xafqLlk3kkUe(is9TD1F9z7G2, xafqLlk3kkUe(SXOLrMavuUCe(b'wf\xe2<\xe2\x12fX\xb7\xdf'), chr(0b101101 + 0o67) + '\x65' + chr(99) + '\x6f' + chr(5661 - 5561) + chr(0b101101 + 0o70))(chr(0b1110101) + chr(0b1110100) + chr(102) + '\055' + '\070'), None)
kJDRfRhcZHjS = xafqLlk3kkUe(is9TD1F9z7G2, xafqLlk3kkUe(SXOLrMavuUCe(b'wf\xec<\xec\x06Pi'), chr(0b1011100 + 0o10) + chr(525 - 424) + chr(0b1100011) + chr(8498 - 8387) + chr(399 - 299) + chr(0b10001 + 0o124))(chr(117) + chr(8737 - 8621) + chr(0b1010 + 0o134) + '\055' + '\x38'), ())
if YJV9ndirAHBI in (zBnV56fc6HrA, wLqBDw8l0eIm):
(uQQ8V4lfHjIr, Mkc1eSH9mVGe) = kJDRfRhcZHjS
return f'Dict[{je7_3_Zvuq2o(uQQ8V4lfHjIr)}, {je7_3_Zvuq2o(Mkc1eSH9mVGe)}]'
elif YJV9ndirAHBI in (MRK8Uzg2En3D, KNyTy8rYcwji, qRxF7OQ0y39T, YyaZ4tpXu4lf, w9norYf4Z1i5, xafqLlk3kkUe(FGhnnwoh1Dd8.abc, xafqLlk3kkUe(SXOLrMavuUCe(b'{\\\xfc;\xee\x1blS'), chr(0b110001 + 0o63) + chr(101) + chr(0b1100011) + chr(0b1101111) + '\144' + chr(101))(chr(0b101100 + 0o111) + chr(0b1110100) + chr(0b110110 + 0o60) + '\055' + chr(56)))):
return f"{U7r1InhxLEfS(M8_cKLkHVB2V(YJV9ndirAHBI))}[{xafqLlk3kkUe(chr(44) + chr(0b11111 + 0o1), chr(0b111101 + 0o42) + chr(0b1011 + 0o144) + chr(0b1000110 + 0o21) + chr(88) + chr(122) + chr(0b101000 + 0o114) + chr(2610 - 2524) + chr(0b110011 + 0o33) + chr(8230 - 8120) + chr(113) + chr(72) + chr(0b1011 + 0o73))((je7_3_Zvuq2o(LTE9MPUbqSos) for LTE9MPUbqSos in kJDRfRhcZHjS))}]"
elif YJV9ndirAHBI == xS28O63k1eqo:
if c2A0yzQpDQB3(kJDRfRhcZHjS) == ehT0Px3KOsy9(chr(0b110000) + chr(0b1000 + 0o147) + chr(0b1001 + 0o51), 0b1000) and PlSM16l2KDPD(None, kJDRfRhcZHjS[-ehT0Px3KOsy9('\060' + chr(8753 - 8642) + '\x31', 0b1000)]):
return f'Optional[{je7_3_Zvuq2o(kJDRfRhcZHjS[0])}]'
else:
return f"Union[{xafqLlk3kkUe(chr(1202 - 1158) + chr(0b0 + 0o40), chr(0b1010101 + 0o12) + chr(111) + chr(87) + chr(0b11000 + 0o100) + chr(0b1111010) + chr(413 - 297) + chr(0b1010110) + chr(850 - 772) + chr(0b10100 + 0o132) + chr(9252 - 9139) + chr(0b100011 + 0o45) + chr(70))((je7_3_Zvuq2o(LTE9MPUbqSos) for LTE9MPUbqSos in kJDRfRhcZHjS))}]"
else:
return U7r1InhxLEfS(f"{xafqLlk3kkUe(is9TD1F9z7G2, chr(3949 - 3876) + chr(2723 - 2655) + chr(74) + chr(0b101110 + 0o11) + chr(118) + chr(80) + chr(112) + chr(0b1001010) + chr(3712 - 3610) + chr(111) + chr(0b100110 + 0o13) + chr(1304 - 1235))}.{xafqLlk3kkUe(is9TD1F9z7G2, chr(1824 - 1753) + chr(0b1100010) + chr(0b1100101) + chr(0b1101010) + chr(52) + chr(111) + chr(7675 - 7585) + chr(6096 - 5983) + chr(744 - 669) + chr(76) + chr(0b111100 + 0o5) + chr(0b110110))}")
|
allenai/allennlp
|
allennlp/common/configuration.py
|
_get_config_type
|
def _get_config_type(cla55: type) -> Optional[str]:
"""
Find the name (if any) that a subclass was registered under.
We do this simply by iterating through the registry until we
find it.
"""
# Special handling for pytorch RNN types:
if cla55 == torch.nn.RNN:
return "rnn"
elif cla55 == torch.nn.LSTM:
return "lstm"
elif cla55 == torch.nn.GRU:
return "gru"
for subclass_dict in Registrable._registry.values():
for name, subclass in subclass_dict.items():
if subclass == cla55:
return name
# Special handling for initializer functions
if hasattr(subclass, '_initializer_wrapper'):
sif = subclass()._init_function
if sif == cla55:
return sif.__name__.rstrip("_")
return None
|
python
|
def _get_config_type(cla55: type) -> Optional[str]:
"""
Find the name (if any) that a subclass was registered under.
We do this simply by iterating through the registry until we
find it.
"""
# Special handling for pytorch RNN types:
if cla55 == torch.nn.RNN:
return "rnn"
elif cla55 == torch.nn.LSTM:
return "lstm"
elif cla55 == torch.nn.GRU:
return "gru"
for subclass_dict in Registrable._registry.values():
for name, subclass in subclass_dict.items():
if subclass == cla55:
return name
# Special handling for initializer functions
if hasattr(subclass, '_initializer_wrapper'):
sif = subclass()._init_function
if sif == cla55:
return sif.__name__.rstrip("_")
return None
|
[
"def",
"_get_config_type",
"(",
"cla55",
":",
"type",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# Special handling for pytorch RNN types:",
"if",
"cla55",
"==",
"torch",
".",
"nn",
".",
"RNN",
":",
"return",
"\"rnn\"",
"elif",
"cla55",
"==",
"torch",
".",
"nn",
".",
"LSTM",
":",
"return",
"\"lstm\"",
"elif",
"cla55",
"==",
"torch",
".",
"nn",
".",
"GRU",
":",
"return",
"\"gru\"",
"for",
"subclass_dict",
"in",
"Registrable",
".",
"_registry",
".",
"values",
"(",
")",
":",
"for",
"name",
",",
"subclass",
"in",
"subclass_dict",
".",
"items",
"(",
")",
":",
"if",
"subclass",
"==",
"cla55",
":",
"return",
"name",
"# Special handling for initializer functions",
"if",
"hasattr",
"(",
"subclass",
",",
"'_initializer_wrapper'",
")",
":",
"sif",
"=",
"subclass",
"(",
")",
".",
"_init_function",
"if",
"sif",
"==",
"cla55",
":",
"return",
"sif",
".",
"__name__",
".",
"rstrip",
"(",
"\"_\"",
")",
"return",
"None"
] |
Find the name (if any) that a subclass was registered under.
We do this simply by iterating through the registry until we
find it.
|
[
"Find",
"the",
"name",
"(",
"if",
"any",
")",
"that",
"a",
"subclass",
"was",
"registered",
"under",
".",
"We",
"do",
"this",
"simply",
"by",
"iterating",
"through",
"the",
"registry",
"until",
"we",
"find",
"it",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#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OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101 + 0o142) + '\x32' + '\067' + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1669 - 1619) + chr(0b110100) + chr(0b1011 + 0o52), 30145 - 30137), ehT0Px3KOsy9(chr(87 - 39) + chr(0b1101111) + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\063' + chr(1622 - 1573) + chr(593 - 541), 0o10), ehT0Px3KOsy9(chr(80 - 32) + chr(111) + chr(1651 - 1602) + '\x35' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(411 - 363) + chr(0b1101111) + chr(0b110010) + chr(2226 - 2175) + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(9160 - 9049) + chr(51) + '\066', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(4103 - 3992) + '\063' + chr(2801 - 2746) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + '\x36' + '\061', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + '\x37' + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + '\x34' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10011 + 0o37) + chr(53) + chr(0b11011 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10111 + 0o32) + chr(0b110100) + chr(1327 - 1277), 0o10), ehT0Px3KOsy9(chr(1864 - 1816) + '\157' + chr(0b110100) + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(11044 - 10933) + chr(0b1100 + 0o46) + '\x32' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(0b1101111) + '\x33' + '\067' + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(570 - 519) + '\061' + chr(54), 0o10), ehT0Px3KOsy9(chr(1933 - 1885) + chr(7418 - 7307) + chr(51) + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x36' + chr(0b1111 + 0o50), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1100 + 0o46) + chr(0b110000) + chr(124 - 76), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + '\x36' + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1100 + 0o45) + chr(0b110000) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(1227 - 1179) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\x6f' + chr(55) + chr(0b110110), 37669 - 37661), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1101111) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(9094 - 8983) + chr(50) + chr(0b110001) + '\x34', 0o10), ehT0Px3KOsy9(chr(403 - 355) + chr(10354 - 10243) + '\062' + '\x35' + '\x31', 8), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + '\x33' + chr(0b110101) + chr(49), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(49) + chr(455 - 402) + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1 + 0o156) + chr(0b110010) + '\x32' + chr(0b1100 + 0o46), 0b1000), ehT0Px3KOsy9(chr(1259 - 1211) + chr(0b1011101 + 0o22) + chr(0b110100) + chr(0b100101 + 0o22), 27586 - 27578), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1101111) + '\x32' + chr(905 - 852) + chr(49), 8), ehT0Px3KOsy9(chr(0b110000) + chr(4850 - 4739) + '\x32' + chr(1672 - 1623) + chr(0b10110 + 0o36), 8), ehT0Px3KOsy9(chr(48) + chr(0b1001 + 0o146) + chr(0b110010) + '\060' + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101001 + 0o106) + '\x34' + '\065', 54299 - 54291), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(1539 - 1491) + '\x6f' + '\x32' + chr(0b110111) + '\x35', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(819 - 770) + chr(0b10101 + 0o42) + chr(0b10000 + 0o46), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(4429 - 4318) + '\x35' + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(0b110111), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\x6f' + '\x35' + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x95'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(0b1100101 + 0o12) + '\144' + '\145')(chr(12307 - 12190) + '\164' + chr(0b11 + 0o143) + '\x2d' + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def cxZJ_66JiWPB(is9TD1F9z7G2) -> vi1g1wPnZvlE[M8_cKLkHVB2V]:
if is9TD1F9z7G2 == xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe9\xebM'), chr(0b1100100) + '\x65' + '\143' + chr(10432 - 10321) + '\144' + '\145')('\165' + '\x74' + chr(10327 - 10225) + '\x2d' + chr(2437 - 2381))):
return xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9\xcbm'), '\144' + '\x65' + chr(0b1100011) + chr(0b1101100 + 0o3) + '\144' + chr(101))(chr(0b1011010 + 0o33) + chr(0b1110100) + '\146' + chr(1896 - 1851) + chr(0b111000))
elif is9TD1F9z7G2 == xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf7\xf6W\x81'), chr(100) + '\x65' + chr(99) + chr(111) + chr(100) + chr(0b101110 + 0o67))('\165' + '\x74' + chr(0b1100110) + chr(705 - 660) + '\070')):
return xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7\xd6w\xa1'), '\144' + '\145' + chr(5997 - 5898) + chr(0b1011 + 0o144) + chr(0b1100000 + 0o4) + chr(101))('\x75' + chr(0b1110100) + chr(922 - 820) + chr(0b101101) + '\x38')
elif is9TD1F9z7G2 == xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc\xf7V'), '\144' + chr(101) + '\143' + '\157' + '\x64' + '\x65')('\x75' + chr(0b1101 + 0o147) + chr(0b1000 + 0o136) + '\x2d' + chr(0b101110 + 0o12))):
return xafqLlk3kkUe(SXOLrMavuUCe(b'\xdc\xd7v'), chr(6306 - 6206) + chr(0b101100 + 0o71) + chr(0b1100011) + chr(1161 - 1050) + chr(0b1001111 + 0o25) + chr(0b1100101))(chr(0b10000 + 0o145) + chr(116) + chr(3015 - 2913) + chr(0b100111 + 0o6) + chr(56))
for UqfeKOkce3pD in xafqLlk3kkUe(as4C_9DOd2Yb._registry, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8\xf5m\x8f \xed+\xcd9\xcb\x07\xcb'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(111) + chr(5042 - 4942) + chr(101))(chr(1898 - 1781) + '\x74' + chr(0b1100110) + chr(0b101001 + 0o4) + '\x38'))():
for (AIvJRzLdDfgF, CBZQJD_UO_oZ) in xafqLlk3kkUe(UqfeKOkce3pD, xafqLlk3kkUe(SXOLrMavuUCe(b"\xf5\xdfu\xa9'\xc2-\xb0\x1d\xa9+\x90"), chr(1471 - 1371) + chr(101) + chr(99) + chr(111) + '\x64' + chr(0b1100101))(chr(117) + chr(116) + chr(0b101001 + 0o75) + '\055' + chr(2869 - 2813)))():
if CBZQJD_UO_oZ == is9TD1F9z7G2:
return AIvJRzLdDfgF
if lot1PSoAwYhj(CBZQJD_UO_oZ, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe4\xccm\xa5\x1a\xf1\x7f\x95\x18\x80\x06\xdb=Q\xe4\x9a\xbejR\xf2'), '\x64' + chr(0b1110 + 0o127) + chr(99) + chr(111) + chr(7103 - 7003) + chr(1675 - 1574))(chr(117) + '\x74' + '\x66' + chr(0b101101) + chr(1002 - 946))):
cf22zKeZ7L3p = CBZQJD_UO_oZ()._init_function
if cf22zKeZ7L3p == is9TD1F9z7G2:
return xafqLlk3kkUe(cf22zKeZ7L3p.__name__, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc9\xd6w\xbe\x07\xe8'), chr(4139 - 4039) + chr(0b1011000 + 0o15) + '\143' + chr(0b101100 + 0o103) + chr(100) + '\x65')(chr(0b1110101) + chr(0b1110100) + '\146' + '\x2d' + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe4'), '\144' + '\x65' + chr(0b1100011) + chr(0b100 + 0o153) + chr(0b110010 + 0o62) + '\x65')('\165' + chr(0b1110100) + chr(2404 - 2302) + chr(0b11 + 0o52) + '\070'))
return None
|
allenai/allennlp
|
allennlp/common/configuration.py
|
_docspec_comments
|
def _docspec_comments(obj) -> Dict[str, str]:
"""
Inspect the docstring and get the comments for each parameter.
"""
# Sometimes our docstring is on the class, and sometimes it's on the initializer,
# so we've got to check both.
class_docstring = getattr(obj, '__doc__', None)
init_docstring = getattr(obj.__init__, '__doc__', None) if hasattr(obj, '__init__') else None
docstring = class_docstring or init_docstring or ''
doc = NumpyDocString(docstring)
params = doc["Parameters"]
comments: Dict[str, str] = {}
for line in params:
# It looks like when there's not a space after the parameter name,
# numpydocstring parses it incorrectly.
name_bad = line[0]
name = name_bad.split(":")[0]
# Sometimes the line has 3 fields, sometimes it has 4 fields.
comment = "\n".join(line[-1])
comments[name] = comment
return comments
|
python
|
def _docspec_comments(obj) -> Dict[str, str]:
"""
Inspect the docstring and get the comments for each parameter.
"""
# Sometimes our docstring is on the class, and sometimes it's on the initializer,
# so we've got to check both.
class_docstring = getattr(obj, '__doc__', None)
init_docstring = getattr(obj.__init__, '__doc__', None) if hasattr(obj, '__init__') else None
docstring = class_docstring or init_docstring or ''
doc = NumpyDocString(docstring)
params = doc["Parameters"]
comments: Dict[str, str] = {}
for line in params:
# It looks like when there's not a space after the parameter name,
# numpydocstring parses it incorrectly.
name_bad = line[0]
name = name_bad.split(":")[0]
# Sometimes the line has 3 fields, sometimes it has 4 fields.
comment = "\n".join(line[-1])
comments[name] = comment
return comments
|
[
"def",
"_docspec_comments",
"(",
"obj",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"# Sometimes our docstring is on the class, and sometimes it's on the initializer,",
"# so we've got to check both.",
"class_docstring",
"=",
"getattr",
"(",
"obj",
",",
"'__doc__'",
",",
"None",
")",
"init_docstring",
"=",
"getattr",
"(",
"obj",
".",
"__init__",
",",
"'__doc__'",
",",
"None",
")",
"if",
"hasattr",
"(",
"obj",
",",
"'__init__'",
")",
"else",
"None",
"docstring",
"=",
"class_docstring",
"or",
"init_docstring",
"or",
"''",
"doc",
"=",
"NumpyDocString",
"(",
"docstring",
")",
"params",
"=",
"doc",
"[",
"\"Parameters\"",
"]",
"comments",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
"=",
"{",
"}",
"for",
"line",
"in",
"params",
":",
"# It looks like when there's not a space after the parameter name,",
"# numpydocstring parses it incorrectly.",
"name_bad",
"=",
"line",
"[",
"0",
"]",
"name",
"=",
"name_bad",
".",
"split",
"(",
"\":\"",
")",
"[",
"0",
"]",
"# Sometimes the line has 3 fields, sometimes it has 4 fields.",
"comment",
"=",
"\"\\n\"",
".",
"join",
"(",
"line",
"[",
"-",
"1",
"]",
")",
"comments",
"[",
"name",
"]",
"=",
"comment",
"return",
"comments"
] |
Inspect the docstring and get the comments for each parameter.
|
[
"Inspect",
"the",
"docstring",
"and",
"get",
"the",
"comments",
"for",
"each",
"parameter",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L195-L221
|
train
|
Inspect the docstring and get the comments for each parameter.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,Kk1hd194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ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(1870 - 1759) + chr(0b100111 + 0o14) + chr(0b110000), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + '\062' + chr(0b101111 + 0o2), 1303 - 1295), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(762 - 712) + chr(0b10100 + 0o37), 4414 - 4406), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011 + 0o4) + '\063', 0o10), ehT0Px3KOsy9('\x30' + chr(2605 - 2494) + '\061' + '\x33' + chr(1197 - 1146), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + '\063' + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + chr(0b110001) + '\060' + chr(49), 62511 - 62503), ehT0Px3KOsy9(chr(561 - 513) + chr(0b1110 + 0o141) + chr(49) + chr(0b1110 + 0o45) + chr(1204 - 1154), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(8873 - 8762) + chr(50) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + '\x6f' + '\062' + chr(0b101110 + 0o3), 0b1000), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(0b110001) + chr(0b101100 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1010110 + 0o31) + '\x31' + chr(0b110011) + '\x33', 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + '\067' + '\x37', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1100001 + 0o16) + chr(0b110101) + chr(969 - 920), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(234 - 123) + '\x32' + chr(55) + '\062', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1001110 + 0o41) + chr(0b110010 + 0o5) + '\067', 8047 - 8039), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101001 + 0o11) + chr(54) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101111 + 0o3) + '\x30' + '\x35', 0b1000), ehT0Px3KOsy9(chr(1712 - 1664) + '\x6f' + '\061' + chr(0b110010 + 0o2) + chr(0b11 + 0o55), 57163 - 57155), ehT0Px3KOsy9(chr(1395 - 1347) + '\x6f' + chr(0b11111 + 0o23) + chr(51) + chr(0b10010 + 0o43), 59832 - 59824), ehT0Px3KOsy9('\060' + chr(8335 - 8224) + chr(0b110011) + chr(2095 - 2041) + '\060', 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\x6f' + chr(0b11011 + 0o32) + '\x34', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + chr(48) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + chr(1213 - 1164), 8), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(511 - 400) + chr(0b110010) + chr(2147 - 2097) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b101010 + 0o105) + '\x33' + '\x32' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\066' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001110 + 0o41) + chr(49) + '\x34' + chr(0b111 + 0o51), 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1101111) + chr(91 - 42) + chr(2369 - 2319) + chr(0b100 + 0o62), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110110) + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x32' + chr(0b11000 + 0o33), 44838 - 44830), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + chr(950 - 902) + '\067', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x34' + '\x30', 38034 - 38026), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1001000 + 0o47) + chr(49) + chr(55) + '\062', 39426 - 39418), ehT0Px3KOsy9('\060' + chr(111) + chr(2211 - 2156) + chr(0b110011 + 0o2), 59262 - 59254), ehT0Px3KOsy9('\x30' + chr(6808 - 6697) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + chr(876 - 825) + chr(0b110110 + 0o1) + chr(802 - 751), 0b1000), ehT0Px3KOsy9(chr(1998 - 1950) + chr(0b1101110 + 0o1) + chr(0b110001) + '\x30' + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(0b1011010 + 0o25) + '\x31' + chr(0b110110) + chr(291 - 243), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + '\x35' + chr(0b101011 + 0o5), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'6'), '\x64' + '\145' + '\x63' + '\157' + chr(100) + '\145')(chr(117) + chr(116) + '\x66' + '\055' + chr(0b11000 + 0o40)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Y9ub8MXbmYnM(mDuDykdz0pcm) -> zBnV56fc6HrA[M8_cKLkHVB2V, M8_cKLkHVB2V]:
DJr0_Wmwu0gb = xafqLlk3kkUe(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'G\x0e\xb7T8\xc6\x1e'), chr(0b11101 + 0o107) + chr(4511 - 4410) + chr(0b1 + 0o142) + chr(0b101110 + 0o101) + chr(4413 - 4313) + chr(604 - 503))('\x75' + chr(0b1110100) + chr(9375 - 9273) + chr(0b101101) + '\070'), None)
MxW6aMwcRRUo = xafqLlk3kkUe(mDuDykdz0pcm.__init__, xafqLlk3kkUe(SXOLrMavuUCe(b'G\x0e\xb7T8\xc6\x1e'), chr(0b111110 + 0o46) + chr(0b1100101) + chr(7684 - 7585) + chr(10186 - 10075) + chr(5640 - 5540) + '\145')(chr(0b1110101) + chr(0b1110100) + chr(0b100100 + 0o102) + chr(45) + chr(0b111000)), None) if lot1PSoAwYhj(mDuDykdz0pcm, xafqLlk3kkUe(SXOLrMavuUCe(b'G\x0e\xbaU2\xed\x1e\x05'), '\144' + chr(8242 - 8141) + chr(99) + '\157' + '\x64' + chr(3265 - 3164))(chr(4661 - 4544) + chr(0b1110100) + '\x66' + chr(1173 - 1128) + chr(0b111000))) else None
nVYJv7AZy3Rn = DJr0_Wmwu0gb or MxW6aMwcRRUo or xafqLlk3kkUe(SXOLrMavuUCe(b''), '\144' + chr(9021 - 8920) + chr(99) + '\x6f' + chr(0b1100100) + chr(5812 - 5711))(chr(117) + '\x74' + chr(0b110001 + 0o65) + '\x2d' + chr(0b111000))
JCpEgna6NeKD = wTPcAVgSGsby(nVYJv7AZy3Rn)
nEbJZ4wfte2w = JCpEgna6NeKD[xafqLlk3kkUe(SXOLrMavuUCe(b'H0\xa1Z6\xfc5?bb'), '\x64' + chr(101) + '\x63' + chr(0b1101000 + 0o7) + chr(100) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(8988 - 8886) + '\055' + '\070')]
OsJWxY9ZtQdX = {}
for LycYkDpyelF6 in nEbJZ4wfte2w:
mJuhdyr0MxSr = LycYkDpyelF6[ehT0Px3KOsy9(chr(0b110000) + chr(0b1000001 + 0o56) + chr(0b110000), 0b1000)]
AIvJRzLdDfgF = mJuhdyr0MxSr.split(xafqLlk3kkUe(SXOLrMavuUCe(b'"'), chr(100) + chr(101) + chr(0b111111 + 0o44) + chr(11280 - 11169) + chr(100) + '\x65')(chr(117) + chr(5514 - 5398) + chr(0b1000010 + 0o44) + '\x2d' + chr(0b111000)))[ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(1288 - 1177) + '\060', 8)]
mUoZPwXPQG1p = xafqLlk3kkUe(SXOLrMavuUCe(b'\x12'), '\x64' + chr(101) + chr(2670 - 2571) + chr(8905 - 8794) + chr(8723 - 8623) + '\145')('\x75' + chr(0b110111 + 0o75) + chr(0b1100110) + chr(0b101101) + chr(91 - 35))._oWXztVNnqHF(LycYkDpyelF6[-ehT0Px3KOsy9('\x30' + '\x6f' + chr(353 - 304), 0o10)])
OsJWxY9ZtQdX[AIvJRzLdDfgF] = mUoZPwXPQG1p
return OsJWxY9ZtQdX
|
allenai/allennlp
|
allennlp/common/configuration.py
|
_auto_config
|
def _auto_config(cla55: Type[T]) -> Config[T]:
"""
Create the ``Config`` for a class by reflecting on its ``__init__``
method and applying a few hacks.
"""
typ3 = _get_config_type(cla55)
# Don't include self, or vocab
names_to_ignore = {"self", "vocab"}
# Hack for RNNs
if cla55 in [torch.nn.RNN, torch.nn.LSTM, torch.nn.GRU]:
cla55 = torch.nn.RNNBase
names_to_ignore.add("mode")
if isinstance(cla55, type):
# It's a class, so inspect its constructor
function_to_inspect = cla55.__init__
else:
# It's a function, so inspect it, and ignore tensor
function_to_inspect = cla55
names_to_ignore.add("tensor")
argspec = inspect.getfullargspec(function_to_inspect)
comments = _docspec_comments(cla55)
items: List[ConfigItem] = []
num_args = len(argspec.args)
defaults = list(argspec.defaults or [])
num_default_args = len(defaults)
num_non_default_args = num_args - num_default_args
# Required args all come first, default args at the end.
defaults = [_NO_DEFAULT for _ in range(num_non_default_args)] + defaults
for name, default in zip(argspec.args, defaults):
if name in names_to_ignore:
continue
annotation = argspec.annotations.get(name)
comment = comments.get(name)
# Don't include Model, the only place you'd specify that is top-level.
if annotation == Model:
continue
# Don't include DataIterator, the only place you'd specify that is top-level.
if annotation == DataIterator:
continue
# Don't include params for an Optimizer
if torch.optim.Optimizer in getattr(cla55, '__bases__', ()) and name == "params":
continue
# Don't include datasets in the trainer
if cla55 == Trainer and name.endswith("_dataset"):
continue
# Hack in our Optimizer class to the trainer
if cla55 == Trainer and annotation == torch.optim.Optimizer:
annotation = AllenNLPOptimizer
# Hack in embedding num_embeddings as optional (it can be inferred from the pretrained file)
if cla55 == Embedding and name == "num_embeddings":
default = None
items.append(ConfigItem(name, annotation, default, comment))
# More hacks, Embedding
if cla55 == Embedding:
items.insert(1, ConfigItem("pretrained_file", str, None))
return Config(items, typ3=typ3)
|
python
|
def _auto_config(cla55: Type[T]) -> Config[T]:
"""
Create the ``Config`` for a class by reflecting on its ``__init__``
method and applying a few hacks.
"""
typ3 = _get_config_type(cla55)
# Don't include self, or vocab
names_to_ignore = {"self", "vocab"}
# Hack for RNNs
if cla55 in [torch.nn.RNN, torch.nn.LSTM, torch.nn.GRU]:
cla55 = torch.nn.RNNBase
names_to_ignore.add("mode")
if isinstance(cla55, type):
# It's a class, so inspect its constructor
function_to_inspect = cla55.__init__
else:
# It's a function, so inspect it, and ignore tensor
function_to_inspect = cla55
names_to_ignore.add("tensor")
argspec = inspect.getfullargspec(function_to_inspect)
comments = _docspec_comments(cla55)
items: List[ConfigItem] = []
num_args = len(argspec.args)
defaults = list(argspec.defaults or [])
num_default_args = len(defaults)
num_non_default_args = num_args - num_default_args
# Required args all come first, default args at the end.
defaults = [_NO_DEFAULT for _ in range(num_non_default_args)] + defaults
for name, default in zip(argspec.args, defaults):
if name in names_to_ignore:
continue
annotation = argspec.annotations.get(name)
comment = comments.get(name)
# Don't include Model, the only place you'd specify that is top-level.
if annotation == Model:
continue
# Don't include DataIterator, the only place you'd specify that is top-level.
if annotation == DataIterator:
continue
# Don't include params for an Optimizer
if torch.optim.Optimizer in getattr(cla55, '__bases__', ()) and name == "params":
continue
# Don't include datasets in the trainer
if cla55 == Trainer and name.endswith("_dataset"):
continue
# Hack in our Optimizer class to the trainer
if cla55 == Trainer and annotation == torch.optim.Optimizer:
annotation = AllenNLPOptimizer
# Hack in embedding num_embeddings as optional (it can be inferred from the pretrained file)
if cla55 == Embedding and name == "num_embeddings":
default = None
items.append(ConfigItem(name, annotation, default, comment))
# More hacks, Embedding
if cla55 == Embedding:
items.insert(1, ConfigItem("pretrained_file", str, None))
return Config(items, typ3=typ3)
|
[
"def",
"_auto_config",
"(",
"cla55",
":",
"Type",
"[",
"T",
"]",
")",
"->",
"Config",
"[",
"T",
"]",
":",
"typ3",
"=",
"_get_config_type",
"(",
"cla55",
")",
"# Don't include self, or vocab",
"names_to_ignore",
"=",
"{",
"\"self\"",
",",
"\"vocab\"",
"}",
"# Hack for RNNs",
"if",
"cla55",
"in",
"[",
"torch",
".",
"nn",
".",
"RNN",
",",
"torch",
".",
"nn",
".",
"LSTM",
",",
"torch",
".",
"nn",
".",
"GRU",
"]",
":",
"cla55",
"=",
"torch",
".",
"nn",
".",
"RNNBase",
"names_to_ignore",
".",
"add",
"(",
"\"mode\"",
")",
"if",
"isinstance",
"(",
"cla55",
",",
"type",
")",
":",
"# It's a class, so inspect its constructor",
"function_to_inspect",
"=",
"cla55",
".",
"__init__",
"else",
":",
"# It's a function, so inspect it, and ignore tensor",
"function_to_inspect",
"=",
"cla55",
"names_to_ignore",
".",
"add",
"(",
"\"tensor\"",
")",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"function_to_inspect",
")",
"comments",
"=",
"_docspec_comments",
"(",
"cla55",
")",
"items",
":",
"List",
"[",
"ConfigItem",
"]",
"=",
"[",
"]",
"num_args",
"=",
"len",
"(",
"argspec",
".",
"args",
")",
"defaults",
"=",
"list",
"(",
"argspec",
".",
"defaults",
"or",
"[",
"]",
")",
"num_default_args",
"=",
"len",
"(",
"defaults",
")",
"num_non_default_args",
"=",
"num_args",
"-",
"num_default_args",
"# Required args all come first, default args at the end.",
"defaults",
"=",
"[",
"_NO_DEFAULT",
"for",
"_",
"in",
"range",
"(",
"num_non_default_args",
")",
"]",
"+",
"defaults",
"for",
"name",
",",
"default",
"in",
"zip",
"(",
"argspec",
".",
"args",
",",
"defaults",
")",
":",
"if",
"name",
"in",
"names_to_ignore",
":",
"continue",
"annotation",
"=",
"argspec",
".",
"annotations",
".",
"get",
"(",
"name",
")",
"comment",
"=",
"comments",
".",
"get",
"(",
"name",
")",
"# Don't include Model, the only place you'd specify that is top-level.",
"if",
"annotation",
"==",
"Model",
":",
"continue",
"# Don't include DataIterator, the only place you'd specify that is top-level.",
"if",
"annotation",
"==",
"DataIterator",
":",
"continue",
"# Don't include params for an Optimizer",
"if",
"torch",
".",
"optim",
".",
"Optimizer",
"in",
"getattr",
"(",
"cla55",
",",
"'__bases__'",
",",
"(",
")",
")",
"and",
"name",
"==",
"\"params\"",
":",
"continue",
"# Don't include datasets in the trainer",
"if",
"cla55",
"==",
"Trainer",
"and",
"name",
".",
"endswith",
"(",
"\"_dataset\"",
")",
":",
"continue",
"# Hack in our Optimizer class to the trainer",
"if",
"cla55",
"==",
"Trainer",
"and",
"annotation",
"==",
"torch",
".",
"optim",
".",
"Optimizer",
":",
"annotation",
"=",
"AllenNLPOptimizer",
"# Hack in embedding num_embeddings as optional (it can be inferred from the pretrained file)",
"if",
"cla55",
"==",
"Embedding",
"and",
"name",
"==",
"\"num_embeddings\"",
":",
"default",
"=",
"None",
"items",
".",
"append",
"(",
"ConfigItem",
"(",
"name",
",",
"annotation",
",",
"default",
",",
"comment",
")",
")",
"# More hacks, Embedding",
"if",
"cla55",
"==",
"Embedding",
":",
"items",
".",
"insert",
"(",
"1",
",",
"ConfigItem",
"(",
"\"pretrained_file\"",
",",
"str",
",",
"None",
")",
")",
"return",
"Config",
"(",
"items",
",",
"typ3",
"=",
"typ3",
")"
] |
Create the ``Config`` for a class by reflecting on its ``__init__``
method and applying a few hacks.
|
[
"Create",
"the",
"Config",
"for",
"a",
"class",
"by",
"reflecting",
"on",
"its",
"__init__",
"method",
"and",
"applying",
"a",
"few",
"hacks",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L223-L295
|
train
|
Auto - creates a new Config for a class.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwE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ipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b110100 + 0o0) + chr(50), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(0b110100 + 0o3) + chr(0b10000 + 0o46), 0o10), ehT0Px3KOsy9(chr(80 - 32) + chr(7853 - 7742) + chr(49) + chr(53) + chr(2658 - 2603), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + '\x33' + chr(0b110011 + 0o3) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(111) + '\065' + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(2303 - 2252) + '\061', 55167 - 55159), ehT0Px3KOsy9('\060' + chr(5069 - 4958) + chr(0b110001) + chr(0b10101 + 0o40) + chr(348 - 298), ord("\x08")), ehT0Px3KOsy9(chr(49 - 1) + '\x6f' + chr(50) + '\067' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + '\x35' + chr(1915 - 1861), 60463 - 60455), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000 + 0o147) + chr(0b110010) + chr(757 - 703) + chr(1456 - 1402), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b110 + 0o53) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(1553 - 1505) + '\157' + '\x31' + chr(51) + '\060', 0b1000), ehT0Px3KOsy9(chr(261 - 213) + chr(0b1101111) + '\062' + chr(55) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\x37' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + chr(2324 - 2274) + chr(0b110000), 1347 - 1339), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b111 + 0o54) + chr(590 - 535) + chr(0b1001 + 0o52), 0o10), ehT0Px3KOsy9(chr(509 - 461) + chr(7095 - 6984) + chr(0b101111 + 0o2) + chr(52) + chr(48), 0b1000), ehT0Px3KOsy9(chr(0b1000 + 0o50) + '\x6f' + '\x31' + '\x31' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(524 - 476) + '\157' + chr(0b11010 + 0o27) + chr(52) + '\062', 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1101111) + chr(0b10110 + 0o35) + chr(1200 - 1145), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(1045 - 994) + '\x37', 27918 - 27910), ehT0Px3KOsy9('\060' + chr(8399 - 8288) + chr(50) + '\065' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(329 - 279) + chr(0b110101) + chr(2341 - 2287), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(457 - 406) + chr(49), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10111 + 0o37) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2212 - 2161) + chr(0b100110 + 0o17) + chr(55), 38038 - 38030), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + chr(55) + '\065', 54701 - 54693), ehT0Px3KOsy9(chr(0b11101 + 0o23) + '\x6f' + chr(51) + '\067' + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(168 - 120) + chr(111) + chr(1254 - 1204) + chr(0b110000), 32757 - 32749), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x32' + '\063' + chr(0b0 + 0o63), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + '\060' + chr(137 - 84), 12059 - 12051), ehT0Px3KOsy9('\060' + chr(111) + chr(1026 - 975) + chr(0b101110 + 0o3), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(777 - 726) + '\064' + chr(0b1100 + 0o52), 19262 - 19254), ehT0Px3KOsy9(chr(540 - 492) + chr(0b1101111) + chr(0b110110) + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(290 - 240) + chr(1806 - 1752) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(1856 - 1808) + chr(111) + chr(0b110001) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(3690 - 3579) + '\063' + chr(52) + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x36' + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(1483 - 1434) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(1239 - 1191) + '\157' + chr(0b110001) + chr(0b101101 + 0o6) + chr(0b10000 + 0o44), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(4862 - 4751) + chr(0b110101) + '\x30', 48802 - 48794)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8c'), chr(0b1100100) + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(0b100 + 0o140) + chr(0b1011110 + 0o7))(chr(0b1100 + 0o151) + '\164' + chr(0b1100110) + chr(0b100100 + 0o11) + chr(0b100010 + 0o26)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def CnocoXkGft7u(is9TD1F9z7G2) -> oR3zja24ldyJ[GkVqzVIYtSeO]:
av2Rrhhw6KZF = cxZJ_66JiWPB(is9TD1F9z7G2)
nGuWDgf0Q6DN = {xafqLlk3kkUe(SXOLrMavuUCe(b'\xd1\x1b\x03\x93'), chr(0b1100100) + chr(8279 - 8178) + '\x63' + chr(118 - 7) + '\x64' + chr(9097 - 8996))(chr(0b1110101) + chr(842 - 726) + '\x66' + chr(45) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\xd4\x11\x0c\x94O'), '\144' + '\x65' + '\143' + chr(0b1101111) + chr(1553 - 1453) + chr(101))(chr(10374 - 10257) + '\x74' + '\x66' + chr(1227 - 1182) + '\070')}
if is9TD1F9z7G2 in [xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf00!'), chr(8450 - 8350) + chr(101) + '\x63' + chr(111) + chr(0b1100100) + '\x65')(chr(117) + chr(0b10011 + 0o141) + '\146' + '\x2d' + chr(408 - 352))), xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xee-;\xb8'), chr(8042 - 7942) + chr(9986 - 9885) + '\x63' + '\157' + chr(0b1100100) + chr(0b100100 + 0o101))('\x75' + chr(0b1110100) + chr(0b1011000 + 0o16) + '\055' + chr(0b101110 + 0o12))), xafqLlk3kkUe(cEkFpYktkSeK.nn, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe5,:'), '\144' + chr(0b1100101) + chr(5979 - 5880) + chr(111) + '\x64' + chr(101))(chr(0b1110101) + chr(370 - 254) + chr(0b1100110) + chr(0b11110 + 0o17) + chr(0b111000)))]:
is9TD1F9z7G2 = cEkFpYktkSeK.nn.RNNBase
xafqLlk3kkUe(nGuWDgf0Q6DN, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd74_\x84\x14\xfa-\x8b\xb4\xf9\x99k'), '\144' + chr(0b1101 + 0o130) + chr(3855 - 3756) + chr(0b101 + 0o152) + chr(0b1100100 + 0o0) + '\x65')(chr(117) + '\x74' + chr(1820 - 1718) + chr(45) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf\x11\x0b\x90'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(1301 - 1190) + chr(100) + chr(0b1100101))(chr(0b1010010 + 0o43) + '\164' + '\x66' + chr(0b101101) + chr(2196 - 2140)))
if PlSM16l2KDPD(is9TD1F9z7G2, wmQmyeWBmUpv):
SGKqpvpDKxnx = is9TD1F9z7G2.__init__
else:
SGKqpvpDKxnx = is9TD1F9z7G2
xafqLlk3kkUe(nGuWDgf0Q6DN, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd74_\x84\x14\xfa-\x8b\xb4\xf9\x99k'), '\x64' + '\x65' + chr(0b1100011) + '\x6f' + chr(100) + chr(0b110011 + 0o62))('\x75' + '\164' + chr(4494 - 4392) + '\055' + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd6\x1b\x01\x86B\xeb'), chr(0b110011 + 0o61) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(100) + '\x65')(chr(117) + '\164' + '\x66' + chr(0b101101) + chr(56)))
UuCc3Vtxh59H = kzXqv8ZZwm75.getfullargspec(SGKqpvpDKxnx)
OsJWxY9ZtQdX = Y9ub8MXbmYnM(is9TD1F9z7G2)
NzveIZ3IlSH9 = []
_oJDDborOOJ6 = c2A0yzQpDQB3(UuCc3Vtxh59H.kJDRfRhcZHjS)
sRkYTJirQlN8 = YyaZ4tpXu4lf(UuCc3Vtxh59H.defaults or [])
n5Wum_qInTru = c2A0yzQpDQB3(sRkYTJirQlN8)
G8gHgFQnwet_ = _oJDDborOOJ6 - n5Wum_qInTru
sRkYTJirQlN8 = [S5nigsI3n12F for VNGQdHSFPrso in vQr8gNKaIaWE(G8gHgFQnwet_)] + sRkYTJirQlN8
for (AIvJRzLdDfgF, t1v7afVhe01t) in pZ0NK2y6HRbn(xafqLlk3kkUe(UuCc3Vtxh59H, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc94+\xa7K\xcb\x02\xdd\xb4\xfe\xa1\x0b'), '\144' + chr(0b1100101) + chr(0b111000 + 0o53) + chr(0b1101111) + chr(100) + '\x65')('\165' + '\164' + '\146' + chr(0b11000 + 0o25) + chr(56))), sRkYTJirQlN8):
if AIvJRzLdDfgF in nGuWDgf0Q6DN:
continue
vIc_73L45y1x = UuCc3Vtxh59H.annotations.get(AIvJRzLdDfgF)
mUoZPwXPQG1p = OsJWxY9ZtQdX.get(AIvJRzLdDfgF)
if vIc_73L45y1x == JC8lDcRGu6X6:
continue
if vIc_73L45y1x == xhi4BHbLZKGU:
continue
if xafqLlk3kkUe(cEkFpYktkSeK.optim, xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\x0e\x1b\x9c@\xf0\x10\xdb\x9c'), '\x64' + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(100) + chr(0b1001110 + 0o27))('\165' + chr(0b1110100) + chr(0b101011 + 0o73) + '\x2d' + chr(56))) in xafqLlk3kkUe(is9TD1F9z7G2, xafqLlk3kkUe(SXOLrMavuUCe(b'\xfd!\r\x94^\xfc\x19\xe1\xb1'), chr(100) + chr(0b1100101) + '\x63' + chr(0b1101111) + chr(969 - 869) + chr(0b1000111 + 0o36))(chr(0b1110101) + '\x74' + chr(102) + chr(45) + chr(0b1001 + 0o57)), ()) and AIvJRzLdDfgF == xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\x1f\x1d\x94@\xea'), chr(0b1011011 + 0o11) + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + chr(100) + '\x65')(chr(12776 - 12659) + chr(116) + chr(0b1100110) + chr(0b1110 + 0o37) + '\070'):
continue
if is9TD1F9z7G2 == hZriZHGNaIGA and xafqLlk3kkUe(AIvJRzLdDfgF, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc7\x10\x0b\x86Z\xf0\x1e\xd6'), '\x64' + '\x65' + chr(7497 - 7398) + '\157' + '\144' + chr(3390 - 3289))(chr(0b1110101) + chr(0b110101 + 0o77) + chr(9905 - 9803) + chr(0b10010 + 0o33) + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xfd\x1a\x0e\x81L\xea\x0f\xca'), chr(6405 - 6305) + chr(101) + '\143' + chr(0b1101111) + '\144' + chr(0b1100101))(chr(0b1110101) + '\164' + chr(102) + chr(45) + chr(0b11000 + 0o40))):
continue
if is9TD1F9z7G2 == hZriZHGNaIGA and vIc_73L45y1x == xafqLlk3kkUe(cEkFpYktkSeK.optim, xafqLlk3kkUe(SXOLrMavuUCe(b'\xed\x0e\x1b\x9c@\xf0\x10\xdb\x9c'), '\144' + chr(4297 - 4196) + chr(0b11 + 0o140) + chr(0b1101111) + chr(0b110100 + 0o60) + '\x65')(chr(6573 - 6456) + chr(782 - 666) + chr(0b110100 + 0o62) + chr(0b10101 + 0o30) + chr(1988 - 1932))):
vIc_73L45y1x = U7R8jshQSGhC
if is9TD1F9z7G2 == UvUNwTdSPUfp and AIvJRzLdDfgF == xafqLlk3kkUe(SXOLrMavuUCe(b'\xcc\x0b\x02\xaaH\xf4\x08\xdb\x8a\xd2\xa26\xde\xcf'), chr(0b110000 + 0o64) + chr(0b1100101) + chr(4930 - 4831) + '\x6f' + chr(100) + '\x65')('\165' + chr(0b110100 + 0o100) + chr(102) + chr(1796 - 1751) + chr(607 - 551)):
t1v7afVhe01t = None
xafqLlk3kkUe(NzveIZ3IlSH9, xafqLlk3kkUe(SXOLrMavuUCe(b'\xc3\x0e\x1f\x90C\xfd'), chr(0b1100100) + chr(101) + '\143' + chr(111) + chr(0b1100100) + '\145')(chr(0b1001111 + 0o46) + '\164' + chr(0b1100110) + '\x2d' + '\x38'))(IeqxQKTCyq6v(AIvJRzLdDfgF, vIc_73L45y1x, t1v7afVhe01t, mUoZPwXPQG1p))
if is9TD1F9z7G2 == UvUNwTdSPUfp:
xafqLlk3kkUe(NzveIZ3IlSH9, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcb\x10\x1c\x90_\xed'), chr(2598 - 2498) + chr(0b1100101) + '\x63' + chr(0b1000010 + 0o55) + chr(100) + '\145')('\x75' + '\x74' + chr(0b1100110) + chr(45) + chr(0b10101 + 0o43)))(ehT0Px3KOsy9(chr(1412 - 1364) + '\x6f' + chr(0b110001), 0b1000), IeqxQKTCyq6v(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\x0c\n\x81_\xf8\x03\xd0\x8b\xd2\x94>\xd0\xd05'), chr(100) + chr(101) + '\x63' + '\157' + '\144' + chr(0b1100101))(chr(4985 - 4868) + chr(0b1110100) + chr(0b1100110) + chr(45) + '\x38'), M8_cKLkHVB2V, None))
return oR3zja24ldyJ(NzveIZ3IlSH9, typ3=av2Rrhhw6KZF)
|
allenai/allennlp
|
allennlp/common/configuration.py
|
render_config
|
def render_config(config: Config, indent: str = "") -> str:
"""
Pretty-print a config in sort-of-JSON+comments.
"""
# Add four spaces to the indent.
new_indent = indent + " "
return "".join([
# opening brace + newline
"{\n",
# "type": "...", (if present)
f'{new_indent}"type": "{config.typ3}",\n' if config.typ3 else '',
# render each item
"".join(_render(item, new_indent) for item in config.items),
# indent and close the brace
indent,
"}\n"
])
|
python
|
def render_config(config: Config, indent: str = "") -> str:
"""
Pretty-print a config in sort-of-JSON+comments.
"""
# Add four spaces to the indent.
new_indent = indent + " "
return "".join([
# opening brace + newline
"{\n",
# "type": "...", (if present)
f'{new_indent}"type": "{config.typ3}",\n' if config.typ3 else '',
# render each item
"".join(_render(item, new_indent) for item in config.items),
# indent and close the brace
indent,
"}\n"
])
|
[
"def",
"render_config",
"(",
"config",
":",
"Config",
",",
"indent",
":",
"str",
"=",
"\"\"",
")",
"->",
"str",
":",
"# Add four spaces to the indent.",
"new_indent",
"=",
"indent",
"+",
"\" \"",
"return",
"\"\"",
".",
"join",
"(",
"[",
"# opening brace + newline",
"\"{\\n\"",
",",
"# \"type\": \"...\", (if present)",
"f'{new_indent}\"type\": \"{config.typ3}\",\\n'",
"if",
"config",
".",
"typ3",
"else",
"''",
",",
"# render each item",
"\"\"",
".",
"join",
"(",
"_render",
"(",
"item",
",",
"new_indent",
")",
"for",
"item",
"in",
"config",
".",
"items",
")",
",",
"# indent and close the brace",
"indent",
",",
"\"}\\n\"",
"]",
")"
] |
Pretty-print a config in sort-of-JSON+comments.
|
[
"Pretty",
"-",
"print",
"a",
"config",
"in",
"sort",
"-",
"of",
"-",
"JSON",
"+",
"comments",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L298-L315
|
train
|
Pretty - print a config in sort - of - JSON + comments.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,O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,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1703 - 1655) + '\157' + chr(0b110001) + '\x30' + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32' + '\064' + chr(0b11011 + 0o30), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110011) + chr(1777 - 1723) + chr(2388 - 2337), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1011000 + 0o27) + chr(53) + chr(637 - 582), 8793 - 8785), ehT0Px3KOsy9(chr(780 - 732) + chr(3774 - 3663) + chr(1443 - 1392) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(2117 - 2064), 8), ehT0Px3KOsy9('\060' + chr(0b1111 + 0o140) + chr(0b110001) + chr(962 - 909) + chr(0b11000 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(939 - 885) + chr(54), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(49) + '\062' + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(53) + '\x32', 8), ehT0Px3KOsy9('\x30' + chr(0b110111 + 0o70) + chr(49) + '\061' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + chr(49) + '\060' + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + chr(0b100001 + 0o116) + chr(49) + chr(48) + chr(52), 57604 - 57596), ehT0Px3KOsy9(chr(0b1001 + 0o47) + '\157' + chr(0b101001 + 0o12) + '\064' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b101110 + 0o7) + chr(0b110001), 29601 - 29593), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1733 - 1678), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(2259 - 2210) + '\x32' + chr(0b11000 + 0o30), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b11 + 0o154) + chr(0b100100 + 0o15) + '\064' + chr(0b10101 + 0o36), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1380 - 1330) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + '\157' + chr(0b110010) + '\x33' + chr(1653 - 1605), 13463 - 13455), ehT0Px3KOsy9('\060' + '\x6f' + chr(490 - 439) + '\x36' + chr(2055 - 2001), 10822 - 10814), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010010 + 0o35) + chr(0b1010 + 0o50) + chr(0b110111), 46324 - 46316), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100101 + 0o15) + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(5162 - 5051) + chr(0b110001) + chr(0b101110 + 0o6) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(51) + chr(0b110110) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(449 - 400) + chr(1203 - 1152), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(1540 - 1489) + chr(253 - 203) + '\067', 35469 - 35461), ehT0Px3KOsy9(chr(0b110000) + chr(11808 - 11697) + '\x33' + '\066' + '\061', 0b1000), ehT0Px3KOsy9(chr(1406 - 1358) + '\x6f' + '\x33' + '\062' + chr(2701 - 2647), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4557 - 4446) + '\067' + '\x36', 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b0 + 0o157) + '\x32' + chr(49) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + chr(0b10010 + 0o40) + chr(0b110100), 21900 - 21892), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(0b101100 + 0o103) + chr(0b110010) + '\x30' + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + chr(10655 - 10544) + chr(0b110001) + chr(48) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\x6f' + '\x33' + chr(0b110110) + chr(50), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(117 - 69) + '\063', 0b1000), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(12153 - 12042) + '\061' + chr(870 - 817) + chr(1218 - 1165), 0b1000), ehT0Px3KOsy9(chr(2271 - 2223) + '\x6f' + chr(50) + chr(77 - 25) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2122 - 2072) + chr(2168 - 2113) + chr(0b1 + 0o62), 38348 - 38340), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(55) + '\060', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + chr(10191 - 10080) + '\x35' + chr(1528 - 1480), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'l'), chr(0b110 + 0o136) + chr(0b1001111 + 0o26) + chr(0b11 + 0o140) + chr(111) + chr(0b1100100) + chr(101))('\165' + chr(0b1110100) + chr(102) + chr(45) + chr(918 - 862)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def EBNFOGXrYeGg(jAj7S20Ct06o, rxwJk_g4F6Db=xafqLlk3kkUe(SXOLrMavuUCe(b''), '\x64' + chr(101) + '\143' + '\157' + chr(1810 - 1710) + '\145')(chr(0b1110101) + '\x74' + chr(0b1100110) + chr(1906 - 1861) + '\070')) -> M8_cKLkHVB2V:
_CMRF_PF_yhZ = rxwJk_g4F6Db + xafqLlk3kkUe(SXOLrMavuUCe(b'b\x83\xd3\x0f'), chr(0b111 + 0o135) + chr(101) + chr(99) + '\x6f' + '\144' + '\x65')(chr(117) + chr(116) + chr(102) + chr(0b1110 + 0o37) + chr(56))
return xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1010010 + 0o22) + chr(101) + chr(0b1100011) + chr(111) + '\x64' + chr(101))('\165' + '\x74' + '\146' + chr(45) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\xcc\xa4wgi<88\x1b\x06\x00'), chr(100) + chr(0b1100101) + chr(99) + chr(1008 - 897) + '\144' + chr(0b101110 + 0o67))('\x75' + '\x74' + '\146' + chr(0b110 + 0o47) + '\x38'))([xafqLlk3kkUe(SXOLrMavuUCe(b'9\xa9'), chr(2520 - 2420) + chr(0b1100101) + chr(5957 - 5858) + chr(7089 - 6978) + chr(0b111 + 0o135) + chr(9005 - 8904))(chr(0b1010010 + 0o43) + chr(0b111110 + 0o66) + chr(0b1100110) + chr(45) + chr(0b111000)), f'''{_CMRF_PF_yhZ}"type": "{xafqLlk3kkUe(jAj7S20Ct06o, chr(6263 - 6147) + chr(0b1111001) + chr(112) + chr(2196 - 2145))}",\n''' if xafqLlk3kkUe(jAj7S20Ct06o, xafqLlk3kkUe(SXOLrMavuUCe(b'6\xda\x83\x1c'), chr(100) + chr(2871 - 2770) + chr(5244 - 5145) + '\157' + chr(0b1100100) + '\x65')('\x75' + '\x74' + '\146' + chr(0b10001 + 0o34) + chr(56))) else xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(100) + chr(9333 - 9232) + chr(0b101011 + 0o70) + chr(111) + '\144' + chr(101))(chr(117) + chr(5657 - 5541) + '\x66' + '\055' + '\x38'), xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b''), '\144' + chr(0b111000 + 0o55) + chr(0b1100011) + chr(0b1101111) + chr(9424 - 9324) + chr(0b1100101))(chr(6719 - 6602) + '\x74' + '\146' + chr(45) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x1d\xcc\xa4wgi<88\x1b\x06\x00'), '\144' + chr(101) + chr(1573 - 1474) + chr(111) + chr(100) + chr(101))(chr(0b1110101) + chr(0b1110100) + '\146' + '\055' + chr(0b111000)))((Iu6Y2lPjGdmH(N7j7ePTXzzI0, _CMRF_PF_yhZ) for N7j7ePTXzzI0 in xafqLlk3kkUe(jAj7S20Ct06o, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0c\xd9\x85JTGY?:9\x06\x7f'), '\144' + chr(0b1100101) + chr(0b10010 + 0o121) + '\x6f' + chr(746 - 646) + chr(7188 - 7087))(chr(950 - 833) + chr(5076 - 4960) + chr(8053 - 7951) + chr(0b101101) + '\070')))), rxwJk_g4F6Db, xafqLlk3kkUe(SXOLrMavuUCe(b'?\xa9'), '\144' + '\x65' + chr(719 - 620) + chr(111) + chr(0b1101 + 0o127) + chr(6453 - 6352))(chr(0b1110101) + chr(116) + '\146' + chr(45) + '\x38')])
|
allenai/allennlp
|
allennlp/common/configuration.py
|
_render
|
def _render(item: ConfigItem, indent: str = "") -> str:
"""
Render a single config item, with the provided indent
"""
optional = item.default_value != _NO_DEFAULT
if is_configurable(item.annotation):
rendered_annotation = f"{item.annotation} (configurable)"
else:
rendered_annotation = str(item.annotation)
rendered_item = "".join([
# rendered_comment,
indent,
"// " if optional else "",
f'"{item.name}": ',
rendered_annotation,
f" (default: {item.default_value} )" if optional else "",
f" // {item.comment}" if item.comment else "",
"\n"
])
return rendered_item
|
python
|
def _render(item: ConfigItem, indent: str = "") -> str:
"""
Render a single config item, with the provided indent
"""
optional = item.default_value != _NO_DEFAULT
if is_configurable(item.annotation):
rendered_annotation = f"{item.annotation} (configurable)"
else:
rendered_annotation = str(item.annotation)
rendered_item = "".join([
# rendered_comment,
indent,
"// " if optional else "",
f'"{item.name}": ',
rendered_annotation,
f" (default: {item.default_value} )" if optional else "",
f" // {item.comment}" if item.comment else "",
"\n"
])
return rendered_item
|
[
"def",
"_render",
"(",
"item",
":",
"ConfigItem",
",",
"indent",
":",
"str",
"=",
"\"\"",
")",
"->",
"str",
":",
"optional",
"=",
"item",
".",
"default_value",
"!=",
"_NO_DEFAULT",
"if",
"is_configurable",
"(",
"item",
".",
"annotation",
")",
":",
"rendered_annotation",
"=",
"f\"{item.annotation} (configurable)\"",
"else",
":",
"rendered_annotation",
"=",
"str",
"(",
"item",
".",
"annotation",
")",
"rendered_item",
"=",
"\"\"",
".",
"join",
"(",
"[",
"# rendered_comment,",
"indent",
",",
"\"// \"",
"if",
"optional",
"else",
"\"\"",
",",
"f'\"{item.name}\": '",
",",
"rendered_annotation",
",",
"f\" (default: {item.default_value} )\"",
"if",
"optional",
"else",
"\"\"",
",",
"f\" // {item.comment}\"",
"if",
"item",
".",
"comment",
"else",
"\"\"",
",",
"\"\\n\"",
"]",
")",
"return",
"rendered_item"
] |
Render a single config item, with the provided indent
|
[
"Render",
"a",
"single",
"config",
"item",
"with",
"the",
"provided",
"indent"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L355-L377
|
train
|
Render a single config item with the provided indent
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSm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8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + '\x32' + chr(0b110000) + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(111) + chr(499 - 450) + chr(2106 - 2057) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\x6f' + chr(0b11 + 0o56) + chr(2422 - 2367) + chr(0b11000 + 0o36), 32543 - 32535), ehT0Px3KOsy9(chr(654 - 606) + '\x6f' + chr(2487 - 2437) + '\065' + '\x31', 12261 - 12253), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + '\062' + chr(50) + '\x33', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101000 + 0o15) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\064' + '\x31', 8505 - 8497), ehT0Px3KOsy9('\x30' + chr(111) + '\065' + '\063', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101001 + 0o6) + '\x31' + '\x36' + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110111 + 0o70) + chr(0b110010) + chr(0b110111) + '\x31', 0b1000), ehT0Px3KOsy9(chr(284 - 236) + chr(0b10111 + 0o130) + '\062' + chr(0b110110) + '\067', 14398 - 14390), ehT0Px3KOsy9(chr(0b110000) + chr(8540 - 8429) + chr(0b110011) + chr(0b101111 + 0o6) + chr(1306 - 1253), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b110111) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + '\064' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2058 - 1947) + chr(0b110001) + chr(144 - 96) + chr(0b101000 + 0o15), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2211 - 2161) + chr(882 - 827) + chr(0b100100 + 0o16), 0b1000), ehT0Px3KOsy9(chr(2053 - 2005) + chr(0b11001 + 0o126) + chr(2352 - 2301) + '\066' + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b100100 + 0o22) + chr(0b10100 + 0o42), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b11 + 0o154) + chr(49) + chr(0b110100 + 0o1) + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(10290 - 10179) + '\x32' + '\x36', 0b1000), ehT0Px3KOsy9(chr(48) + chr(3420 - 3309) + chr(50) + chr(0b110 + 0o52) + '\060', 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\061' + chr(52) + chr(0b110000 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(1170 - 1122) + chr(0b1101111) + chr(51) + chr(0b11010 + 0o26), 20180 - 20172), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(1929 - 1875) + '\064', 42078 - 42070), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x36' + '\x35', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b1011 + 0o50) + chr(53) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + chr(1956 - 1906) + '\064' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(930 - 879) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(4104 - 3993) + chr(1389 - 1338) + '\x30' + chr(244 - 192), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111111 + 0o60) + '\x32' + '\x30' + '\065', 1142 - 1134), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100000 + 0o21) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\x33' + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x34' + chr(979 - 924), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(3277 - 3166) + chr(464 - 415) + '\062' + chr(53), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(49) + '\066' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10111 + 0o34) + chr(1385 - 1332) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + '\061' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b111 + 0o51) + '\x6f' + chr(1490 - 1440) + '\x33' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(10038 - 9927) + chr(553 - 502) + chr(0b10001 + 0o42) + chr(55), 43206 - 43198), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110010) + chr(516 - 465) + chr(1797 - 1743), 9458 - 9450)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(111) + chr(0b101111 + 0o6) + chr(662 - 614), 51044 - 51036)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa9'), chr(9764 - 9664) + chr(0b1011101 + 0o10) + chr(99) + '\157' + chr(0b1100100) + chr(0b1100101))(chr(9258 - 9141) + '\x74' + chr(0b1100110) + '\x2d' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Iu6Y2lPjGdmH(N7j7ePTXzzI0, rxwJk_g4F6Db=xafqLlk3kkUe(SXOLrMavuUCe(b''), '\x64' + '\x65' + '\x63' + '\x6f' + chr(3916 - 3816) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(102) + '\055' + '\070')) -> M8_cKLkHVB2V:
LfD5WZf72Q8U = N7j7ePTXzzI0.default_value != S5nigsI3n12F
if otsvfwkNz6i8(xafqLlk3kkUe(N7j7ePTXzzI0, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe6!\x10\xc6\xe7L\xd5B\x1f\xd7'), '\144' + chr(4416 - 4315) + '\x63' + chr(0b100001 + 0o116) + chr(100) + chr(101))('\x75' + chr(0b1110100) + '\146' + chr(0b101101) + '\x38'))):
mYSBPqIHXdlG = f'{N7j7ePTXzzI0.annotation} (configurable)'
else:
mYSBPqIHXdlG = M8_cKLkHVB2V(N7j7ePTXzzI0.annotation)
oV5BUdZaHPgt = xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(6848 - 6748) + '\145' + chr(99) + chr(9858 - 9747) + chr(1961 - 1861) + chr(0b101111 + 0o66))(chr(7146 - 7029) + chr(0b1110100) + chr(0b1010011 + 0o23) + '\x2d' + '\x38')._oWXztVNnqHF([rxwJk_g4F6Db, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8`^'), chr(0b1100100) + '\x65' + chr(0b1100011) + chr(111) + '\x64' + '\145')('\165' + '\x74' + chr(0b1100110) + '\055' + '\070') if LfD5WZf72Q8U else xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b100101 + 0o77) + chr(3706 - 3605) + '\143' + chr(111) + chr(100) + chr(0b1100101))('\x75' + chr(0b1110100) + chr(557 - 455) + '\x2d' + chr(2156 - 2100)), f'"{N7j7ePTXzzI0.AIvJRzLdDfgF}": ', mYSBPqIHXdlG, f' (default: {N7j7ePTXzzI0.default_value} )' if LfD5WZf72Q8U else xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + chr(10038 - 9937) + chr(0b110101 + 0o56) + chr(0b110101 + 0o72) + chr(0b1001 + 0o133) + chr(0b1100101))('\165' + chr(0b10010 + 0o142) + chr(102) + chr(0b10100 + 0o31) + chr(0b111000)), f' // {N7j7ePTXzzI0.mUoZPwXPQG1p}' if N7j7ePTXzzI0.mUoZPwXPQG1p else xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(0b1101111) + chr(0b1100100) + '\x65')('\x75' + '\164' + chr(0b10101 + 0o121) + '\055' + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x8d'), chr(100) + chr(1236 - 1135) + chr(0b1100011) + chr(1858 - 1747) + chr(0b1100100) + chr(0b1100101))(chr(0b1110 + 0o147) + '\164' + '\x66' + chr(0b1000 + 0o45) + chr(1865 - 1809))])
return oV5BUdZaHPgt
|
allenai/allennlp
|
allennlp/common/configuration.py
|
_valid_choices
|
def _valid_choices(cla55: type) -> Dict[str, str]:
"""
Return a mapping {registered_name -> subclass_name}
for the registered subclasses of `cla55`.
"""
valid_choices: Dict[str, str] = {}
if cla55 not in Registrable._registry:
raise ValueError(f"{cla55} is not a known Registrable class")
for name, subclass in Registrable._registry[cla55].items():
# These wrapper classes need special treatment
if isinstance(subclass, (_Seq2SeqWrapper, _Seq2VecWrapper)):
subclass = subclass._module_class
valid_choices[name] = full_name(subclass)
return valid_choices
|
python
|
def _valid_choices(cla55: type) -> Dict[str, str]:
"""
Return a mapping {registered_name -> subclass_name}
for the registered subclasses of `cla55`.
"""
valid_choices: Dict[str, str] = {}
if cla55 not in Registrable._registry:
raise ValueError(f"{cla55} is not a known Registrable class")
for name, subclass in Registrable._registry[cla55].items():
# These wrapper classes need special treatment
if isinstance(subclass, (_Seq2SeqWrapper, _Seq2VecWrapper)):
subclass = subclass._module_class
valid_choices[name] = full_name(subclass)
return valid_choices
|
[
"def",
"_valid_choices",
"(",
"cla55",
":",
"type",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"valid_choices",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
"=",
"{",
"}",
"if",
"cla55",
"not",
"in",
"Registrable",
".",
"_registry",
":",
"raise",
"ValueError",
"(",
"f\"{cla55} is not a known Registrable class\"",
")",
"for",
"name",
",",
"subclass",
"in",
"Registrable",
".",
"_registry",
"[",
"cla55",
"]",
".",
"items",
"(",
")",
":",
"# These wrapper classes need special treatment",
"if",
"isinstance",
"(",
"subclass",
",",
"(",
"_Seq2SeqWrapper",
",",
"_Seq2VecWrapper",
")",
")",
":",
"subclass",
"=",
"subclass",
".",
"_module_class",
"valid_choices",
"[",
"name",
"]",
"=",
"full_name",
"(",
"subclass",
")",
"return",
"valid_choices"
] |
Return a mapping {registered_name -> subclass_name}
for the registered subclasses of `cla55`.
|
[
"Return",
"a",
"mapping",
"{",
"registered_name",
"-",
">",
"subclass_name",
"}",
"for",
"the",
"registered",
"subclasses",
"of",
"cla55",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/configuration.py#L427-L444
|
train
|
Returns a mapping from registered_name to subclass_name
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d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jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1660 - 1612) + '\x6f' + chr(0b110001) + chr(52) + chr(0b110110), 47407 - 47399), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + chr(0b110111), 968 - 960), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(5875 - 5764) + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(364 - 315) + '\061' + chr(49), 28269 - 28261), ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + chr(0b110 + 0o55) + '\061' + '\064', 14542 - 14534), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(223 - 175) + chr(0b10001 + 0o136) + chr(0b110011) + chr(0b110000) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(0b101100 + 0o7) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(2184 - 2136) + chr(0b1100101 + 0o12) + '\x32' + chr(0b1011 + 0o52) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(111) + chr(227 - 178) + chr(0b101100 + 0o13) + chr(1271 - 1216), 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(8394 - 8283) + chr(0b11100 + 0o31) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(51) + chr(0b110110) + chr(1894 - 1845), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1100101 + 0o12) + '\061' + '\063' + chr(0b1000 + 0o52), 0b1000), ehT0Px3KOsy9(chr(1317 - 1269) + chr(0b1101111) + chr(0b11 + 0o56) + '\x32' + '\061', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10 + 0o57), 0b1000), ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(111) + chr(2171 - 2122) + chr(0b101000 + 0o14) + chr(50), 44932 - 44924), ehT0Px3KOsy9(chr(48) + '\157' + chr(2204 - 2149) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010111 + 0o30) + chr(0b101111 + 0o2) + chr(0b11 + 0o57) + chr(0b110111), 21224 - 21216), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b11001 + 0o126) + chr(52) + chr(0b1001 + 0o55), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100101 + 0o112) + '\x33' + chr(49) + chr(0b11111 + 0o24), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b111010 + 0o65) + '\x33' + '\061' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + chr(0b100100 + 0o15) + chr(54), 40345 - 40337), ehT0Px3KOsy9('\x30' + chr(0b1010111 + 0o30) + chr(0b110110) + chr(226 - 172), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(51) + chr(0b11100 + 0o27), 0o10), ehT0Px3KOsy9(chr(134 - 86) + chr(0b1101111) + chr(2367 - 2316) + '\065' + chr(723 - 668), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(2024 - 1975) + chr(0b110000) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(947 - 899) + chr(111) + '\x31' + chr(0b110011) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(3701 - 3590) + chr(49) + chr(0b101111 + 0o1) + chr(0b100010 + 0o21), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + '\060' + chr(0b110001 + 0o0), 50860 - 50852), ehT0Px3KOsy9(chr(390 - 342) + chr(111) + chr(1826 - 1777) + chr(0b110000) + chr(0b100010 + 0o22), 8), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(54) + '\x35', 0b1000), ehT0Px3KOsy9(chr(1661 - 1613) + '\157' + chr(0b1110 + 0o44) + '\x32' + chr(50), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(2393 - 2343) + chr(0b11010 + 0o26) + '\x37', 21770 - 21762), ehT0Px3KOsy9(chr(690 - 642) + '\x6f' + '\061' + chr(50) + chr(0b11 + 0o63), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + '\063' + chr(0b100100 + 0o23), 12807 - 12799), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(52) + chr(0b10001 + 0o41), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b100011 + 0o17) + chr(55) + chr(51), 56926 - 56918), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100000 + 0o22) + chr(54) + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110101) + chr(1715 - 1664), 35338 - 35330), ehT0Px3KOsy9(chr(48) + chr(9657 - 9546) + chr(278 - 227) + chr(52) + chr(2126 - 2071), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(917 - 864) + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'H'), chr(5572 - 5472) + chr(101) + chr(0b1100011) + '\157' + '\144' + '\145')('\165' + chr(0b1100000 + 0o24) + chr(0b1100110) + chr(45) + chr(2001 - 1945)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def RhEzktJ84E9X(is9TD1F9z7G2) -> zBnV56fc6HrA[M8_cKLkHVB2V, M8_cKLkHVB2V]:
KPPRVYVRqWZ4 = {}
if is9TD1F9z7G2 not in xafqLlk3kkUe(as4C_9DOd2Yb, xafqLlk3kkUe(SXOLrMavuUCe(b'9ma.\xa5p\xb0)\xd7'), chr(0b1100010 + 0o2) + chr(0b1100101) + '\143' + chr(111) + chr(0b11001 + 0o113) + chr(0b1100101))(chr(0b1110101) + '\x74' + chr(8395 - 8293) + '\x2d' + chr(0b100100 + 0o24))):
raise q1QCh3W88sgk(f'{is9TD1F9z7G2} is not a known Registrable class')
for (AIvJRzLdDfgF, CBZQJD_UO_oZ) in xafqLlk3kkUe(as4C_9DOd2Yb._registry[is9TD1F9z7G2], xafqLlk3kkUe(SXOLrMavuUCe(b'(er,\x85Y\xf7\x12\xc2,g\xc8'), chr(9527 - 9427) + '\x65' + chr(99) + chr(0b1101111) + '\144' + chr(0b1100101))(chr(117) + '\164' + chr(102) + chr(1111 - 1066) + chr(0b111000)))():
if PlSM16l2KDPD(CBZQJD_UO_oZ, (c0_umfUzNurh, N01laGu20PsN)):
CBZQJD_UO_oZ = CBZQJD_UO_oZ._module_class
KPPRVYVRqWZ4[AIvJRzLdDfgF] = je7_3_Zvuq2o(CBZQJD_UO_oZ)
return KPPRVYVRqWZ4
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
url_to_filename
|
def url_to_filename(url: str, etag: str = None) -> str:
"""
Convert `url` into a hashed filename in a repeatable way.
If `etag` is specified, append its hash to the url's, delimited
by a period.
"""
url_bytes = url.encode('utf-8')
url_hash = sha256(url_bytes)
filename = url_hash.hexdigest()
if etag:
etag_bytes = etag.encode('utf-8')
etag_hash = sha256(etag_bytes)
filename += '.' + etag_hash.hexdigest()
return filename
|
python
|
def url_to_filename(url: str, etag: str = None) -> str:
"""
Convert `url` into a hashed filename in a repeatable way.
If `etag` is specified, append its hash to the url's, delimited
by a period.
"""
url_bytes = url.encode('utf-8')
url_hash = sha256(url_bytes)
filename = url_hash.hexdigest()
if etag:
etag_bytes = etag.encode('utf-8')
etag_hash = sha256(etag_bytes)
filename += '.' + etag_hash.hexdigest()
return filename
|
[
"def",
"url_to_filename",
"(",
"url",
":",
"str",
",",
"etag",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"url_bytes",
"=",
"url",
".",
"encode",
"(",
"'utf-8'",
")",
"url_hash",
"=",
"sha256",
"(",
"url_bytes",
")",
"filename",
"=",
"url_hash",
".",
"hexdigest",
"(",
")",
"if",
"etag",
":",
"etag_bytes",
"=",
"etag",
".",
"encode",
"(",
"'utf-8'",
")",
"etag_hash",
"=",
"sha256",
"(",
"etag_bytes",
")",
"filename",
"+=",
"'.'",
"+",
"etag_hash",
".",
"hexdigest",
"(",
")",
"return",
"filename"
] |
Convert `url` into a hashed filename in a repeatable way.
If `etag` is specified, append its hash to the url's, delimited
by a period.
|
[
"Convert",
"url",
"into",
"a",
"hashed",
"filename",
"in",
"a",
"repeatable",
"way",
".",
"If",
"etag",
"is",
"specified",
"append",
"its",
"hash",
"to",
"the",
"url",
"s",
"delimited",
"by",
"a",
"period",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L39-L54
|
train
|
Convert a url into a hashed filename in a repeatable way.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6r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,QC9iu2kLpS8s,QOfmzcVJsrp8,tzcpInYwBvYW,iDQ_gSK8V7h0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10110 + 0o33) + chr(48) + chr(48), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(2515 - 2460) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b101111 + 0o100) + chr(0b101100 + 0o6) + '\066' + chr(2024 - 1973), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(737 - 684) + chr(0b110111), 43524 - 43516), ehT0Px3KOsy9(chr(48) + '\157' + chr(50) + '\062' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100011 + 0o16) + '\066', 53771 - 53763), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1100 + 0o143) + '\061' + chr(0b110011) + '\066', 0o10), ehT0Px3KOsy9(chr(2200 - 2152) + '\x6f' + chr(2042 - 1991) + '\x37' + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\062' + chr(0b101001 + 0o15) + chr(1581 - 1532), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10001 + 0o42) + '\x36' + '\x31', 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\157' + '\x33' + '\062' + chr(1244 - 1195), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101110 + 0o4) + '\x32' + chr(54), 30572 - 30564), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b101010 + 0o105) + chr(0b110001) + chr(917 - 864) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(606 - 558) + chr(111) + '\062' + chr(0b10111 + 0o34) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(1700 - 1649) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(1817 - 1766) + chr(54) + chr(1047 - 996), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11011 + 0o30) + '\x35', 22126 - 22118), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10101 + 0o35) + chr(2229 - 2180) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(0b1101111) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1350 - 1302) + chr(111) + chr(49) + chr(2722 - 2668) + '\063', 8462 - 8454), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b1101111) + '\062' + chr(0b110100) + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + '\061' + chr(0b101 + 0o54), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + '\x34' + '\065', ord("\x08")), ehT0Px3KOsy9(chr(1797 - 1749) + chr(4514 - 4403) + chr(2370 - 2320) + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b10 + 0o155) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1245 - 1196) + '\x34' + chr(50), 0b1000), ehT0Px3KOsy9(chr(340 - 292) + chr(0b1101111) + chr(1860 - 1809) + chr(165 - 117) + '\x36', 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(1318 - 1270) + '\x35', 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110001) + chr(0b111 + 0o55) + chr(0b110100), 39701 - 39693), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100111 + 0o13) + chr(0b110110) + chr(49), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(126 - 76) + chr(106 - 55) + chr(0b110010), 0b1000), ehT0Px3KOsy9('\060' + chr(450 - 339) + '\062' + chr(0b110000), 29886 - 29878), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + chr(0b10011 + 0o42) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b1101111) + chr(0b110010) + '\x35' + '\x36', 34233 - 34225), ehT0Px3KOsy9(chr(0b110000) + chr(9940 - 9829) + '\x31' + chr(0b101000 + 0o17) + chr(52), 47283 - 47275), ehT0Px3KOsy9('\x30' + chr(111) + chr(283 - 234) + chr(752 - 699) + chr(0b110000), 8), ehT0Px3KOsy9('\x30' + '\157' + '\066' + chr(0b101010 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(1105 - 1057) + chr(111) + '\064' + chr(908 - 853), 22001 - 21993), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110110) + '\x37', 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\x6f' + chr(0b110010) + chr(0b101011 + 0o5) + '\x32', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1929 - 1876) + chr(48), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'n'), chr(100) + '\x65' + chr(3719 - 3620) + chr(592 - 481) + chr(0b0 + 0o144) + '\x65')(chr(10141 - 10024) + '\164' + '\x66' + chr(45) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def lXDzoYHIOVOO(CYCr3xzMHl4K, RwOST2AT9ncg=None) -> M8_cKLkHVB2V:
XzDRQXjrB3QA = CYCr3xzMHl4K.encode(xafqLlk3kkUe(SXOLrMavuUCe(b'5J\xd5\x02\xa8'), chr(100) + chr(0b1100101) + chr(0b111000 + 0o53) + chr(111) + chr(100) + chr(3382 - 3281))(chr(1429 - 1312) + '\x74' + chr(0b110001 + 0o65) + chr(0b11111 + 0o16) + '\070'))
FyWLknOUbAe3 = dpMEy1fTMRvs(XzDRQXjrB3QA)
xw4DsBfIJ22E = FyWLknOUbAe3.hexdigest()
if RwOST2AT9ncg:
L2km5WjcE7kv = RwOST2AT9ncg.encode(xafqLlk3kkUe(SXOLrMavuUCe(b'5J\xd5\x02\xa8'), chr(0b1100100) + chr(101) + '\x63' + chr(0b1101111) + chr(100) + '\x65')(chr(6453 - 6336) + chr(0b1110100) + '\146' + chr(0b101101) + '\070'))
mnqFMCx4RObg = dpMEy1fTMRvs(L2km5WjcE7kv)
xw4DsBfIJ22E += xafqLlk3kkUe(SXOLrMavuUCe(b'n'), chr(0b1100100) + chr(6006 - 5905) + chr(1836 - 1737) + '\x6f' + chr(7840 - 7740) + chr(6796 - 6695))(chr(0b1010101 + 0o40) + chr(0b1110100) + chr(0b1100110) + chr(45) + '\x38') + mnqFMCx4RObg.hexdigest()
return xw4DsBfIJ22E
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
filename_to_url
|
def filename_to_url(filename: str, cache_dir: str = None) -> Tuple[str, str]:
"""
Return the url and etag (which may be ``None``) stored for `filename`.
Raise ``FileNotFoundError`` if `filename` or its stored metadata do not exist.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
cache_path = os.path.join(cache_dir, filename)
if not os.path.exists(cache_path):
raise FileNotFoundError("file {} not found".format(cache_path))
meta_path = cache_path + '.json'
if not os.path.exists(meta_path):
raise FileNotFoundError("file {} not found".format(meta_path))
with open(meta_path) as meta_file:
metadata = json.load(meta_file)
url = metadata['url']
etag = metadata['etag']
return url, etag
|
python
|
def filename_to_url(filename: str, cache_dir: str = None) -> Tuple[str, str]:
"""
Return the url and etag (which may be ``None``) stored for `filename`.
Raise ``FileNotFoundError`` if `filename` or its stored metadata do not exist.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
cache_path = os.path.join(cache_dir, filename)
if not os.path.exists(cache_path):
raise FileNotFoundError("file {} not found".format(cache_path))
meta_path = cache_path + '.json'
if not os.path.exists(meta_path):
raise FileNotFoundError("file {} not found".format(meta_path))
with open(meta_path) as meta_file:
metadata = json.load(meta_file)
url = metadata['url']
etag = metadata['etag']
return url, etag
|
[
"def",
"filename_to_url",
"(",
"filename",
":",
"str",
",",
"cache_dir",
":",
"str",
"=",
"None",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"if",
"cache_dir",
"is",
"None",
":",
"cache_dir",
"=",
"CACHE_DIRECTORY",
"cache_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cache_path",
")",
":",
"raise",
"FileNotFoundError",
"(",
"\"file {} not found\"",
".",
"format",
"(",
"cache_path",
")",
")",
"meta_path",
"=",
"cache_path",
"+",
"'.json'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"meta_path",
")",
":",
"raise",
"FileNotFoundError",
"(",
"\"file {} not found\"",
".",
"format",
"(",
"meta_path",
")",
")",
"with",
"open",
"(",
"meta_path",
")",
"as",
"meta_file",
":",
"metadata",
"=",
"json",
".",
"load",
"(",
"meta_file",
")",
"url",
"=",
"metadata",
"[",
"'url'",
"]",
"etag",
"=",
"metadata",
"[",
"'etag'",
"]",
"return",
"url",
",",
"etag"
] |
Return the url and etag (which may be ``None``) stored for `filename`.
Raise ``FileNotFoundError`` if `filename` or its stored metadata do not exist.
|
[
"Return",
"the",
"url",
"and",
"etag",
"(",
"which",
"may",
"be",
"None",
")",
"stored",
"for",
"filename",
".",
"Raise",
"FileNotFoundError",
"if",
"filename",
"or",
"its",
"stored",
"metadata",
"do",
"not",
"exist",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L57-L78
|
train
|
Return the url and etag for a given filename.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HP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3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110001) + chr(671 - 620) + '\063', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001 + 0o146) + chr(1019 - 969) + chr(49) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b111101 + 0o62) + chr(0b110010) + chr(0b10001 + 0o42) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(402 - 354) + chr(1734 - 1623) + chr(595 - 546) + '\066' + chr(968 - 918), 0b1000), ehT0Px3KOsy9(chr(270 - 222) + chr(1616 - 1505) + chr(0b110011) + chr(0b111 + 0o55) + chr(1856 - 1806), 58363 - 58355), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(0b100001 + 0o21) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b101010 + 0o7) + '\063' + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x33' + chr(2167 - 2113), 0b1000), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + chr(0b11000 + 0o31) + chr(947 - 897) + '\x34', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\063' + '\x33' + chr(0b101101 + 0o5), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1001000 + 0o47) + chr(0b110001) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(0b111011 + 0o64) + chr(0b110111) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1193 - 1140) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(0b1101111) + chr(0b101000 + 0o13) + chr(0b11010 + 0o34) + '\066', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(1009 - 960) + chr(1517 - 1463) + chr(0b110011 + 0o0), 40105 - 40097), ehT0Px3KOsy9(chr(1282 - 1234) + chr(10443 - 10332) + chr(51) + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + '\061' + chr(48) + '\x31', 0b1000), ehT0Px3KOsy9(chr(2260 - 2212) + chr(2641 - 2530) + chr(0b110001) + '\061' + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b101000 + 0o107) + chr(714 - 660) + '\x35', 0b1000), ehT0Px3KOsy9(chr(1355 - 1307) + chr(111) + chr(49) + chr(2484 - 2433), 0b1000), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + chr(1835 - 1785) + '\x37' + chr(2008 - 1955), 0b1000), ehT0Px3KOsy9(chr(1126 - 1078) + chr(0b1101111) + chr(0b110010) + '\x33' + chr(2026 - 1971), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + chr(0b110010) + '\064', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\061' + chr(319 - 269) + chr(2189 - 2137), 8), ehT0Px3KOsy9('\x30' + chr(12286 - 12175) + chr(54) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(1379 - 1331) + '\x6f' + chr(49) + chr(298 - 248) + chr(84 - 31), 10805 - 10797), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1166 - 1117) + '\063' + chr(50), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b11110 + 0o121) + '\066' + chr(1183 - 1132), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(50), 0b1000), ehT0Px3KOsy9(chr(1031 - 983) + '\x6f' + '\x34' + chr(0b100110 + 0o17), 740 - 732), ehT0Px3KOsy9(chr(2071 - 2023) + '\157' + '\x37' + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(111) + '\062' + chr(0b110010 + 0o1) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\061' + chr(54) + chr(0b11111 + 0o26), 0o10), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(0b101000 + 0o12) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1851 - 1803) + chr(111) + chr(0b110001 + 0o2) + chr(0b10110 + 0o35) + '\x31', 10513 - 10505), ehT0Px3KOsy9(chr(435 - 387) + chr(0b1101111) + chr(1786 - 1737) + chr(50), 0b1000), ehT0Px3KOsy9('\060' + chr(3135 - 3024) + chr(50) + '\x31', 52972 - 52964), ehT0Px3KOsy9('\x30' + chr(0b111010 + 0o65) + chr(49) + chr(0b110011) + '\060', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10110 + 0o35) + chr(49), 0b1000), ehT0Px3KOsy9(chr(1945 - 1897) + chr(6257 - 6146) + '\061' + chr(0b110001) + chr(511 - 462), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1011 + 0o45) + chr(8645 - 8534) + '\x35' + '\060', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'u'), chr(0b1010111 + 0o15) + chr(0b1100101) + '\x63' + '\157' + chr(4781 - 4681) + chr(0b1100101))(chr(117) + '\x74' + chr(102) + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def n_uxU4ePMVnF(xw4DsBfIJ22E, j3fmOtvUtrP5=None) -> MRK8Uzg2En3D[M8_cKLkHVB2V, M8_cKLkHVB2V]:
if j3fmOtvUtrP5 is None:
j3fmOtvUtrP5 = WQgeKIRObRPj
WYuPioNR_sqI = oqhJDdMJfuwx.path._oWXztVNnqHF(j3fmOtvUtrP5, xw4DsBfIJ22E)
if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'>\xf3\xf3\x01\x96"'), chr(100) + '\x65' + chr(0b1011001 + 0o12) + chr(111) + '\144' + chr(4212 - 4111))(chr(0b100000 + 0o125) + chr(0b10001 + 0o143) + chr(0b1100110) + '\055' + chr(0b111000)))(WYuPioNR_sqI):
raise oNamnshN4dFG(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'=\xe2\xf6\x17\xc2*$>:\xb5y\x1bK\x99\x06s%'), chr(100) + '\x65' + '\143' + chr(0b11110 + 0o121) + '\144' + chr(5829 - 5728))(chr(0b1000111 + 0o56) + '\x74' + '\146' + chr(944 - 899) + '\x38'), xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xbf\xe8\x1d\xaa0\n-\x04\xaahQ'), chr(0b10000 + 0o124) + chr(101) + '\x63' + chr(7241 - 7130) + chr(0b1100100) + '\145')(chr(8271 - 8154) + chr(0b1100111 + 0o15) + chr(8955 - 8853) + chr(45) + chr(0b111000)))(WYuPioNR_sqI))
EnlLcM0uvHG1 = WYuPioNR_sqI + xafqLlk3kkUe(SXOLrMavuUCe(b'u\xe1\xe9\x1d\x8c'), chr(0b1001011 + 0o31) + chr(101) + chr(5169 - 5070) + chr(7556 - 7445) + chr(8407 - 8307) + '\x65')(chr(0b1000000 + 0o65) + chr(2351 - 2235) + '\x66' + '\055' + chr(2865 - 2809))
if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'>\xf3\xf3\x01\x96"'), '\144' + '\x65' + chr(0b110110 + 0o55) + chr(4637 - 4526) + chr(100) + chr(0b1100101))('\165' + chr(0b1110100) + chr(0b1001 + 0o135) + chr(0b100110 + 0o7) + '\070'))(EnlLcM0uvHG1):
raise oNamnshN4dFG(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'=\xe2\xf6\x17\xc2*$>:\xb5y\x1bK\x99\x06s%'), '\x64' + '\145' + chr(99) + chr(9237 - 9126) + chr(0b1 + 0o143) + chr(0b1100101))(chr(117) + '\x74' + '\146' + '\055' + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'\r\xbf\xe8\x1d\xaa0\n-\x04\xaahQ'), chr(1306 - 1206) + '\x65' + chr(3465 - 3366) + '\157' + '\x64' + chr(101))(chr(8080 - 7963) + '\164' + chr(0b11010 + 0o114) + chr(0b101101) + chr(56)))(EnlLcM0uvHG1))
with _fwkIVCGgtAN(EnlLcM0uvHG1) as bA1zw91Kxflm:
mU7wOAGoTnlM = fXk443epxtd5.mxtdQMeiwJZJ(bA1zw91Kxflm)
CYCr3xzMHl4K = mU7wOAGoTnlM[xafqLlk3kkUe(SXOLrMavuUCe(b'.\xf9\xf6'), chr(0b1100100) + chr(0b1100101) + chr(7929 - 7830) + chr(7292 - 7181) + chr(0b1000000 + 0o44) + chr(0b1000111 + 0o36))(chr(0b1001 + 0o154) + '\x74' + '\x66' + chr(45) + chr(2274 - 2218))]
RwOST2AT9ncg = mU7wOAGoTnlM[xafqLlk3kkUe(SXOLrMavuUCe(b'>\xff\xfb\x15'), chr(0b1100100) + '\x65' + '\x63' + chr(9980 - 9869) + '\144' + chr(0b1010011 + 0o22))('\165' + chr(3599 - 3483) + '\x66' + chr(0b101101) + chr(0b111000))]
return (CYCr3xzMHl4K, RwOST2AT9ncg)
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
cached_path
|
def cached_path(url_or_filename: Union[str, Path], cache_dir: str = None) -> str:
"""
Given something that might be a URL (or might be a local path),
determine which. If it's a URL, download the file and cache it, and
return the path to the cached file. If it's already a local path,
make sure the file exists and then return the path.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
if isinstance(url_or_filename, Path):
url_or_filename = str(url_or_filename)
url_or_filename = os.path.expanduser(url_or_filename)
parsed = urlparse(url_or_filename)
if parsed.scheme in ('http', 'https', 's3'):
# URL, so get it from the cache (downloading if necessary)
return get_from_cache(url_or_filename, cache_dir)
elif os.path.exists(url_or_filename):
# File, and it exists.
return url_or_filename
elif parsed.scheme == '':
# File, but it doesn't exist.
raise FileNotFoundError("file {} not found".format(url_or_filename))
else:
# Something unknown
raise ValueError("unable to parse {} as a URL or as a local path".format(url_or_filename))
|
python
|
def cached_path(url_or_filename: Union[str, Path], cache_dir: str = None) -> str:
"""
Given something that might be a URL (or might be a local path),
determine which. If it's a URL, download the file and cache it, and
return the path to the cached file. If it's already a local path,
make sure the file exists and then return the path.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
if isinstance(url_or_filename, Path):
url_or_filename = str(url_or_filename)
url_or_filename = os.path.expanduser(url_or_filename)
parsed = urlparse(url_or_filename)
if parsed.scheme in ('http', 'https', 's3'):
# URL, so get it from the cache (downloading if necessary)
return get_from_cache(url_or_filename, cache_dir)
elif os.path.exists(url_or_filename):
# File, and it exists.
return url_or_filename
elif parsed.scheme == '':
# File, but it doesn't exist.
raise FileNotFoundError("file {} not found".format(url_or_filename))
else:
# Something unknown
raise ValueError("unable to parse {} as a URL or as a local path".format(url_or_filename))
|
[
"def",
"cached_path",
"(",
"url_or_filename",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
",",
"cache_dir",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"if",
"cache_dir",
"is",
"None",
":",
"cache_dir",
"=",
"CACHE_DIRECTORY",
"if",
"isinstance",
"(",
"url_or_filename",
",",
"Path",
")",
":",
"url_or_filename",
"=",
"str",
"(",
"url_or_filename",
")",
"url_or_filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"url_or_filename",
")",
"parsed",
"=",
"urlparse",
"(",
"url_or_filename",
")",
"if",
"parsed",
".",
"scheme",
"in",
"(",
"'http'",
",",
"'https'",
",",
"'s3'",
")",
":",
"# URL, so get it from the cache (downloading if necessary)",
"return",
"get_from_cache",
"(",
"url_or_filename",
",",
"cache_dir",
")",
"elif",
"os",
".",
"path",
".",
"exists",
"(",
"url_or_filename",
")",
":",
"# File, and it exists.",
"return",
"url_or_filename",
"elif",
"parsed",
".",
"scheme",
"==",
"''",
":",
"# File, but it doesn't exist.",
"raise",
"FileNotFoundError",
"(",
"\"file {} not found\"",
".",
"format",
"(",
"url_or_filename",
")",
")",
"else",
":",
"# Something unknown",
"raise",
"ValueError",
"(",
"\"unable to parse {} as a URL or as a local path\"",
".",
"format",
"(",
"url_or_filename",
")",
")"
] |
Given something that might be a URL (or might be a local path),
determine which. If it's a URL, download the file and cache it, and
return the path to the cached file. If it's already a local path,
make sure the file exists and then return the path.
|
[
"Given",
"something",
"that",
"might",
"be",
"a",
"URL",
"(",
"or",
"might",
"be",
"a",
"local",
"path",
")",
"determine",
"which",
".",
"If",
"it",
"s",
"a",
"URL",
"download",
"the",
"file",
"and",
"cache",
"it",
"and",
"return",
"the",
"path",
"to",
"the",
"cached",
"file",
".",
"If",
"it",
"s",
"already",
"a",
"local",
"path",
"make",
"sure",
"the",
"file",
"exists",
"and",
"then",
"return",
"the",
"path",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L81-L107
|
train
|
Given something that might be a URL or a local path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RZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\x35', 35730 - 35722), ehT0Px3KOsy9('\x30' + '\157' + chr(49) + '\x31' + chr(343 - 294), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110010) + chr(53) + chr(49), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1011011 + 0o24) + '\x31' + '\x31' + '\066', 57421 - 57413), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b1101111) + chr(50) + '\063' + chr(53), 25965 - 25957), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100111 + 0o12) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1250 - 1200) + chr(0b100110 + 0o13), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b111 + 0o53) + chr(52) + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(1962 - 1911) + chr(0b100101 + 0o15) + chr(1671 - 1617), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b1101111) + chr(0b110001 + 0o6) + '\062', 57294 - 57286), ehT0Px3KOsy9('\060' + chr(8858 - 8747) + chr(327 - 278) + chr(1287 - 1237) + '\065', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10010 + 0o37) + chr(0b101011 + 0o14), 8), ehT0Px3KOsy9(chr(48) + chr(10326 - 10215) + '\x37' + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + '\x32' + chr(50) + chr(0b100101 + 0o15), 25815 - 25807), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + '\x33', 0b1000), ehT0Px3KOsy9(chr(993 - 945) + chr(111) + chr(0b110001) + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(609 - 557) + chr(0b100111 + 0o17), 58328 - 58320), ehT0Px3KOsy9('\060' + chr(8382 - 8271) + '\x33' + '\066' + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\x33' + chr(1732 - 1679) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(10122 - 10011) + '\061' + '\x37' + '\061', 42339 - 42331), ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\061' + '\x33' + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(2938 - 2827) + chr(57 - 7) + chr(54) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(111) + '\x36' + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(48) + chr(6862 - 6751) + chr(0b10110 + 0o35) + chr(0b110000) + chr(48), 59271 - 59263), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1111 + 0o42) + chr(50) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b0 + 0o157) + chr(0b10 + 0o60) + '\066' + '\x35', 0b1000), ehT0Px3KOsy9(chr(1020 - 972) + '\x6f' + chr(54) + '\066', ord("\x08")), ehT0Px3KOsy9(chr(2250 - 2202) + '\157' + chr(51) + '\065' + chr(0b110110), 7359 - 7351), ehT0Px3KOsy9('\060' + chr(0b100001 + 0o116) + chr(0b110001) + '\x35' + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x33' + '\x33' + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(398 - 350) + '\x6f' + chr(0b110010) + chr(834 - 779), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1000 - 951) + '\x37' + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(111) + chr(0b110010) + '\x32' + '\063', 41896 - 41888), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101011 + 0o10) + '\x37' + chr(1013 - 964), 3127 - 3119), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + '\x36' + chr(0b100111 + 0o12), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b111110 + 0o61) + chr(0b110001) + '\x36' + chr(871 - 817), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1100011 + 0o14) + chr(402 - 352) + chr(49) + '\060', 62509 - 62501), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(0b100000 + 0o23) + chr(0b11011 + 0o27), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(0b110010) + chr(0b110011), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b101110 + 0o101) + chr(53) + '\060', ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b';'), chr(3674 - 3574) + '\145' + chr(0b1011010 + 0o11) + chr(1361 - 1250) + chr(0b1100100) + chr(101))(chr(0b1011110 + 0o27) + chr(116) + '\146' + chr(45) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def MygwJnRV_fCw(Q611RMiIRsPE, j3fmOtvUtrP5=None) -> M8_cKLkHVB2V:
if j3fmOtvUtrP5 is None:
j3fmOtvUtrP5 = WQgeKIRObRPj
if PlSM16l2KDPD(Q611RMiIRsPE, HiPOQr0Cdorg):
Q611RMiIRsPE = M8_cKLkHVB2V(Q611RMiIRsPE)
Q611RMiIRsPE = oqhJDdMJfuwx.path.expanduser(Q611RMiIRsPE)
QIe124s5EFAg = P8lnsClJdUFG(Q611RMiIRsPE)
if xafqLlk3kkUe(QIe124s5EFAg, xafqLlk3kkUe(SXOLrMavuUCe(b'f*\xc1+\xf0j'), '\144' + chr(4222 - 4121) + '\143' + chr(111) + '\144' + chr(1911 - 1810))('\165' + '\x74' + '\x66' + chr(45) + '\x38')) in (xafqLlk3kkUe(SXOLrMavuUCe(b'}=\xdd>'), chr(5082 - 4982) + '\x65' + chr(0b11011 + 0o110) + '\157' + chr(0b100100 + 0o100) + chr(0b1100101))(chr(0b1110101) + chr(8149 - 8033) + '\x66' + chr(0b11011 + 0o22) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'}=\xdd>\xee'), chr(0b1100100) + '\145' + '\143' + '\157' + '\144' + '\x65')(chr(117) + chr(0b1110100) + chr(0b1100110) + chr(1701 - 1656) + chr(1968 - 1912)), xafqLlk3kkUe(SXOLrMavuUCe(b'fz'), '\144' + chr(0b11 + 0o142) + '\x63' + '\157' + chr(2912 - 2812) + '\x65')(chr(9956 - 9839) + '\x74' + '\x66' + chr(45) + '\070')):
return eszr0um5F1Px(Q611RMiIRsPE, j3fmOtvUtrP5)
elif xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'p1\xc0=\xe9|'), '\144' + '\x65' + '\x63' + chr(2473 - 2362) + '\144' + '\x65')('\x75' + chr(0b1110100) + '\x66' + chr(0b11010 + 0o23) + chr(2280 - 2224)))(Q611RMiIRsPE):
return Q611RMiIRsPE
elif xafqLlk3kkUe(QIe124s5EFAg, xafqLlk3kkUe(SXOLrMavuUCe(b'f*\xc1+\xf0j'), chr(0b100111 + 0o75) + '\145' + chr(0b1100011) + chr(8956 - 8845) + chr(0b1010100 + 0o20) + chr(0b1001000 + 0o35))(chr(117) + chr(116) + chr(0b1001001 + 0o35) + chr(0b101101) + chr(0b111000))) == xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + chr(101) + chr(99) + chr(111) + chr(0b1010000 + 0o24) + chr(0b1001011 + 0o32))(chr(0b1110101) + '\x74' + chr(102) + chr(45) + '\070'):
raise oNamnshN4dFG(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b's \xc5+\xbdtl\x82\xb8U!/^\xfdnaB'), chr(0b1100100) + chr(0b1010010 + 0o23) + chr(99) + chr(0b1101111) + chr(100) + chr(4143 - 4042))(chr(0b1100100 + 0o21) + chr(0b1110100) + '\x66' + chr(1520 - 1475) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'C}\xdb!\xd5nB\x91\x86J0e'), '\144' + chr(421 - 320) + chr(0b1010001 + 0o22) + chr(0b100011 + 0o114) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(0b111001 + 0o73) + chr(102) + chr(0b101101) + '\070'))(Q611RMiIRsPE))
else:
raise q1QCh3W88sgk(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b"`'\xc8,\xf1j1\xd6\xb9\x1a%nJ\xe1~/]\x8e\xcc\x18(\x97P\x0c\x95\x06\xf9\x16\x81\x1d\xf8v\t\xb3\x98\x91\x1a\xe7\xf92yi\xd9/\xe9g"), '\x64' + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(100) + chr(7782 - 7681))(chr(8352 - 8235) + chr(5035 - 4919) + chr(102) + chr(0b101101) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'C}\xdb!\xd5nB\x91\x86J0e'), chr(0b1100100) + chr(1787 - 1686) + chr(7958 - 7859) + '\x6f' + '\144' + '\x65')(chr(8676 - 8559) + chr(6439 - 6323) + chr(102) + chr(0b101100 + 0o1) + '\070'))(Q611RMiIRsPE))
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
is_url_or_existing_file
|
def is_url_or_existing_file(url_or_filename: Union[str, Path, None]) -> bool:
"""
Given something that might be a URL (or might be a local path),
determine check if it's url or an existing file path.
"""
if url_or_filename is None:
return False
url_or_filename = os.path.expanduser(str(url_or_filename))
parsed = urlparse(url_or_filename)
return parsed.scheme in ('http', 'https', 's3') or os.path.exists(url_or_filename)
|
python
|
def is_url_or_existing_file(url_or_filename: Union[str, Path, None]) -> bool:
"""
Given something that might be a URL (or might be a local path),
determine check if it's url or an existing file path.
"""
if url_or_filename is None:
return False
url_or_filename = os.path.expanduser(str(url_or_filename))
parsed = urlparse(url_or_filename)
return parsed.scheme in ('http', 'https', 's3') or os.path.exists(url_or_filename)
|
[
"def",
"is_url_or_existing_file",
"(",
"url_or_filename",
":",
"Union",
"[",
"str",
",",
"Path",
",",
"None",
"]",
")",
"->",
"bool",
":",
"if",
"url_or_filename",
"is",
"None",
":",
"return",
"False",
"url_or_filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"str",
"(",
"url_or_filename",
")",
")",
"parsed",
"=",
"urlparse",
"(",
"url_or_filename",
")",
"return",
"parsed",
".",
"scheme",
"in",
"(",
"'http'",
",",
"'https'",
",",
"'s3'",
")",
"or",
"os",
".",
"path",
".",
"exists",
"(",
"url_or_filename",
")"
] |
Given something that might be a URL (or might be a local path),
determine check if it's url or an existing file path.
|
[
"Given",
"something",
"that",
"might",
"be",
"a",
"URL",
"(",
"or",
"might",
"be",
"a",
"local",
"path",
")",
"determine",
"check",
"if",
"it",
"s",
"url",
"or",
"an",
"existing",
"file",
"path",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L109-L118
|
train
|
Determines if a URL or an existing file path.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTEN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8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + '\x31' + chr(0b110101), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1000000 + 0o57) + chr(51) + chr(0b110100) + chr(0b100 + 0o57), 31764 - 31756), ehT0Px3KOsy9(chr(2096 - 2048) + '\x6f' + chr(0b110101) + chr(0b10110 + 0o37), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + '\x31' + chr(0b10011 + 0o40), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b110111) + '\065', 0o10), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(111) + '\x33' + chr(908 - 860) + chr(0b100010 + 0o25), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b100101 + 0o16) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b111100 + 0o63) + chr(0b110100) + chr(0b10111 + 0o32), 12035 - 12027), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b100001 + 0o116) + '\061' + '\x33' + chr(55), 8396 - 8388), ehT0Px3KOsy9(chr(2043 - 1995) + chr(0b1101111) + '\x33' + '\x35' + chr(0b100100 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6471 - 6360) + '\x31' + '\066' + '\x31', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(1356 - 1307) + chr(50) + chr(0b11 + 0o60), ord("\x08")), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(111) + '\061' + chr(0b110010) + chr(0b101000 + 0o17), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(0b100110 + 0o13) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\064' + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + '\064' + '\x31', 19146 - 19138), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + '\067' + chr(0b10000 + 0o42), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100 + 0o60) + chr(52), 19416 - 19408), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(1108 - 1060) + chr(0b1101111) + chr(0b110010) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\063' + '\x31', 0o10), ehT0Px3KOsy9('\x30' + chr(4120 - 4009) + '\x33' + chr(0b110111) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b100 + 0o153) + chr(0b100101 + 0o14) + chr(0b10001 + 0o42) + chr(0b100011 + 0o20), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b11011 + 0o124) + chr(49) + '\063' + chr(0b110111), 8), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\157' + chr(0b101101 + 0o4) + '\067' + chr(0b100100 + 0o14), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b10101 + 0o34) + '\x33' + chr(0b100000 + 0o23), 8), ehT0Px3KOsy9('\x30' + '\157' + '\066' + chr(0b11111 + 0o22), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1720 - 1670) + '\x37' + chr(0b100110 + 0o12), 0o10), ehT0Px3KOsy9(chr(48) + chr(8120 - 8009) + chr(0b10100 + 0o35) + chr(390 - 342) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + '\x31' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(111) + chr(1526 - 1476) + '\x33' + chr(1315 - 1263), 46545 - 46537), ehT0Px3KOsy9(chr(812 - 764) + chr(0b110100 + 0o73) + '\x33' + '\x32' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\066' + '\064', 35240 - 35232), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + chr(0b10110 + 0o35) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + chr(0b110001) + chr(1745 - 1690) + '\061', 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + chr(638 - 589) + '\x33', 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11010 + 0o30) + '\064' + '\067', 0b1000), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\157' + chr(0b11110 + 0o26) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1010101 + 0o32) + chr(0b10111 + 0o40) + chr(0b101111 + 0o2), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1100 + 0o44) + chr(0b110101 + 0o72) + '\065' + '\060', 56898 - 56890)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'c'), chr(0b111001 + 0o53) + chr(0b1100101) + '\143' + chr(111) + chr(0b11111 + 0o105) + chr(0b1100101))(chr(117) + chr(116) + chr(0b1100100 + 0o2) + '\x2d' + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def rq8_KWxeMlUv(Q611RMiIRsPE) -> WbBjf8Y7v9VN:
if Q611RMiIRsPE is None:
return ehT0Px3KOsy9('\060' + '\x6f' + '\x30', 11693 - 11685)
Q611RMiIRsPE = oqhJDdMJfuwx.path.expanduser(M8_cKLkHVB2V(Q611RMiIRsPE))
QIe124s5EFAg = P8lnsClJdUFG(Q611RMiIRsPE)
return xafqLlk3kkUe(QIe124s5EFAg, xafqLlk3kkUe(SXOLrMavuUCe(b'>\x80E\xae\xd0\xa2'), chr(0b1100100) + '\x65' + '\143' + chr(0b1 + 0o156) + chr(1757 - 1657) + chr(101))(chr(0b100111 + 0o116) + chr(0b1110100) + chr(102) + chr(45) + chr(0b111000))) in (xafqLlk3kkUe(SXOLrMavuUCe(b'%\x97Y\xbb'), chr(0b100001 + 0o103) + '\x65' + '\x63' + chr(6421 - 6310) + chr(0b1100100) + '\x65')(chr(10508 - 10391) + chr(0b1110100) + '\x66' + '\x2d' + chr(2224 - 2168)), xafqLlk3kkUe(SXOLrMavuUCe(b'%\x97Y\xbb\xce'), chr(695 - 595) + chr(4584 - 4483) + chr(601 - 502) + chr(111) + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(116) + chr(6993 - 6891) + chr(0b100001 + 0o14) + chr(0b111000)), xafqLlk3kkUe(SXOLrMavuUCe(b'>\xd0'), '\x64' + '\145' + chr(0b110001 + 0o62) + '\157' + '\144' + chr(101))(chr(0b101001 + 0o114) + chr(0b1110100) + chr(0b111 + 0o137) + chr(0b101101) + '\x38')) or xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'(\x9bD\xb8\xc9\xb4'), chr(0b11110 + 0o106) + '\x65' + chr(0b110010 + 0o61) + chr(111) + '\x64' + chr(101))(chr(0b100000 + 0o125) + chr(0b1101100 + 0o10) + '\x66' + '\055' + '\x38'))(Q611RMiIRsPE)
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
split_s3_path
|
def split_s3_path(url: str) -> Tuple[str, str]:
"""Split a full s3 path into the bucket name and path."""
parsed = urlparse(url)
if not parsed.netloc or not parsed.path:
raise ValueError("bad s3 path {}".format(url))
bucket_name = parsed.netloc
s3_path = parsed.path
# Remove '/' at beginning of path.
if s3_path.startswith("/"):
s3_path = s3_path[1:]
return bucket_name, s3_path
|
python
|
def split_s3_path(url: str) -> Tuple[str, str]:
"""Split a full s3 path into the bucket name and path."""
parsed = urlparse(url)
if not parsed.netloc or not parsed.path:
raise ValueError("bad s3 path {}".format(url))
bucket_name = parsed.netloc
s3_path = parsed.path
# Remove '/' at beginning of path.
if s3_path.startswith("/"):
s3_path = s3_path[1:]
return bucket_name, s3_path
|
[
"def",
"split_s3_path",
"(",
"url",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"if",
"not",
"parsed",
".",
"netloc",
"or",
"not",
"parsed",
".",
"path",
":",
"raise",
"ValueError",
"(",
"\"bad s3 path {}\"",
".",
"format",
"(",
"url",
")",
")",
"bucket_name",
"=",
"parsed",
".",
"netloc",
"s3_path",
"=",
"parsed",
".",
"path",
"# Remove '/' at beginning of path.",
"if",
"s3_path",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"s3_path",
"=",
"s3_path",
"[",
"1",
":",
"]",
"return",
"bucket_name",
",",
"s3_path"
] |
Split a full s3 path into the bucket name and path.
|
[
"Split",
"a",
"full",
"s3",
"path",
"into",
"the",
"bucket",
"name",
"and",
"path",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L120-L130
|
train
|
Split a full s3 path into the bucket name and path.
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A3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\x6f' + '\x33' + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\157' + chr(0b111 + 0o53) + chr(0b110101) + chr(49), 0b1000), ehT0Px3KOsy9('\x30' + chr(766 - 655) + '\x31' + '\x31' + chr(1450 - 1400), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b101 + 0o57) + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(8051 - 7940) + chr(0b110011) + chr(1516 - 1464) + chr(0b110100 + 0o1), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(1407 - 1357) + '\x34' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(776 - 728) + '\157' + chr(2004 - 1953) + chr(2110 - 2058) + chr(0b11001 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + '\063' + chr(0b100000 + 0o24), 1978 - 1970), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010100 + 0o33) + '\061' + chr(0b110111) + '\x30', 24424 - 24416), ehT0Px3KOsy9(chr(269 - 221) + '\x6f' + '\x33' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(55) + '\062', 11884 - 11876), ehT0Px3KOsy9('\060' + chr(0b111101 + 0o62) + chr(49) + chr(0b110000) + '\x33', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110011) + chr(0b11011 + 0o31) + '\x31', 8), ehT0Px3KOsy9('\060' + '\157' + chr(349 - 299) + '\065', 0b1000), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\157' + chr(52) + '\x32', 0b1000), ehT0Px3KOsy9(chr(191 - 143) + chr(0b1101111) + chr(0b110011) + '\062' + chr(52), 13579 - 13571), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1110 + 0o44) + chr(1100 - 1051), 0b1000), ehT0Px3KOsy9('\060' + chr(11985 - 11874) + '\062' + chr(0b110110) + chr(0b110000), 0o10), ehT0Px3KOsy9(chr(292 - 244) + chr(2633 - 2522) + chr(0b110010) + chr(2342 - 2293) + chr(519 - 471), 22610 - 22602), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b101011 + 0o104) + chr(1309 - 1258) + chr(53), 8), ehT0Px3KOsy9('\060' + '\157' + chr(488 - 438) + chr(1339 - 1290) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + '\064' + chr(614 - 563), 2929 - 2921), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + chr(0b10111 + 0o36) + chr(0b10111 + 0o33), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(5313 - 5202) + '\x33' + '\x33' + '\062', 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(0b110100) + chr(0b101111 + 0o6), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b101110 + 0o4) + chr(0b100011 + 0o23) + '\x30', 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + '\x36' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b0 + 0o157) + chr(0b110001) + chr(53) + chr(0b11101 + 0o23), ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + chr(0b110011) + chr(0b0 + 0o61) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b101101 + 0o3) + '\157' + chr(0b10001 + 0o42) + chr(50) + chr(0b110 + 0o54), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x33' + chr(1906 - 1855) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110000 + 0o6) + chr(1237 - 1186), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b1000 + 0o54) + '\x35', 8), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b1110 + 0o44) + chr(50) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1011001 + 0o26) + '\062' + chr(686 - 635) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b10111 + 0o31) + '\x6f' + chr(628 - 580), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11000 + 0o32) + '\066' + chr(1547 - 1493), 8), ehT0Px3KOsy9(chr(867 - 819) + '\x6f' + chr(0b100011 + 0o16) + chr(0b110101 + 0o0) + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(51) + chr(0b10110 + 0o34) + chr(48), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\x6f' + '\065' + '\060', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'4'), '\144' + chr(2811 - 2710) + chr(0b1100011) + chr(111) + '\x64' + chr(101))(chr(117) + chr(0b10001 + 0o143) + chr(102) + chr(0b11011 + 0o22) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def lVVWOuk9Z3CV(CYCr3xzMHl4K) -> MRK8Uzg2En3D[M8_cKLkHVB2V, M8_cKLkHVB2V]:
QIe124s5EFAg = P8lnsClJdUFG(CYCr3xzMHl4K)
if not xafqLlk3kkUe(QIe124s5EFAg, xafqLlk3kkUe(SXOLrMavuUCe(b't\xcc>\x8d\x8a\xc6'), chr(3562 - 3462) + chr(4070 - 3969) + chr(3725 - 3626) + chr(6955 - 6844) + chr(100) + chr(101))(chr(0b1101010 + 0o13) + chr(0b1101100 + 0o10) + chr(2850 - 2748) + '\055' + '\x38')) or not xafqLlk3kkUe(QIe124s5EFAg, xafqLlk3kkUe(SXOLrMavuUCe(b'j\xc8>\x89'), chr(0b1001101 + 0o27) + chr(0b100100 + 0o101) + '\143' + chr(6713 - 6602) + chr(0b1100100) + chr(0b100001 + 0o104))(chr(0b100111 + 0o116) + chr(0b1110001 + 0o3) + '\x66' + chr(45) + chr(2302 - 2246))):
raise q1QCh3W88sgk(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'x\xc8.\xc1\x96\x96\xc3\xec\x19i\x12c\x9ah'), chr(7986 - 7886) + chr(0b1001110 + 0o27) + '\x63' + chr(9919 - 9808) + chr(0b11001 + 0o113) + chr(101))(chr(117) + chr(0b10000 + 0o144) + chr(2154 - 2052) + '\x2d' + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'L\x9d8\x8e\xad\xc4\xb0\xaf(m\x1f)'), '\x64' + chr(101) + chr(99) + '\x6f' + chr(6326 - 6226) + chr(0b110110 + 0o57))(chr(0b1110101) + chr(0b1110100) + '\146' + '\055' + chr(0b100011 + 0o25)))(CYCr3xzMHl4K))
xbZarM78NPqk = QIe124s5EFAg.netloc
F9p046DAk2Gl = QIe124s5EFAg.path
if xafqLlk3kkUe(F9p046DAk2Gl, xafqLlk3kkUe(SXOLrMavuUCe(b'i\xdd+\x93\x91\xd6\x94\xf5\x0cu'), chr(100) + chr(0b1100101) + '\143' + '\157' + '\144' + chr(0b1100101))('\x75' + chr(1706 - 1590) + '\x66' + '\x2d' + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'5'), chr(100) + chr(1910 - 1809) + '\x63' + chr(111) + '\x64' + '\x65')(chr(117) + chr(116) + '\146' + '\055' + '\x38')):
F9p046DAk2Gl = F9p046DAk2Gl[ehT0Px3KOsy9('\060' + chr(5491 - 5380) + '\x31', 8):]
return (xbZarM78NPqk, F9p046DAk2Gl)
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
s3_request
|
def s3_request(func: Callable):
"""
Wrapper function for s3 requests in order to create more helpful error
messages.
"""
@wraps(func)
def wrapper(url: str, *args, **kwargs):
try:
return func(url, *args, **kwargs)
except ClientError as exc:
if int(exc.response["Error"]["Code"]) == 404:
raise FileNotFoundError("file {} not found".format(url))
else:
raise
return wrapper
|
python
|
def s3_request(func: Callable):
"""
Wrapper function for s3 requests in order to create more helpful error
messages.
"""
@wraps(func)
def wrapper(url: str, *args, **kwargs):
try:
return func(url, *args, **kwargs)
except ClientError as exc:
if int(exc.response["Error"]["Code"]) == 404:
raise FileNotFoundError("file {} not found".format(url))
else:
raise
return wrapper
|
[
"def",
"s3_request",
"(",
"func",
":",
"Callable",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"url",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"ClientError",
"as",
"exc",
":",
"if",
"int",
"(",
"exc",
".",
"response",
"[",
"\"Error\"",
"]",
"[",
"\"Code\"",
"]",
")",
"==",
"404",
":",
"raise",
"FileNotFoundError",
"(",
"\"file {} not found\"",
".",
"format",
"(",
"url",
")",
")",
"else",
":",
"raise",
"return",
"wrapper"
] |
Wrapper function for s3 requests in order to create more helpful error
messages.
|
[
"Wrapper",
"function",
"for",
"s3",
"requests",
"in",
"order",
"to",
"create",
"more",
"helpful",
"error",
"messages",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L133-L149
|
train
|
Decorator for s3 requests.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvso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vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b1110 + 0o42) + chr(458 - 347) + '\063' + '\x32' + chr(0b101010 + 0o6), 5049 - 5041), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(55) + chr(118 - 66), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\066' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(1709 - 1661) + chr(111) + '\x31' + chr(0b110100) + chr(0b100010 + 0o17), 56139 - 56131), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + chr(0b110001 + 0o2) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(53) + '\x30', 0b1000), ehT0Px3KOsy9(chr(2141 - 2093) + '\157' + '\065' + '\067', 0o10), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b1101111) + '\x32' + '\063' + '\061', 0b1000), ehT0Px3KOsy9(chr(1356 - 1308) + chr(111) + '\x32' + chr(0b100011 + 0o21) + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + '\065' + chr(0b110110), 12534 - 12526), ehT0Px3KOsy9(chr(848 - 800) + '\157' + chr(1769 - 1720) + '\067' + '\x31', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(0b10101 + 0o33) + '\063', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110011) + chr(0b110111) + chr(53), 0o10), ehT0Px3KOsy9(chr(1570 - 1522) + chr(0b1101111) + '\062' + chr(473 - 421) + chr(53), 0o10), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(8436 - 8325) + '\x32' + chr(55) + chr(0b1011 + 0o45), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110010 + 0o75) + chr(51) + '\x36' + chr(1207 - 1152), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(152 - 100) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b101001 + 0o10) + '\x37' + '\064', 8), ehT0Px3KOsy9('\x30' + chr(4319 - 4208) + chr(49) + chr(0b1110 + 0o45) + chr(593 - 542), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110 + 0o55) + '\060' + chr(202 - 149), 41446 - 41438), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(616 - 505) + '\x31' + '\065' + '\x31', 17746 - 17738), ehT0Px3KOsy9('\060' + chr(0b1100000 + 0o17) + chr(816 - 767) + '\061' + chr(2012 - 1964), 37239 - 37231), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + '\063' + '\x37' + chr(0b111 + 0o60), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\065' + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(108 - 60) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(529 - 481) + '\157' + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(51) + chr(0b100110 + 0o16), 16625 - 16617), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b100100 + 0o17) + chr(0b110011) + chr(55), 63475 - 63467), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10001 + 0o41) + chr(0b110 + 0o60) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + chr(7404 - 7293) + '\063' + '\x33' + chr(1084 - 1036), 17503 - 17495), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(0b1101111) + chr(0b110011) + '\x32' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(2080 - 2032) + chr(0b1101111) + '\x31' + chr(0b100100 + 0o14) + chr(0b100101 + 0o15), 0o10), ehT0Px3KOsy9(chr(1250 - 1202) + '\157' + chr(0b110010) + chr(0b110110) + chr(752 - 702), ord("\x08")), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\x6f' + chr(2170 - 2121) + chr(0b110111) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(9889 - 9778) + chr(0b10001 + 0o44), 8396 - 8388), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + chr(48) + chr(51), 0b1000), ehT0Px3KOsy9(chr(2275 - 2227) + chr(0b1101111) + '\x32' + chr(391 - 338) + '\066', 8), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(359 - 310) + '\x35' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\061' + chr(0b111 + 0o55) + chr(0b11 + 0o60), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x35' + chr(0b10 + 0o56), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xfe'), chr(100) + '\145' + chr(0b1100011) + chr(0b1101111) + '\x64' + chr(0b0 + 0o145))(chr(0b1110101) + '\164' + chr(0b1001011 + 0o33) + chr(0b101101) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Zs45bPzxl3ae(EzOtJ3kbK5x4):
@cUOaMZfY2Ho1(EzOtJ3kbK5x4)
def WW5T3xxdlUaG(CYCr3xzMHl4K, *kJDRfRhcZHjS, **M8EIoTs2GJXE):
try:
return EzOtJ3kbK5x4(CYCr3xzMHl4K, *kJDRfRhcZHjS, **M8EIoTs2GJXE)
except m7I_55SCb3An as YitWAjCPw_g9:
if ehT0Px3KOsy9(xafqLlk3kkUe(YitWAjCPw_g9, xafqLlk3kkUe(SXOLrMavuUCe(b'\xa2\x19A\x115F\\\xfc'), '\x64' + '\x65' + '\x63' + chr(3707 - 3596) + chr(100) + chr(0b1010 + 0o133))('\x75' + chr(0b1011100 + 0o30) + chr(4455 - 4353) + '\055' + '\x38'))[xafqLlk3kkUe(SXOLrMavuUCe(b'\x95\x0e@\x0e('), chr(0b1100100) + chr(0b1100101) + '\x63' + chr(6459 - 6348) + chr(2299 - 2199) + chr(0b1100101))(chr(0b1110101) + chr(0b1110100) + chr(0b11001 + 0o115) + '\x2d' + '\070')][xafqLlk3kkUe(SXOLrMavuUCe(b'\x93\x13V\x04'), chr(0b111 + 0o135) + chr(9333 - 9232) + '\x63' + chr(0b11 + 0o154) + chr(5687 - 5587) + '\x65')(chr(117) + chr(1484 - 1368) + chr(6802 - 6700) + chr(45) + chr(56))]) == ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110110) + chr(0b110010) + chr(323 - 271), 16652 - 16644):
raise oNamnshN4dFG(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb6\x15^\x04zSR\xb9\xcc\xc1\r\xa3\x9b\xca\xcd\x99G'), chr(0b1100100) + chr(0b1100101) + chr(0b1100011) + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(2964 - 2847) + chr(116) + chr(0b1100110) + '\055' + chr(0b11010 + 0o36)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x86H@\x0e\x12I|\xaa\xf2\xde\x1c\xe9'), '\x64' + chr(4378 - 4277) + chr(1853 - 1754) + chr(0b1100010 + 0o15) + chr(7173 - 7073) + chr(0b1100101))('\x75' + chr(0b1110100) + chr(5669 - 5567) + '\055' + chr(0b0 + 0o70)))(CYCr3xzMHl4K))
else:
raise
return WW5T3xxdlUaG
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
s3_etag
|
def s3_etag(url: str) -> Optional[str]:
"""Check ETag on S3 object."""
s3_resource = boto3.resource("s3")
bucket_name, s3_path = split_s3_path(url)
s3_object = s3_resource.Object(bucket_name, s3_path)
return s3_object.e_tag
|
python
|
def s3_etag(url: str) -> Optional[str]:
"""Check ETag on S3 object."""
s3_resource = boto3.resource("s3")
bucket_name, s3_path = split_s3_path(url)
s3_object = s3_resource.Object(bucket_name, s3_path)
return s3_object.e_tag
|
[
"def",
"s3_etag",
"(",
"url",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"s3_resource",
"=",
"boto3",
".",
"resource",
"(",
"\"s3\"",
")",
"bucket_name",
",",
"s3_path",
"=",
"split_s3_path",
"(",
"url",
")",
"s3_object",
"=",
"s3_resource",
".",
"Object",
"(",
"bucket_name",
",",
"s3_path",
")",
"return",
"s3_object",
".",
"e_tag"
] |
Check ETag on S3 object.
|
[
"Check",
"ETag",
"on",
"S3",
"object",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98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JLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110110) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b1011 + 0o50) + chr(0b100000 + 0o25), 0o10), ehT0Px3KOsy9(chr(900 - 852) + chr(8435 - 8324) + '\x33' + chr(0b110111) + chr(0b110011), 59307 - 59299), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110001) + chr(0b110101) + chr(1474 - 1426), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\063' + chr(2257 - 2202), 0b1000), ehT0Px3KOsy9('\060' + chr(8730 - 8619) + '\063' + chr(0b11101 + 0o23) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(2097 - 1986) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(64 - 14) + '\063' + chr(2998 - 2943), 0o10), ehT0Px3KOsy9('\x30' + chr(1236 - 1125) + chr(0b110110) + chr(0b10101 + 0o41), 0o10), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b1100 + 0o143) + '\x33' + chr(1857 - 1807) + chr(1460 - 1407), 0b1000), ehT0Px3KOsy9(chr(258 - 210) + chr(1860 - 1749) + '\061' + chr(1591 - 1540) + chr(0b100101 + 0o13), 6577 - 6569), ehT0Px3KOsy9('\060' + chr(111) + '\x31' + chr(0b10 + 0o57) + chr(51), 18293 - 18285), ehT0Px3KOsy9(chr(0b110000 + 0o0) + '\x6f' + chr(0b110001) + '\x35' + chr(1767 - 1715), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(0b110100) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(49) + '\x32', 0b1000), ehT0Px3KOsy9(chr(1106 - 1058) + '\x6f' + '\x33' + chr(2383 - 2331) + chr(0b110001), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(2360 - 2310) + '\065' + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b11101 + 0o122) + chr(505 - 452) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + chr(1410 - 1362) + chr(958 - 904), 38860 - 38852), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + chr(0b100011 + 0o17) + chr(0b101100 + 0o6), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1010000 + 0o37) + chr(0b1001 + 0o55), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b110010 + 0o75) + '\061' + chr(577 - 527) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100111 + 0o12) + chr(49) + '\064', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110001) + chr(0b101010 + 0o6), 37481 - 37473), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b10001 + 0o41) + '\x31' + chr(0b110000), 38129 - 38121), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b11010 + 0o31) + chr(54) + chr(0b110001 + 0o4), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + '\064' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(884 - 773) + chr(50) + chr(0b10110 + 0o40) + chr(0b1001 + 0o51), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + '\x37' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b100100 + 0o17) + chr(0b110010) + '\065', 8), ehT0Px3KOsy9(chr(0b110000) + chr(5367 - 5256) + chr(2192 - 2142) + '\066' + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1100010 + 0o15) + chr(1279 - 1229) + '\x37' + '\063', 0o10), ehT0Px3KOsy9(chr(48) + chr(1837 - 1726) + chr(49) + chr(54) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1426 - 1375) + '\067' + chr(0b111 + 0o51), 42408 - 42400), ehT0Px3KOsy9(chr(0b11001 + 0o27) + '\157' + chr(0b110010) + '\063' + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(0b100010 + 0o22) + '\x36', 0o10), ehT0Px3KOsy9(chr(816 - 768) + '\157' + '\062' + '\x35' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1243 - 1192) + chr(49) + chr(0b110111), 6488 - 6480), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(49) + chr(0b100110 + 0o17), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(11955 - 11844) + chr(0b110101) + chr(48), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x1f'), chr(100) + chr(0b1010101 + 0o20) + chr(0b1100011) + chr(0b1001001 + 0o46) + chr(100) + chr(7315 - 7214))(chr(11050 - 10933) + chr(0b1110100) + chr(0b1100110) + chr(492 - 447) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def y4iE0pIMeo2g(CYCr3xzMHl4K) -> vi1g1wPnZvlE[M8_cKLkHVB2V]:
OvqVwCWmZpc3 = OyjxW8JV9GLL.resource(xafqLlk3kkUe(SXOLrMavuUCe(b'B\xee'), chr(100) + chr(101) + '\143' + chr(11237 - 11126) + '\x64' + chr(0b1100101))(chr(10160 - 10043) + chr(0b100101 + 0o117) + chr(102) + '\055' + chr(56)))
(xbZarM78NPqk, F9p046DAk2Gl) = lVVWOuk9Z3CV(CYCr3xzMHl4K)
lIPXVdBP1ORU = OvqVwCWmZpc3.Object(xbZarM78NPqk, F9p046DAk2Gl)
return xafqLlk3kkUe(lIPXVdBP1ORU, xafqLlk3kkUe(SXOLrMavuUCe(b'T\x82\x8f\tx'), chr(100) + chr(0b1000110 + 0o37) + chr(7912 - 7813) + chr(6142 - 6031) + chr(0b100110 + 0o76) + chr(0b1100101))('\x75' + '\164' + '\146' + chr(45) + '\070'))
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
s3_get
|
def s3_get(url: str, temp_file: IO) -> None:
"""Pull a file directly from S3."""
s3_resource = boto3.resource("s3")
bucket_name, s3_path = split_s3_path(url)
s3_resource.Bucket(bucket_name).download_fileobj(s3_path, temp_file)
|
python
|
def s3_get(url: str, temp_file: IO) -> None:
"""Pull a file directly from S3."""
s3_resource = boto3.resource("s3")
bucket_name, s3_path = split_s3_path(url)
s3_resource.Bucket(bucket_name).download_fileobj(s3_path, temp_file)
|
[
"def",
"s3_get",
"(",
"url",
":",
"str",
",",
"temp_file",
":",
"IO",
")",
"->",
"None",
":",
"s3_resource",
"=",
"boto3",
".",
"resource",
"(",
"\"s3\"",
")",
"bucket_name",
",",
"s3_path",
"=",
"split_s3_path",
"(",
"url",
")",
"s3_resource",
".",
"Bucket",
"(",
"bucket_name",
")",
".",
"download_fileobj",
"(",
"s3_path",
",",
"temp_file",
")"
] |
Pull a file directly from S3.
|
[
"Pull",
"a",
"file",
"directly",
"from",
"S3",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L162-L166
|
train
|
Pull a file directly from S3.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsD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,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(1278 - 1227) + chr(0b11001 + 0o34), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111111 + 0o60) + chr(0b110010) + '\067' + chr(1945 - 1897), 34875 - 34867), ehT0Px3KOsy9('\060' + '\x6f' + chr(2396 - 2346) + chr(53) + chr(0b110100), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + '\x32' + chr(0b10000 + 0o46), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1001011 + 0o44) + chr(2329 - 2278) + chr(0b110101) + chr(0b1111 + 0o47), 0o10), ehT0Px3KOsy9('\x30' + chr(0b10 + 0o155) + chr(0b11 + 0o56) + chr(0b110000) + chr(0b100010 + 0o21), 59256 - 59248), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110011) + chr(0b110101) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10110 + 0o34) + chr(0b110100) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(6455 - 6344) + chr(49) + chr(0b110001) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(167 - 119) + chr(4650 - 4539) + chr(2257 - 2203) + chr(0b110001), 44772 - 44764), ehT0Px3KOsy9('\060' + chr(0b1100010 + 0o15) + chr(0b110011) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(9206 - 9095) + chr(49) + chr(53) + chr(0b101100 + 0o5), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(49) + chr(987 - 938) + chr(48), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x32' + chr(2445 - 2394) + chr(0b10111 + 0o34), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + chr(0b101100 + 0o13) + '\063', 46984 - 46976), ehT0Px3KOsy9(chr(959 - 911) + chr(0b1101111) + '\062' + chr(2186 - 2133) + chr(0b11001 + 0o36), 0o10), ehT0Px3KOsy9(chr(0b100000 + 0o20) + '\157' + '\x31' + chr(50) + chr(0b101 + 0o54), 0o10), ehT0Px3KOsy9(chr(721 - 673) + '\x6f' + chr(0b101101 + 0o5) + '\066' + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\063' + '\063' + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110000 + 0o3) + '\x36' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b11100 + 0o25) + '\064' + '\063', 0b1000), ehT0Px3KOsy9(chr(612 - 564) + '\x6f' + chr(1626 - 1577) + '\065' + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(1305 - 1257) + chr(0b110110), 4793 - 4785), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100001 + 0o22) + chr(0b110010) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(1764 - 1716) + chr(111) + chr(0b100111 + 0o13) + chr(51) + chr(0b10111 + 0o37), 0b1000), ehT0Px3KOsy9(chr(1861 - 1813) + '\x6f' + '\x33' + chr(0b110011) + chr(50), 8114 - 8106), ehT0Px3KOsy9(chr(0b110000) + chr(11012 - 10901) + '\x32' + chr(525 - 476) + chr(91 - 41), 39375 - 39367), ehT0Px3KOsy9(chr(0b110000) + chr(10573 - 10462) + chr(0b100110 + 0o16), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b100110 + 0o111) + chr(2065 - 2014) + '\x30' + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4813 - 4702) + chr(0b110111) + chr(0b110010), 29930 - 29922), ehT0Px3KOsy9(chr(0b110000) + chr(2133 - 2022) + '\x32' + chr(48), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\063' + '\064', 59846 - 59838), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011100 + 0o23) + '\063' + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + chr(439 - 385) + '\x36', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b101111 + 0o100) + chr(1266 - 1217) + '\x31' + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(1158 - 1110) + chr(0b1000010 + 0o55) + chr(0b110010) + '\x37' + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(11850 - 11739) + '\x33' + chr(0b110101) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(0b110110) + chr(0b110110), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1197 - 1146) + '\065', 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b101110 + 0o101) + chr(877 - 828) + chr(0b11000 + 0o35) + chr(1528 - 1477), 18079 - 18071)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(53) + chr(0b0 + 0o60), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf3'), chr(1501 - 1401) + chr(0b1111 + 0o126) + chr(99) + chr(0b1101111) + chr(100) + chr(0b10111 + 0o116))(chr(4633 - 4516) + '\x74' + chr(9361 - 9259) + chr(1886 - 1841) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def FejmkFsZ5MEQ(CYCr3xzMHl4K, CZHnRGuVVrOs) -> None:
OvqVwCWmZpc3 = OyjxW8JV9GLL.resource(xafqLlk3kkUe(SXOLrMavuUCe(b'\xae\x8b'), '\x64' + chr(0b1010111 + 0o16) + chr(0b11000 + 0o113) + chr(0b1101111) + '\x64' + '\145')('\165' + chr(116) + chr(102) + chr(45) + '\x38'))
(xbZarM78NPqk, F9p046DAk2Gl) = lVVWOuk9Z3CV(CYCr3xzMHl4K)
xafqLlk3kkUe(OvqVwCWmZpc3.Bucket(xbZarM78NPqk), xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\xd7\xdb\xf8\x82,\x8b\xc6\x16Wq\x05-\xf4\xd9\xc5'), chr(0b1100100) + chr(0b1001 + 0o134) + chr(99) + chr(1904 - 1793) + chr(0b1001 + 0o133) + '\x65')('\165' + '\164' + chr(0b1100110) + chr(0b101101) + '\x38'))(F9p046DAk2Gl, CZHnRGuVVrOs)
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
get_from_cache
|
def get_from_cache(url: str, cache_dir: str = None) -> str:
"""
Given a URL, look for the corresponding dataset in the local cache.
If it's not there, download it. Then return the path to the cached file.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
os.makedirs(cache_dir, exist_ok=True)
# Get eTag to add to filename, if it exists.
if url.startswith("s3://"):
etag = s3_etag(url)
else:
response = requests.head(url, allow_redirects=True)
if response.status_code != 200:
raise IOError("HEAD request failed for url {} with status code {}"
.format(url, response.status_code))
etag = response.headers.get("ETag")
filename = url_to_filename(url, etag)
# get cache path to put the file
cache_path = os.path.join(cache_dir, filename)
if not os.path.exists(cache_path):
# Download to temporary file, then copy to cache dir once finished.
# Otherwise you get corrupt cache entries if the download gets interrupted.
with tempfile.NamedTemporaryFile() as temp_file:
logger.info("%s not found in cache, downloading to %s", url, temp_file.name)
# GET file object
if url.startswith("s3://"):
s3_get(url, temp_file)
else:
http_get(url, temp_file)
# we are copying the file before closing it, so flush to avoid truncation
temp_file.flush()
# shutil.copyfileobj() starts at the current position, so go to the start
temp_file.seek(0)
logger.info("copying %s to cache at %s", temp_file.name, cache_path)
with open(cache_path, 'wb') as cache_file:
shutil.copyfileobj(temp_file, cache_file)
logger.info("creating metadata file for %s", cache_path)
meta = {'url': url, 'etag': etag}
meta_path = cache_path + '.json'
with open(meta_path, 'w') as meta_file:
json.dump(meta, meta_file)
logger.info("removing temp file %s", temp_file.name)
return cache_path
|
python
|
def get_from_cache(url: str, cache_dir: str = None) -> str:
"""
Given a URL, look for the corresponding dataset in the local cache.
If it's not there, download it. Then return the path to the cached file.
"""
if cache_dir is None:
cache_dir = CACHE_DIRECTORY
os.makedirs(cache_dir, exist_ok=True)
# Get eTag to add to filename, if it exists.
if url.startswith("s3://"):
etag = s3_etag(url)
else:
response = requests.head(url, allow_redirects=True)
if response.status_code != 200:
raise IOError("HEAD request failed for url {} with status code {}"
.format(url, response.status_code))
etag = response.headers.get("ETag")
filename = url_to_filename(url, etag)
# get cache path to put the file
cache_path = os.path.join(cache_dir, filename)
if not os.path.exists(cache_path):
# Download to temporary file, then copy to cache dir once finished.
# Otherwise you get corrupt cache entries if the download gets interrupted.
with tempfile.NamedTemporaryFile() as temp_file:
logger.info("%s not found in cache, downloading to %s", url, temp_file.name)
# GET file object
if url.startswith("s3://"):
s3_get(url, temp_file)
else:
http_get(url, temp_file)
# we are copying the file before closing it, so flush to avoid truncation
temp_file.flush()
# shutil.copyfileobj() starts at the current position, so go to the start
temp_file.seek(0)
logger.info("copying %s to cache at %s", temp_file.name, cache_path)
with open(cache_path, 'wb') as cache_file:
shutil.copyfileobj(temp_file, cache_file)
logger.info("creating metadata file for %s", cache_path)
meta = {'url': url, 'etag': etag}
meta_path = cache_path + '.json'
with open(meta_path, 'w') as meta_file:
json.dump(meta, meta_file)
logger.info("removing temp file %s", temp_file.name)
return cache_path
|
[
"def",
"get_from_cache",
"(",
"url",
":",
"str",
",",
"cache_dir",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"if",
"cache_dir",
"is",
"None",
":",
"cache_dir",
"=",
"CACHE_DIRECTORY",
"os",
".",
"makedirs",
"(",
"cache_dir",
",",
"exist_ok",
"=",
"True",
")",
"# Get eTag to add to filename, if it exists.",
"if",
"url",
".",
"startswith",
"(",
"\"s3://\"",
")",
":",
"etag",
"=",
"s3_etag",
"(",
"url",
")",
"else",
":",
"response",
"=",
"requests",
".",
"head",
"(",
"url",
",",
"allow_redirects",
"=",
"True",
")",
"if",
"response",
".",
"status_code",
"!=",
"200",
":",
"raise",
"IOError",
"(",
"\"HEAD request failed for url {} with status code {}\"",
".",
"format",
"(",
"url",
",",
"response",
".",
"status_code",
")",
")",
"etag",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"\"ETag\"",
")",
"filename",
"=",
"url_to_filename",
"(",
"url",
",",
"etag",
")",
"# get cache path to put the file",
"cache_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cache_path",
")",
":",
"# Download to temporary file, then copy to cache dir once finished.",
"# Otherwise you get corrupt cache entries if the download gets interrupted.",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"as",
"temp_file",
":",
"logger",
".",
"info",
"(",
"\"%s not found in cache, downloading to %s\"",
",",
"url",
",",
"temp_file",
".",
"name",
")",
"# GET file object",
"if",
"url",
".",
"startswith",
"(",
"\"s3://\"",
")",
":",
"s3_get",
"(",
"url",
",",
"temp_file",
")",
"else",
":",
"http_get",
"(",
"url",
",",
"temp_file",
")",
"# we are copying the file before closing it, so flush to avoid truncation",
"temp_file",
".",
"flush",
"(",
")",
"# shutil.copyfileobj() starts at the current position, so go to the start",
"temp_file",
".",
"seek",
"(",
"0",
")",
"logger",
".",
"info",
"(",
"\"copying %s to cache at %s\"",
",",
"temp_file",
".",
"name",
",",
"cache_path",
")",
"with",
"open",
"(",
"cache_path",
",",
"'wb'",
")",
"as",
"cache_file",
":",
"shutil",
".",
"copyfileobj",
"(",
"temp_file",
",",
"cache_file",
")",
"logger",
".",
"info",
"(",
"\"creating metadata file for %s\"",
",",
"cache_path",
")",
"meta",
"=",
"{",
"'url'",
":",
"url",
",",
"'etag'",
":",
"etag",
"}",
"meta_path",
"=",
"cache_path",
"+",
"'.json'",
"with",
"open",
"(",
"meta_path",
",",
"'w'",
")",
"as",
"meta_file",
":",
"json",
".",
"dump",
"(",
"meta",
",",
"meta_file",
")",
"logger",
".",
"info",
"(",
"\"removing temp file %s\"",
",",
"temp_file",
".",
"name",
")",
"return",
"cache_path"
] |
Given a URL, look for the corresponding dataset in the local cache.
If it's not there, download it. Then return the path to the cached file.
|
[
"Given",
"a",
"URL",
"look",
"for",
"the",
"corresponding",
"dataset",
"in",
"the",
"local",
"cache",
".",
"If",
"it",
"s",
"not",
"there",
"download",
"it",
".",
"Then",
"return",
"the",
"path",
"to",
"the",
"cached",
"file",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L182-L236
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eSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + chr(7443 - 7332) + chr(0b110001) + '\062' + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b10111 + 0o36) + '\066', ord("\x08")), ehT0Px3KOsy9('\060' + chr(3260 - 3149) + chr(0b11101 + 0o25) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\157' + chr(0b110011) + chr(0b110100) + chr(2206 - 2155), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101101 + 0o6) + chr(0b110110) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b110110) + '\066', 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\066' + chr(0b10101 + 0o40), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(0b1 + 0o66), ord("\x08")), ehT0Px3KOsy9(chr(1440 - 1392) + chr(3347 - 3236) + chr(286 - 235) + chr(0b110111), 54675 - 54667), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101010 + 0o5) + '\062' + chr(0b110111) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b101101 + 0o102) + chr(0b10001 + 0o41) + chr(0b10011 + 0o41) + chr(0b10101 + 0o42), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10000 + 0o137) + '\061' + chr(0b0 + 0o67) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b111010 + 0o65) + '\x32' + chr(0b110001 + 0o0) + chr(1099 - 1046), 53512 - 53504), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b11111 + 0o24) + chr(0b110100) + chr(0b101011 + 0o10), 8), ehT0Px3KOsy9('\060' + '\157' + chr(49) + chr(0b10111 + 0o34) + '\x30', 0b1000), ehT0Px3KOsy9(chr(1496 - 1448) + chr(11081 - 10970) + '\x37', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b100000 + 0o23) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(2189 - 2141) + chr(0b1100100 + 0o13) + chr(850 - 801) + chr(0b110101) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(0b11011 + 0o25) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50 - 0) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\064' + chr(0b1110 + 0o46), 0o10), ehT0Px3KOsy9(chr(0b100110 + 0o12) + chr(3643 - 3532) + chr(50) + '\x31' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + '\062' + chr(1816 - 1761) + chr(51), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(1106 - 995) + chr(0b11100 + 0o30) + '\065', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1000 + 0o147) + chr(0b11111 + 0o24) + '\066' + chr(0b110000), 10356 - 10348), ehT0Px3KOsy9('\060' + '\x6f' + '\062' + chr(259 - 211) + chr(53), 8), ehT0Px3KOsy9(chr(0b100 + 0o54) + '\157' + chr(0b10001 + 0o42) + chr(49), 0o10), ehT0Px3KOsy9(chr(126 - 78) + '\157' + '\x33' + chr(0b110101) + '\066', 12801 - 12793), ehT0Px3KOsy9('\x30' + '\157' + '\060', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(50) + '\063' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + chr(2182 - 2133) + chr(2832 - 2778) + '\x36', 8), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10 + 0o61) + '\061' + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110001) + '\064', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(835 - 785) + chr(54) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(0b1100 + 0o45) + chr(0b11101 + 0o24), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1115 - 1066) + chr(0b11010 + 0o34) + chr(0b10001 + 0o43), 0b1000), ehT0Px3KOsy9(chr(778 - 730) + chr(7901 - 7790) + chr(0b110010 + 0o1) + '\x34' + chr(0b10001 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\062' + chr(0b110000) + chr(2314 - 2263), 5680 - 5672), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b1101111) + chr(0b110010) + '\x31', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + chr(0b101110 + 0o7) + '\x34', 55124 - 55116)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100101 + 0o20) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'z'), chr(0b1100000 + 0o4) + chr(101) + '\143' + chr(0b101000 + 0o107) + chr(100) + '\x65')(chr(117) + '\x74' + chr(0b11111 + 0o107) + '\x2d' + chr(0b110111 + 0o1)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def eszr0um5F1Px(CYCr3xzMHl4K, j3fmOtvUtrP5=None) -> M8_cKLkHVB2V:
if j3fmOtvUtrP5 is None:
j3fmOtvUtrP5 = WQgeKIRObRPj
xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'9O}\x86\x95\x1fG|'), '\x64' + chr(0b1011110 + 0o7) + chr(0b1100011) + chr(0b1101111) + '\144' + chr(0b1100101))('\x75' + chr(0b101001 + 0o113) + '\146' + chr(0b100010 + 0o13) + chr(0b111000)))(j3fmOtvUtrP5, exist_ok=ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001), 0o10))
if xafqLlk3kkUe(CYCr3xzMHl4K, xafqLlk3kkUe(SXOLrMavuUCe(b"'Zw\x91\x85\x05Bfk\xd4"), chr(0b1100100) + chr(0b101011 + 0o72) + chr(99) + '\x6f' + chr(0b1100100) + chr(0b1100101))('\x75' + '\164' + '\146' + chr(0b1100 + 0o41) + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b"'\x1d,\xcc\xde"), chr(9100 - 9000) + '\145' + chr(0b1100011) + chr(0b1101111) + '\144' + chr(0b1100101))(chr(117) + chr(0b1110100) + chr(6425 - 6323) + '\x2d' + chr(56))):
RwOST2AT9ncg = y4iE0pIMeo2g(CYCr3xzMHl4K)
else:
ekFGDFIe9V8v = Mx6ixpcPMQy3.head(CYCr3xzMHl4K, allow_redirects=ehT0Px3KOsy9('\x30' + chr(0b111000 + 0o67) + chr(0b1101 + 0o44), 8))
if xafqLlk3kkUe(ekFGDFIe9V8v, xafqLlk3kkUe(SXOLrMavuUCe(b'7ja\x8f\xa9@d^&\x8e\x91>'), chr(9995 - 9895) + chr(101) + chr(0b1010 + 0o131) + '\157' + chr(4110 - 4010) + '\x65')(chr(0b100100 + 0o121) + '\x74' + '\x66' + '\x2d' + chr(56))) != ehT0Px3KOsy9(chr(2104 - 2056) + chr(0b1101111) + chr(1594 - 1543) + chr(1307 - 1258) + chr(0b110 + 0o52), 0o10):
raise sR2sPcm7Zrfn(xafqLlk3kkUe(xafqLlk3kkUe(SXOLrMavuUCe(b'\x1ckW\xa7\xd1\x04P~j\xd9\xd4\x0f\xad\x859np\x0c\xe12B\xe7\xc9\x05\x85\xf7u\xce{\xe4V\xb9e\xc5\xa1T\x95\xf7p\x98!]6\x80\x9e\x12P/d\xc1'), chr(7563 - 7463) + '\145' + '\143' + '\157' + chr(100) + chr(0b1001010 + 0o33))('\x75' + chr(0b1000010 + 0o62) + chr(0b1000010 + 0o44) + '\055' + chr(0b10 + 0o66)), xafqLlk3kkUe(SXOLrMavuUCe(b'\x02\x1ad\x8c\xb9\x17f<O\xcc\xc2\x11'), '\144' + '\145' + chr(0b1100011) + chr(0b1001110 + 0o41) + '\144' + chr(0b1100101))(chr(117) + '\164' + '\146' + chr(0b101101) + chr(0b111000)))(CYCr3xzMHl4K, xafqLlk3kkUe(ekFGDFIe9V8v, xafqLlk3kkUe(SXOLrMavuUCe(b'7ja\x8f\xa9@d^&\x8e\x91>'), chr(0b101111 + 0o65) + chr(0b1100101) + '\143' + chr(0b1101111) + chr(0b1100100) + chr(1067 - 966))('\x75' + '\164' + '\146' + chr(45) + chr(1137 - 1081)))))
RwOST2AT9ncg = ekFGDFIe9V8v.headers.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\x11zw\x84'), '\144' + '\x65' + chr(0b1100011) + '\x6f' + '\144' + chr(0b1100101))(chr(0b1000 + 0o155) + '\x74' + chr(102) + chr(45) + chr(0b10111 + 0o41)))
xw4DsBfIJ22E = lXDzoYHIOVOO(CYCr3xzMHl4K, RwOST2AT9ncg)
WYuPioNR_sqI = oqhJDdMJfuwx.path._oWXztVNnqHF(j3fmOtvUtrP5, xw4DsBfIJ22E)
if not xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'1V\x7f\x90\x85\x05'), '\x64' + chr(0b1100101) + chr(3796 - 3697) + '\157' + chr(0b1100100) + chr(0b1111 + 0o126))(chr(0b10100 + 0o141) + chr(116) + '\x66' + '\055' + chr(56)))(WYuPioNR_sqI):
with xafqLlk3kkUe(IvD8hQuFpT7c, xafqLlk3kkUe(SXOLrMavuUCe(b'\x1aO{\x86\x95"Pbo\xd3\xd5\x1a\xff\x9a\x1enp\x0c'), chr(0b1100100) + chr(10023 - 9922) + chr(99) + chr(7160 - 7049) + chr(100) + chr(0b1000010 + 0o43))(chr(117) + chr(0b111 + 0o155) + chr(0b111 + 0o137) + chr(299 - 254) + '\x38'))() as CZHnRGuVVrOs:
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x07\x19^\x9b\x84\x15R8u\xd0\xfd\x10'), chr(100) + chr(0b1100101) + chr(0b1010001 + 0o22) + chr(0b1101111) + chr(0b1100100) + '\145')('\165' + chr(7471 - 7355) + chr(0b10100 + 0o122) + '\x2d' + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b"q]6\x8d\x9e\x02\x15ip\xc9\xc9\x1f\xad\x8a6'\x7f\x08\xe6zA\xa4\x9bA\x9f\xf2w\x82o\xf8\x12\xa7b\xd6\xe9\x00\x89\xa34\x9f"), chr(9341 - 9241) + chr(0b100111 + 0o76) + chr(0b10011 + 0o120) + chr(111) + '\x64' + '\145')(chr(0b1101 + 0o150) + chr(0b1101010 + 0o12) + chr(0b11100 + 0o112) + chr(1262 - 1217) + chr(56)), CYCr3xzMHl4K, xafqLlk3kkUe(CZHnRGuVVrOs, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15g`\xa9\xa3\x0cyk[\xda\xc0='), chr(1842 - 1742) + chr(101) + chr(0b1100011) + chr(12159 - 12048) + chr(1157 - 1057) + chr(0b101101 + 0o70))(chr(117) + '\x74' + chr(102) + '\055' + '\x38')))
if xafqLlk3kkUe(CYCr3xzMHl4K, xafqLlk3kkUe(SXOLrMavuUCe(b"'Zw\x91\x85\x05Bfk\xd4"), chr(100) + '\145' + chr(99) + chr(0b1101111) + chr(0b1100100) + chr(0b1100101))(chr(0b1110101) + chr(116) + chr(0b1100110) + '\055' + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b"'\x1d,\xcc\xde"), '\144' + chr(6450 - 6349) + chr(0b1100011) + '\157' + chr(5584 - 5484) + chr(0b101111 + 0o66))('\165' + chr(0b1011101 + 0o27) + chr(0b1011010 + 0o14) + chr(275 - 230) + chr(0b111000))):
FejmkFsZ5MEQ(CYCr3xzMHl4K, CZHnRGuVVrOs)
else:
FxjOl8Q5K066(CYCr3xzMHl4K, CZHnRGuVVrOs)
xafqLlk3kkUe(CZHnRGuVVrOs, xafqLlk3kkUe(SXOLrMavuUCe(b'2Bc\x90\x99'), chr(1271 - 1171) + chr(101) + '\x63' + '\157' + '\144' + chr(0b1101 + 0o130))(chr(0b1110101) + chr(0b1110100) + '\146' + '\055' + '\070'))()
xafqLlk3kkUe(CZHnRGuVVrOs, xafqLlk3kkUe(SXOLrMavuUCe(b"'Ks\x88"), chr(0b1001110 + 0o26) + chr(0b1100000 + 0o5) + chr(99) + '\x6f' + '\x64' + chr(0b1100101))(chr(9455 - 9338) + chr(0b1010100 + 0o40) + chr(8934 - 8832) + '\055' + chr(1579 - 1523)))(ehT0Px3KOsy9('\x30' + '\x6f' + chr(2298 - 2250), 8))
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x07\x19^\x9b\x84\x15R8u\xd0\xfd\x10'), chr(8846 - 8746) + chr(9988 - 9887) + '\x63' + chr(3801 - 3690) + '\144' + '\145')('\x75' + chr(0b1000101 + 0o57) + chr(102) + chr(0b101101) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'7Af\x9a\x98\x18R/:\xcf\x87\x0f\xe2\xc3;f\x7f\x01\xe02E\xfc\x9b\x00\x83'), '\x64' + chr(101) + chr(2173 - 2074) + chr(3799 - 3688) + chr(0b1100100) + chr(0b1100101))(chr(0b100000 + 0o125) + chr(0b1110100) + chr(102) + '\055' + chr(1441 - 1385)), xafqLlk3kkUe(CZHnRGuVVrOs, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15g`\xa9\xa3\x0cyk[\xda\xc0='), chr(100) + '\x65' + '\143' + chr(10587 - 10476) + chr(0b1100100) + '\145')('\165' + chr(116) + '\146' + chr(0b101101) + '\x38')), WYuPioNR_sqI)
with _fwkIVCGgtAN(WYuPioNR_sqI, xafqLlk3kkUe(SXOLrMavuUCe(b'#L'), chr(100) + chr(0b1100101) + chr(532 - 433) + chr(111) + chr(1378 - 1278) + '\x65')(chr(0b1100110 + 0o17) + chr(116) + chr(102) + chr(0b11 + 0o52) + chr(56))) as vhXbYptxZ3Pz:
xafqLlk3kkUe(DSLq_IS6e6IX, xafqLlk3kkUe(SXOLrMavuUCe(b'7Af\x9a\x97\x1fYjp\xde\xcd'), chr(2227 - 2127) + chr(101) + '\x63' + chr(0b1000100 + 0o53) + '\144' + chr(0b1101 + 0o130))(chr(0b111111 + 0o66) + chr(705 - 589) + chr(102) + chr(0b101101) + chr(0b111000)))(CZHnRGuVVrOs, vhXbYptxZ3Pz)
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x07\x19^\x9b\x84\x15R8u\xd0\xfd\x10'), chr(0b1001 + 0o133) + chr(101) + chr(0b1100011) + chr(0b111110 + 0o61) + chr(7175 - 7075) + chr(0b1100101))('\x75' + '\164' + chr(8275 - 8173) + chr(45) + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'7\\s\x82\x85\x1f[h?\xd1\xc2\x0f\xec\x879s}I\xe3{H\xed\x9bC\x9f\xf79\xcbs'), chr(0b1100011 + 0o1) + chr(101) + '\x63' + chr(111) + '\144' + '\x65')(chr(1595 - 1478) + chr(116) + '\x66' + chr(0b101101) + chr(0b111000)), WYuPioNR_sqI)
Ddxy_ihdYXS3 = {xafqLlk3kkUe(SXOLrMavuUCe(b'!\\z'), '\x64' + '\x65' + chr(0b1010110 + 0o15) + '\x6f' + chr(100) + chr(9623 - 9522))(chr(0b1110101) + '\164' + chr(102) + chr(1734 - 1689) + chr(665 - 609)): CYCr3xzMHl4K, xafqLlk3kkUe(SXOLrMavuUCe(b'1Zw\x84'), chr(0b1011010 + 0o12) + chr(101) + chr(0b1011110 + 0o5) + '\x6f' + '\144' + chr(0b100000 + 0o105))(chr(0b100111 + 0o116) + chr(0b1110100) + chr(0b1011100 + 0o12) + chr(0b111 + 0o46) + chr(0b111000)): RwOST2AT9ncg}
EnlLcM0uvHG1 = WYuPioNR_sqI + xafqLlk3kkUe(SXOLrMavuUCe(b'zDe\x8c\x9f'), chr(100) + chr(7289 - 7188) + chr(1509 - 1410) + chr(0b1010 + 0o145) + '\x64' + '\145')(chr(0b1110101) + chr(7442 - 7326) + '\146' + chr(0b101000 + 0o5) + chr(2600 - 2544))
with _fwkIVCGgtAN(EnlLcM0uvHG1, xafqLlk3kkUe(SXOLrMavuUCe(b'#'), chr(100) + chr(101) + chr(4256 - 4157) + '\157' + chr(4274 - 4174) + chr(0b1010111 + 0o16))(chr(0b1110101) + chr(116) + chr(0b1100110) + '\x2d' + chr(0b111000))) as bA1zw91Kxflm:
xafqLlk3kkUe(fXk443epxtd5, xafqLlk3kkUe(SXOLrMavuUCe(b'0[{\x93'), '\x64' + chr(0b100000 + 0o105) + chr(0b1100011) + chr(0b1101111) + chr(0b1000010 + 0o42) + '\145')(chr(7528 - 7411) + '\x74' + chr(0b11000 + 0o116) + chr(0b10100 + 0o31) + '\x38'))(Ddxy_ihdYXS3, bA1zw91Kxflm)
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\x07\x19^\x9b\x84\x15R8u\xd0\xfd\x10'), chr(0b1001100 + 0o30) + '\145' + '\143' + '\x6f' + chr(501 - 401) + chr(1304 - 1203))('\165' + chr(116) + '\146' + chr(699 - 654) + chr(0b111000)))(xafqLlk3kkUe(SXOLrMavuUCe(b'&K{\x8c\x87\x1f[h?\xc8\xc2\x16\xfd\xc3>np\x0c\xa57W'), '\144' + chr(101) + chr(99) + chr(0b1101111) + '\144' + '\145')(chr(0b1110101) + chr(0b1110100) + '\x66' + chr(0b101101) + chr(56)), xafqLlk3kkUe(CZHnRGuVVrOs, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15g`\xa9\xa3\x0cyk[\xda\xc0='), chr(100) + chr(2345 - 2244) + chr(1635 - 1536) + chr(6619 - 6508) + '\x64' + chr(3981 - 3880))(chr(117) + '\164' + '\x66' + chr(0b101101) + '\x38')))
return WYuPioNR_sqI
|
allenai/allennlp
|
allennlp/common/file_utils.py
|
read_set_from_file
|
def read_set_from_file(filename: str) -> Set[str]:
"""
Extract a de-duped collection (set) of text from a file.
Expected file format is one item per line.
"""
collection = set()
with open(filename, 'r') as file_:
for line in file_:
collection.add(line.rstrip())
return collection
|
python
|
def read_set_from_file(filename: str) -> Set[str]:
"""
Extract a de-duped collection (set) of text from a file.
Expected file format is one item per line.
"""
collection = set()
with open(filename, 'r') as file_:
for line in file_:
collection.add(line.rstrip())
return collection
|
[
"def",
"read_set_from_file",
"(",
"filename",
":",
"str",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"collection",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"file_",
":",
"for",
"line",
"in",
"file_",
":",
"collection",
".",
"add",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"return",
"collection"
] |
Extract a de-duped collection (set) of text from a file.
Expected file format is one item per line.
|
[
"Extract",
"a",
"de",
"-",
"duped",
"collection",
"(",
"set",
")",
"of",
"text",
"from",
"a",
"file",
".",
"Expected",
"file",
"format",
"is",
"one",
"item",
"per",
"line",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/file_utils.py#L239-L248
|
train
|
Extract a de - duped collection of text from a file.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPth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k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\x30' + '\157' + chr(282 - 232) + chr(52) + chr(1514 - 1461), 64067 - 64059), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(315 - 264) + chr(0b11101 + 0o27) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(1311 - 1200) + '\063' + '\x36' + chr(1323 - 1270), 0o10), ehT0Px3KOsy9(chr(1691 - 1643) + chr(0b10000 + 0o137) + chr(0b1111 + 0o42) + '\x35' + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\157' + chr(0b110010) + '\x34' + chr(0b11111 + 0o23), 0o10), ehT0Px3KOsy9(chr(48) + chr(9089 - 8978) + chr(54), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(1501 - 1452) + chr(54) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b11101 + 0o26), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4319 - 4208) + chr(0b100011 + 0o20) + chr(0b110111) + chr(52), 3081 - 3073), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(50) + '\x33' + '\066', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101011 + 0o4) + chr(50) + '\067' + chr(48), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(55), 34992 - 34984), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\157' + '\x33' + chr(991 - 943) + chr(0b11111 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + chr(2284 - 2235) + '\x30' + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(7675 - 7564) + '\x31' + '\064' + chr(0b1000 + 0o55), 62150 - 62142), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10111 + 0o33) + '\x36' + chr(54), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(829 - 779) + chr(2091 - 2040) + chr(0b110110), 8), ehT0Px3KOsy9('\060' + chr(111) + chr(0b101100 + 0o6) + chr(1939 - 1884), 8), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1011000 + 0o27) + '\062' + chr(1494 - 1439) + chr(0b11000 + 0o33), ord("\x08")), ehT0Px3KOsy9(chr(894 - 846) + '\x6f' + '\x31' + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b110101), 31505 - 31497), ehT0Px3KOsy9(chr(48) + chr(10686 - 10575) + chr(0b110010) + '\060' + chr(2116 - 2068), 344 - 336), ehT0Px3KOsy9('\060' + chr(0b1000001 + 0o56) + chr(1990 - 1941) + chr(0b11100 + 0o31) + '\x33', 54164 - 54156), ehT0Px3KOsy9(chr(1600 - 1552) + chr(6116 - 6005) + chr(0b101100 + 0o5) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b10101 + 0o34) + '\065', 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(50) + chr(0b110111) + '\x36', 0b1000), ehT0Px3KOsy9(chr(1281 - 1233) + chr(0b1101111) + '\063' + chr(0b10101 + 0o42) + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(1293 - 1245) + chr(0b1101111) + chr(50) + '\x33' + '\066', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\064' + '\x30', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + '\064' + chr(50), 0o10), ehT0Px3KOsy9(chr(1735 - 1687) + '\157' + chr(0b110011) + '\x30' + chr(0b110000), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + '\060' + '\060', 14647 - 14639), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + '\x33' + chr(0b110111) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(348 - 299) + '\x30' + '\067', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(530 - 479) + chr(49) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(0b1010011 + 0o34) + chr(1708 - 1658) + chr(0b110001) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(2107 - 2059) + chr(111) + '\063' + '\062' + chr(50), 0b1000), ehT0Px3KOsy9(chr(1797 - 1749) + '\x6f' + '\x32' + chr(700 - 646) + chr(336 - 284), 48126 - 48118), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + '\067' + chr(0b10110 + 0o36), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + '\157' + '\x35' + '\x30', 5652 - 5644)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x8b'), chr(0b1000110 + 0o36) + '\x65' + chr(0b11100 + 0o107) + chr(0b1101111) + chr(2280 - 2180) + chr(0b1100101))('\x75' + '\x74' + chr(0b1100110) + chr(1345 - 1300) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Ztvt9zbOiqb6(xw4DsBfIJ22E) -> nRCEkXkGnMeI[M8_cKLkHVB2V]:
ftKNTjy9Pkr_ = MVEN8G6CxlvR()
with _fwkIVCGgtAN(xw4DsBfIJ22E, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(100) + chr(101) + chr(99) + '\157' + chr(0b10101 + 0o117) + chr(0b101001 + 0o74))(chr(0b1110101) + '\x74' + chr(102) + chr(45) + '\x38')) as vOFiaE6LRkQi:
for LycYkDpyelF6 in vOFiaE6LRkQi:
xafqLlk3kkUe(ftKNTjy9Pkr_, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0\xa9\xc5\x1e\x9be76\xa6\xd1\xea$'), chr(100) + chr(0b100010 + 0o103) + chr(1594 - 1495) + '\157' + chr(5307 - 5207) + chr(0b1100101))('\165' + chr(116) + chr(102) + '\x2d' + chr(0b101010 + 0o16)))(xafqLlk3kkUe(LycYkDpyelF6, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7\x90\x81\x1d\xcbv'), chr(0b1100100) + chr(5020 - 4919) + chr(99) + '\157' + chr(100) + chr(0b10111 + 0o116))(chr(0b10000 + 0o145) + chr(0b111110 + 0o66) + chr(0b11 + 0o143) + '\055' + chr(1966 - 1910)))())
return ftKNTjy9Pkr_
|
allenai/allennlp
|
scripts/reformat_text2sql_data.py
|
main
|
def main(output_directory: int, data: str) -> None:
"""
Processes the text2sql data into the following directory structure:
``dataset/{query_split, question_split}/{train,dev,test}.json``
for datasets which have train, dev and test splits, or:
``dataset/{query_split, question_split}/{split_{split_id}}.json``
for datasets which use cross validation.
The JSON format is identical to the original datasets, apart from they
are split into separate files with respect to the split_type. This means that
for the question split, all of the sql data is duplicated for each sentence
which is bucketed together as having the same semantics.
As an example, the following blob would be put "as-is" into the query split
dataset, and split into two datasets with identical blobs for the question split,
differing only in the "sentence" key, where blob1 would end up in the train split
and blob2 would be in the dev split, with the rest of the json duplicated in each.
{
"comments": [],
"old-name": "",
"query-split": "train",
"sentences": [{blob1, "question-split": "train"}, {blob2, "question-split": "dev"}],
"sql": [],
"variables": []
},
Parameters
----------
output_directory : str, required.
The output directory.
data: str, default = None
The path to the data director of https://github.com/jkkummerfeld/text2sql-data.
"""
json_files = glob.glob(os.path.join(data, "*.json"))
for dataset in json_files:
dataset_name = os.path.basename(dataset)[:-5]
print(f"Processing dataset: {dataset} into query and question "
f"splits at output path: {output_directory + '/' + dataset_name}")
full_dataset = json.load(open(dataset))
if not isinstance(full_dataset, list):
full_dataset = [full_dataset]
for split_type in ["query_split", "question_split"]:
dataset_out = os.path.join(output_directory, dataset_name, split_type)
for split, split_dataset in process_dataset(full_dataset, split_type):
dataset_out = os.path.join(output_directory, dataset_name, split_type)
os.makedirs(dataset_out, exist_ok=True)
json.dump(split_dataset, open(os.path.join(dataset_out, split), "w"), indent=4)
|
python
|
def main(output_directory: int, data: str) -> None:
"""
Processes the text2sql data into the following directory structure:
``dataset/{query_split, question_split}/{train,dev,test}.json``
for datasets which have train, dev and test splits, or:
``dataset/{query_split, question_split}/{split_{split_id}}.json``
for datasets which use cross validation.
The JSON format is identical to the original datasets, apart from they
are split into separate files with respect to the split_type. This means that
for the question split, all of the sql data is duplicated for each sentence
which is bucketed together as having the same semantics.
As an example, the following blob would be put "as-is" into the query split
dataset, and split into two datasets with identical blobs for the question split,
differing only in the "sentence" key, where blob1 would end up in the train split
and blob2 would be in the dev split, with the rest of the json duplicated in each.
{
"comments": [],
"old-name": "",
"query-split": "train",
"sentences": [{blob1, "question-split": "train"}, {blob2, "question-split": "dev"}],
"sql": [],
"variables": []
},
Parameters
----------
output_directory : str, required.
The output directory.
data: str, default = None
The path to the data director of https://github.com/jkkummerfeld/text2sql-data.
"""
json_files = glob.glob(os.path.join(data, "*.json"))
for dataset in json_files:
dataset_name = os.path.basename(dataset)[:-5]
print(f"Processing dataset: {dataset} into query and question "
f"splits at output path: {output_directory + '/' + dataset_name}")
full_dataset = json.load(open(dataset))
if not isinstance(full_dataset, list):
full_dataset = [full_dataset]
for split_type in ["query_split", "question_split"]:
dataset_out = os.path.join(output_directory, dataset_name, split_type)
for split, split_dataset in process_dataset(full_dataset, split_type):
dataset_out = os.path.join(output_directory, dataset_name, split_type)
os.makedirs(dataset_out, exist_ok=True)
json.dump(split_dataset, open(os.path.join(dataset_out, split), "w"), indent=4)
|
[
"def",
"main",
"(",
"output_directory",
":",
"int",
",",
"data",
":",
"str",
")",
"->",
"None",
":",
"json_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data",
",",
"\"*.json\"",
")",
")",
"for",
"dataset",
"in",
"json_files",
":",
"dataset_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"dataset",
")",
"[",
":",
"-",
"5",
"]",
"print",
"(",
"f\"Processing dataset: {dataset} into query and question \"",
"f\"splits at output path: {output_directory + '/' + dataset_name}\"",
")",
"full_dataset",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"dataset",
")",
")",
"if",
"not",
"isinstance",
"(",
"full_dataset",
",",
"list",
")",
":",
"full_dataset",
"=",
"[",
"full_dataset",
"]",
"for",
"split_type",
"in",
"[",
"\"query_split\"",
",",
"\"question_split\"",
"]",
":",
"dataset_out",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_directory",
",",
"dataset_name",
",",
"split_type",
")",
"for",
"split",
",",
"split_dataset",
"in",
"process_dataset",
"(",
"full_dataset",
",",
"split_type",
")",
":",
"dataset_out",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_directory",
",",
"dataset_name",
",",
"split_type",
")",
"os",
".",
"makedirs",
"(",
"dataset_out",
",",
"exist_ok",
"=",
"True",
")",
"json",
".",
"dump",
"(",
"split_dataset",
",",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dataset_out",
",",
"split",
")",
",",
"\"w\"",
")",
",",
"indent",
"=",
"4",
")"
] |
Processes the text2sql data into the following directory structure:
``dataset/{query_split, question_split}/{train,dev,test}.json``
for datasets which have train, dev and test splits, or:
``dataset/{query_split, question_split}/{split_{split_id}}.json``
for datasets which use cross validation.
The JSON format is identical to the original datasets, apart from they
are split into separate files with respect to the split_type. This means that
for the question split, all of the sql data is duplicated for each sentence
which is bucketed together as having the same semantics.
As an example, the following blob would be put "as-is" into the query split
dataset, and split into two datasets with identical blobs for the question split,
differing only in the "sentence" key, where blob1 would end up in the train split
and blob2 would be in the dev split, with the rest of the json duplicated in each.
{
"comments": [],
"old-name": "",
"query-split": "train",
"sentences": [{blob1, "question-split": "train"}, {blob2, "question-split": "dev"}],
"sql": [],
"variables": []
},
Parameters
----------
output_directory : str, required.
The output directory.
data: str, default = None
The path to the data director of https://github.com/jkkummerfeld/text2sql-data.
|
[
"Processes",
"the",
"text2sql",
"data",
"into",
"the",
"following",
"directory",
"structure",
":"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/reformat_text2sql_data.py#L38-L91
|
train
|
This function processes the text2sql data into a single tree structure.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Z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kL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(321 - 273) + chr(0b1101111) + chr(0b110001) + chr(0b110011) + '\x34', 0o10), ehT0Px3KOsy9('\x30' + chr(9928 - 9817) + chr(0b110001) + chr(51) + chr(0b11011 + 0o26), 41578 - 41570), ehT0Px3KOsy9('\x30' + chr(111) + '\061' + chr(0b101 + 0o54) + chr(51), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\064' + '\062', 0b1000), ehT0Px3KOsy9(chr(1303 - 1255) + chr(111) + chr(1337 - 1288) + '\062' + '\066', 64442 - 64434), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10000 + 0o41) + '\x32' + chr(0b110111), 15269 - 15261), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(8545 - 8434) + chr(1840 - 1789) + chr(0b10101 + 0o34) + chr(0b10001 + 0o45), 48512 - 48504), ehT0Px3KOsy9('\x30' + chr(0b1100010 + 0o15) + chr(0b10001 + 0o40) + chr(2573 - 2522) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(0b1101111) + '\062' + chr(1454 - 1404) + chr(49), 18351 - 18343), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b10011 + 0o37) + '\066' + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(2361 - 2250) + chr(0b110001) + '\062' + chr(2219 - 2164), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2069 - 2020) + '\067' + chr(0b0 + 0o66), 2962 - 2954), ehT0Px3KOsy9('\060' + chr(0b1000 + 0o147) + chr(0b100010 + 0o21) + chr(0b101111 + 0o10) + chr(0b110010 + 0o1), 0b1000), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(5652 - 5541) + chr(0b110001) + '\067' + chr(54), 8), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(55) + chr(2566 - 2512), 0b1000), ehT0Px3KOsy9(chr(2153 - 2105) + '\157' + chr(1891 - 1841) + chr(0b11100 + 0o30) + chr(1743 - 1694), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2361 - 2312) + chr(1795 - 1746) + '\067', 31465 - 31457), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + '\x35', 12483 - 12475), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(206 - 155) + chr(2043 - 1990) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b100100 + 0o14) + chr(0b1100001 + 0o16) + chr(2123 - 2068) + chr(0b110000), 36116 - 36108), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + '\065' + chr(0b11001 + 0o31), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(111) + chr(0b100010 + 0o20) + chr(48) + chr(0b11001 + 0o27), 0b1000), ehT0Px3KOsy9(chr(1638 - 1590) + chr(10643 - 10532) + chr(49) + '\065', 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\x31' + '\065' + chr(218 - 166), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1188 - 1133) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b10011 + 0o36) + '\063' + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b100001 + 0o116) + chr(1107 - 1057) + chr(0b10110 + 0o34) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(7927 - 7816) + '\062' + chr(0b111 + 0o53) + '\x33', ord("\x08")), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\x6f' + chr(0b110001) + '\x35' + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110110) + '\060', 7231 - 7223), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000011 + 0o54) + chr(49) + '\061', 0o10), ehT0Px3KOsy9(chr(1437 - 1389) + '\x6f' + chr(0b101010 + 0o10) + chr(1411 - 1363) + chr(0b101000 + 0o17), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(0b110010) + chr(50), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b101001 + 0o106) + '\062' + '\x36' + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b111 + 0o51) + chr(0b1101111) + '\062' + chr(0b110101) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(1146 - 1098) + chr(111) + chr(0b110010) + chr(0b110011) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + chr(50) + '\x37' + chr(53), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + '\062' + '\061', 8), ehT0Px3KOsy9('\060' + chr(0b1000000 + 0o57) + chr(0b110010) + '\x36' + chr(0b110101), 8), ehT0Px3KOsy9(chr(48) + chr(0b1011010 + 0o25) + chr(51) + '\x30' + chr(0b10011 + 0o43), 35538 - 35530)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b100110 + 0o17) + '\060', 26797 - 26789)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'r'), chr(2678 - 2578) + chr(0b1100101) + '\143' + chr(3830 - 3719) + '\144' + '\145')(chr(13071 - 12954) + chr(116) + '\146' + chr(45) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def PGNrezus7XpS(D5hpLsfkRs0F, ULnjp6D6efFH) -> None:
cu3NSmKt5Qtx = jt2o3b6QEdP_.glob(oqhJDdMJfuwx.path._oWXztVNnqHF(ULnjp6D6efFH, xafqLlk3kkUe(SXOLrMavuUCe(b'vw!Q99'), chr(0b11 + 0o141) + chr(2743 - 2642) + chr(0b1100011) + chr(0b1101011 + 0o4) + chr(0b1100100) + chr(4405 - 4304))('\x75' + '\x74' + chr(4782 - 4680) + chr(714 - 669) + chr(0b111000))))
for xQt6gV9VfTO3 in cu3NSmKt5Qtx:
p_vJ076GqAjR = oqhJDdMJfuwx.path.basename(xQt6gV9VfTO3)[:-ehT0Px3KOsy9(chr(0b101101 + 0o3) + chr(0b1101111) + chr(0b110101), ord("\x08"))]
zLUzGokYBM2Z(f"Processing dataset: {xQt6gV9VfTO3} into query and question splits at output path: {D5hpLsfkRs0F + chr(1185 - 1138) + p_vJ076GqAjR}")
m6fGxjtXyq4P = fXk443epxtd5.mxtdQMeiwJZJ(_fwkIVCGgtAN(xQt6gV9VfTO3))
if not PlSM16l2KDPD(m6fGxjtXyq4P, YyaZ4tpXu4lf):
m6fGxjtXyq4P = [m6fGxjtXyq4P]
for ysnCyWsVMdPp in [xafqLlk3kkUe(SXOLrMavuUCe(b'-,.P/\x08\xbd*\xfd\xde#'), chr(0b1100100) + '\x65' + '\x63' + '\x6f' + '\144' + chr(101))(chr(0b1101111 + 0o6) + '\164' + chr(0b1100110) + chr(45) + chr(56)), xafqLlk3kkUe(SXOLrMavuUCe(b'-,.Q">\xa14\xce\xc4\'\x12\x92\n'), chr(3429 - 3329) + chr(101) + chr(0b1 + 0o142) + chr(111) + chr(0b1100100) + '\145')('\165' + chr(116) + '\146' + chr(45) + chr(0b111000))]:
Ta8ZArnlFoYn = oqhJDdMJfuwx.path._oWXztVNnqHF(D5hpLsfkRs0F, p_vJ076GqAjR, ysnCyWsVMdPp)
for (vsJU7GhuEuh6, bKp4HHP8CiQf) in g33ugSmdyUno(m6fGxjtXyq4P, ysnCyWsVMdPp):
Ta8ZArnlFoYn = oqhJDdMJfuwx.path._oWXztVNnqHF(D5hpLsfkRs0F, p_vJ076GqAjR, ysnCyWsVMdPp)
xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'18 G2>\xbc)'), chr(0b1100100) + '\145' + '\143' + chr(0b110101 + 0o72) + chr(0b1000 + 0o134) + chr(0b1011010 + 0o13))('\x75' + '\164' + '\146' + '\055' + chr(0b1 + 0o67)))(Ta8ZArnlFoYn, exist_ok=ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(111) + chr(0b101111 + 0o2), ord("\x08")))
xafqLlk3kkUe(fXk443epxtd5, xafqLlk3kkUe(SXOLrMavuUCe(b'8,&R'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(0b1100110 + 0o11) + '\144' + '\x65')(chr(0b110110 + 0o77) + chr(116) + chr(0b100111 + 0o77) + '\x2d' + chr(2336 - 2280)))(bKp4HHP8CiQf, _fwkIVCGgtAN(xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\x036\x1cz,#\x98\x14\xff\xc6\x1f8'), chr(6580 - 6480) + '\145' + chr(0b1100011) + chr(0b101 + 0o152) + '\x64' + '\145')(chr(117) + chr(2251 - 2135) + chr(0b1100011 + 0o3) + '\055' + '\x38'))(Ta8ZArnlFoYn, vsJU7GhuEuh6), xafqLlk3kkUe(SXOLrMavuUCe(b'+'), chr(8803 - 8703) + '\145' + chr(99) + '\x6f' + '\x64' + chr(101))(chr(117) + chr(116) + chr(1853 - 1751) + chr(624 - 579) + chr(0b111000))), indent=ehT0Px3KOsy9('\x30' + chr(0b1011 + 0o144) + '\064', ord("\x08")))
|
allenai/allennlp
|
allennlp/semparse/type_declarations/wikitables_lambda_dcs.py
|
ArgExtremeType.resolve
|
def resolve(self, other: Type) -> Optional[Type]:
"""See ``PlaceholderType.resolve``"""
if not isinstance(other, NltkComplexType):
return None
expected_second = ComplexType(NUMBER_TYPE,
ComplexType(ANY_TYPE, ComplexType(ComplexType(ANY_TYPE, ANY_TYPE),
ANY_TYPE)))
resolved_second = other.second.resolve(expected_second)
if resolved_second is None:
return None
# The lambda function that we use inside the argmax must take either a number or a date as
# an argument.
lambda_arg_type = other.second.second.second.first.first
if lambda_arg_type.resolve(NUMBER_TYPE) is None and lambda_arg_type.resolve(DATE_TYPE) is None:
return None
try:
# This is the first #1 in the type signature above.
selector_function_type = resolved_second.second.first
# This is the second #1 in the type signature above.
quant_function_argument_type = resolved_second.second.second.first.second
# This is the third #1 in the type signature above.
return_type = resolved_second.second.second.second
# All three placeholder (ph) types above should resolve against each other.
resolved_first_ph = selector_function_type.resolve(quant_function_argument_type)
resolved_first_ph.resolve(return_type)
resolved_second_ph = quant_function_argument_type.resolve(resolved_first_ph)
resolved_second_ph.resolve(return_type)
resolved_third_ph = return_type.resolve(resolved_first_ph)
resolved_third_ph = return_type.resolve(resolved_second_ph)
if not resolved_first_ph or not resolved_second_ph or not resolved_third_ph:
return None
return ArgExtremeType(resolved_first_ph, lambda_arg_type)
except AttributeError:
return None
|
python
|
def resolve(self, other: Type) -> Optional[Type]:
"""See ``PlaceholderType.resolve``"""
if not isinstance(other, NltkComplexType):
return None
expected_second = ComplexType(NUMBER_TYPE,
ComplexType(ANY_TYPE, ComplexType(ComplexType(ANY_TYPE, ANY_TYPE),
ANY_TYPE)))
resolved_second = other.second.resolve(expected_second)
if resolved_second is None:
return None
# The lambda function that we use inside the argmax must take either a number or a date as
# an argument.
lambda_arg_type = other.second.second.second.first.first
if lambda_arg_type.resolve(NUMBER_TYPE) is None and lambda_arg_type.resolve(DATE_TYPE) is None:
return None
try:
# This is the first #1 in the type signature above.
selector_function_type = resolved_second.second.first
# This is the second #1 in the type signature above.
quant_function_argument_type = resolved_second.second.second.first.second
# This is the third #1 in the type signature above.
return_type = resolved_second.second.second.second
# All three placeholder (ph) types above should resolve against each other.
resolved_first_ph = selector_function_type.resolve(quant_function_argument_type)
resolved_first_ph.resolve(return_type)
resolved_second_ph = quant_function_argument_type.resolve(resolved_first_ph)
resolved_second_ph.resolve(return_type)
resolved_third_ph = return_type.resolve(resolved_first_ph)
resolved_third_ph = return_type.resolve(resolved_second_ph)
if not resolved_first_ph or not resolved_second_ph or not resolved_third_ph:
return None
return ArgExtremeType(resolved_first_ph, lambda_arg_type)
except AttributeError:
return None
|
[
"def",
"resolve",
"(",
"self",
",",
"other",
":",
"Type",
")",
"->",
"Optional",
"[",
"Type",
"]",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NltkComplexType",
")",
":",
"return",
"None",
"expected_second",
"=",
"ComplexType",
"(",
"NUMBER_TYPE",
",",
"ComplexType",
"(",
"ANY_TYPE",
",",
"ComplexType",
"(",
"ComplexType",
"(",
"ANY_TYPE",
",",
"ANY_TYPE",
")",
",",
"ANY_TYPE",
")",
")",
")",
"resolved_second",
"=",
"other",
".",
"second",
".",
"resolve",
"(",
"expected_second",
")",
"if",
"resolved_second",
"is",
"None",
":",
"return",
"None",
"# The lambda function that we use inside the argmax must take either a number or a date as",
"# an argument.",
"lambda_arg_type",
"=",
"other",
".",
"second",
".",
"second",
".",
"second",
".",
"first",
".",
"first",
"if",
"lambda_arg_type",
".",
"resolve",
"(",
"NUMBER_TYPE",
")",
"is",
"None",
"and",
"lambda_arg_type",
".",
"resolve",
"(",
"DATE_TYPE",
")",
"is",
"None",
":",
"return",
"None",
"try",
":",
"# This is the first #1 in the type signature above.",
"selector_function_type",
"=",
"resolved_second",
".",
"second",
".",
"first",
"# This is the second #1 in the type signature above.",
"quant_function_argument_type",
"=",
"resolved_second",
".",
"second",
".",
"second",
".",
"first",
".",
"second",
"# This is the third #1 in the type signature above.",
"return_type",
"=",
"resolved_second",
".",
"second",
".",
"second",
".",
"second",
"# All three placeholder (ph) types above should resolve against each other.",
"resolved_first_ph",
"=",
"selector_function_type",
".",
"resolve",
"(",
"quant_function_argument_type",
")",
"resolved_first_ph",
".",
"resolve",
"(",
"return_type",
")",
"resolved_second_ph",
"=",
"quant_function_argument_type",
".",
"resolve",
"(",
"resolved_first_ph",
")",
"resolved_second_ph",
".",
"resolve",
"(",
"return_type",
")",
"resolved_third_ph",
"=",
"return_type",
".",
"resolve",
"(",
"resolved_first_ph",
")",
"resolved_third_ph",
"=",
"return_type",
".",
"resolve",
"(",
"resolved_second_ph",
")",
"if",
"not",
"resolved_first_ph",
"or",
"not",
"resolved_second_ph",
"or",
"not",
"resolved_third_ph",
":",
"return",
"None",
"return",
"ArgExtremeType",
"(",
"resolved_first_ph",
",",
"lambda_arg_type",
")",
"except",
"AttributeError",
":",
"return",
"None"
] |
See ``PlaceholderType.resolve``
|
[
"See",
"PlaceholderType",
".",
"resolve"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/type_declarations/wikitables_lambda_dcs.py#L83-L123
|
train
|
Resolves the type signature of two NltkComplexTypes and returns the corresponding type.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,g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LpS8s,QOfmzcVJsrp8,tzcpInYwBvYW,iDQ_gSK8V7h0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(111) + '\x31' + '\x30' + chr(55), 0b1000), ehT0Px3KOsy9(chr(1451 - 1403) + chr(0b1 + 0o156) + chr(0b101001 + 0o10) + chr(2418 - 2368) + chr(0b11110 + 0o23), 0o10), ehT0Px3KOsy9('\x30' + chr(4534 - 4423) + chr(0b110011) + '\x33' + chr(0b110000), 46877 - 46869), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + '\x33' + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + chr(2151 - 2101) + chr(2356 - 2302) + chr(1524 - 1469), ord("\x08")), ehT0Px3KOsy9('\060' + chr(576 - 465) + chr(0b110111) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(2115 - 2067) + chr(0b1000000 + 0o57) + chr(1769 - 1719) + chr(988 - 940) + chr(51), 0o10), ehT0Px3KOsy9(chr(2018 - 1970) + '\157' + '\067' + '\x36', 0b1000), ehT0Px3KOsy9(chr(939 - 891) + chr(0b1100110 + 0o11) + chr(0b110010) + chr(0b10110 + 0o37) + chr(52 - 2), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110010) + chr(0b11100 + 0o32) + chr(0b0 + 0o65), 0o10), ehT0Px3KOsy9(chr(345 - 297) + '\157' + chr(0b11101 + 0o26) + chr(0b100110 + 0o21) + chr(1669 - 1614), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(421 - 373) + '\157' + chr(1235 - 1184) + chr(55) + chr(2180 - 2130), 55991 - 55983), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b101 + 0o54) + '\061' + '\x34', 32695 - 32687), ehT0Px3KOsy9(chr(0b110000) + chr(0b10001 + 0o136) + chr(0b110011) + chr(48), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(2456 - 2406) + chr(0b110010 + 0o3), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(0b110111) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(1539 - 1491) + chr(1307 - 1196) + chr(0b101110 + 0o4) + '\x32' + '\x35', 43584 - 43576), ehT0Px3KOsy9(chr(654 - 606) + '\157' + chr(452 - 402) + '\061' + chr(0b10110 + 0o32), 0o10), ehT0Px3KOsy9(chr(1805 - 1757) + chr(0b1101111) + chr(622 - 571) + '\x35' + chr(48), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1111 + 0o140) + chr(0b101111 + 0o3) + chr(54) + chr(0b101111 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(1975 - 1927) + chr(0b1100110 + 0o11) + chr(0b110011) + '\067' + '\063', 0o10), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(0b1101111) + '\x33' + '\x30' + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(1168 - 1120) + chr(111) + chr(50) + '\067' + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1691 - 1643) + chr(0b1101111) + '\x33' + chr(0b110100) + chr(968 - 918), 0b1000), ehT0Px3KOsy9(chr(1245 - 1197) + '\157' + '\062' + chr(0b110100) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + '\x31' + '\066', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(51) + chr(0b1111 + 0o41) + '\064', 12942 - 12934), ehT0Px3KOsy9(chr(440 - 392) + '\x6f' + '\x36' + chr(839 - 791), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000011 + 0o54) + '\x31' + chr(52), 8), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\063' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011000 + 0o27) + chr(0b100111 + 0o12) + '\x31' + chr(1919 - 1867), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(51) + chr(0b100101 + 0o14) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + chr(0b10000 + 0o43) + chr(260 - 211) + chr(52), 43320 - 43312), ehT0Px3KOsy9(chr(48) + '\157' + chr(1505 - 1451) + '\x30', 8), ehT0Px3KOsy9(chr(48) + '\157' + '\061' + chr(1317 - 1263) + chr(55), 55234 - 55226), ehT0Px3KOsy9(chr(1088 - 1040) + '\157' + chr(0b110001), 21330 - 21322), ehT0Px3KOsy9('\x30' + chr(10468 - 10357) + chr(0b100111 + 0o14) + '\062', 0b1000), ehT0Px3KOsy9(chr(48) + chr(5382 - 5271) + '\066' + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b11100 + 0o24) + chr(11489 - 11378) + chr(1352 - 1297) + chr(0b110111), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b101001 + 0o7) + '\157' + '\065' + chr(151 - 103), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'i'), chr(100) + chr(0b1100101) + chr(0b1100011) + '\157' + chr(100) + chr(0b1100101))('\165' + '\x74' + chr(102) + '\055' + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def dctvAM1AW7Ye(oVre8I6UXc3b, KK0ERS7DqYrY) -> vi1g1wPnZvlE[_X5hXy25Wy5s]:
if not PlSM16l2KDPD(KK0ERS7DqYrY, T9eqK5bklWSI):
return None
EgCkTYOP_5CC = onk3DvZwSMl6(bN1Lyo8UJ4NS, onk3DvZwSMl6(bgK74uReTaM3, onk3DvZwSMl6(onk3DvZwSMl6(bgK74uReTaM3, bgK74uReTaM3), bgK74uReTaM3)))
VfDUS3nPlEGD = KK0ERS7DqYrY.second.resolve(EgCkTYOP_5CC)
if VfDUS3nPlEGD is None:
return None
XAwuysaXGANg = KK0ERS7DqYrY.second.second.second.first.It1LJs8swHZQ
if xafqLlk3kkUe(XAwuysaXGANg, xafqLlk3kkUe(SXOLrMavuUCe(b'54\xab\xb0\xdbO\xe6'), chr(100) + chr(101) + chr(99) + chr(0b1010110 + 0o31) + chr(0b1100100) + chr(101))(chr(117) + chr(0b1110100) + '\x66' + '\055' + chr(0b111000)))(bN1Lyo8UJ4NS) is None and xafqLlk3kkUe(XAwuysaXGANg, xafqLlk3kkUe(SXOLrMavuUCe(b'54\xab\xb0\xdbO\xe6'), '\144' + '\x65' + '\x63' + chr(111) + '\144' + chr(101))(chr(0b1110101) + chr(116) + chr(0b1100110) + '\055' + chr(56)))(xYkhicLaA5IP) is None:
return None
try:
TnLxu56QyYxG = VfDUS3nPlEGD.second.It1LJs8swHZQ
cKrHGpAP4yfr = VfDUS3nPlEGD.second.second.first.second
ELL59KGwZKj3 = VfDUS3nPlEGD.second.second.second
Wh1EyDwLQWgM = TnLxu56QyYxG.resolve(cKrHGpAP4yfr)
xafqLlk3kkUe(Wh1EyDwLQWgM, xafqLlk3kkUe(SXOLrMavuUCe(b'54\xab\xb0\xdbO\xe6'), chr(4409 - 4309) + chr(0b11010 + 0o113) + chr(0b1100011) + '\x6f' + chr(4844 - 4744) + '\145')('\x75' + '\x74' + chr(102) + chr(0b11001 + 0o24) + '\x38'))(ELL59KGwZKj3)
XYi9IpsEsIok = cKrHGpAP4yfr.resolve(Wh1EyDwLQWgM)
xafqLlk3kkUe(XYi9IpsEsIok, xafqLlk3kkUe(SXOLrMavuUCe(b'54\xab\xb0\xdbO\xe6'), chr(0b10100 + 0o120) + chr(101) + '\143' + chr(111) + chr(4317 - 4217) + chr(0b101011 + 0o72))('\x75' + chr(0b1000001 + 0o63) + chr(9076 - 8974) + chr(45) + chr(0b100101 + 0o23)))(ELL59KGwZKj3)
djUcBQTEcwAY = ELL59KGwZKj3.resolve(Wh1EyDwLQWgM)
djUcBQTEcwAY = ELL59KGwZKj3.resolve(XYi9IpsEsIok)
if not Wh1EyDwLQWgM or not XYi9IpsEsIok or (not djUcBQTEcwAY):
return None
return Bqrb_jRSysgB(Wh1EyDwLQWgM, XAwuysaXGANg)
except sHOWSIAKtU58:
return None
|
allenai/allennlp
|
allennlp/semparse/type_declarations/wikitables_lambda_dcs.py
|
CountType.resolve
|
def resolve(self, other: Type) -> Type:
"""See ``PlaceholderType.resolve``"""
if not isinstance(other, NltkComplexType):
return None
resolved_second = NUMBER_TYPE.resolve(other.second)
if not resolved_second:
return None
return CountType(other.first)
|
python
|
def resolve(self, other: Type) -> Type:
"""See ``PlaceholderType.resolve``"""
if not isinstance(other, NltkComplexType):
return None
resolved_second = NUMBER_TYPE.resolve(other.second)
if not resolved_second:
return None
return CountType(other.first)
|
[
"def",
"resolve",
"(",
"self",
",",
"other",
":",
"Type",
")",
"->",
"Type",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NltkComplexType",
")",
":",
"return",
"None",
"resolved_second",
"=",
"NUMBER_TYPE",
".",
"resolve",
"(",
"other",
".",
"second",
")",
"if",
"not",
"resolved_second",
":",
"return",
"None",
"return",
"CountType",
"(",
"other",
".",
"first",
")"
] |
See ``PlaceholderType.resolve``
|
[
"See",
"PlaceholderType",
".",
"resolve"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/type_declarations/wikitables_lambda_dcs.py#L149-L156
|
train
|
Resolve the type of other to the type of self.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3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I2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(745 - 697) + chr(0b1101111) + chr(0b11101 + 0o25) + chr(1693 - 1645) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(11728 - 11617) + chr(2255 - 2205) + chr(2086 - 2037) + chr(367 - 318), 19599 - 19591), ehT0Px3KOsy9(chr(48) + chr(7467 - 7356) + chr(0b110011) + '\063' + chr(0b1 + 0o61), 0o10), ehT0Px3KOsy9('\060' + chr(7413 - 7302) + chr(0b110010) + chr(0b110000) + chr(2679 - 2627), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b11001 + 0o126) + '\x32' + chr(49) + chr(53), 0o10), ehT0Px3KOsy9('\060' + chr(0b1000110 + 0o51) + chr(50) + chr(51), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + chr(0b110000), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\063' + '\061' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(0b110111) + chr(300 - 252), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\066' + chr(0b110111), 58527 - 58519), ehT0Px3KOsy9(chr(0b1111 + 0o41) + chr(9949 - 9838) + chr(0b111 + 0o52) + chr(1345 - 1297) + chr(0b1111 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b100001 + 0o116) + '\063' + chr(53) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(1025 - 977) + '\157' + chr(0b110011) + chr(2846 - 2792) + '\x30', 3776 - 3768), ehT0Px3KOsy9(chr(0b110000) + chr(0b1010010 + 0o35) + chr(0b110010) + chr(54) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10110 + 0o131) + chr(1112 - 1063) + chr(0b100100 + 0o14) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(1573 - 1525) + '\x6f' + '\061' + chr(0b110001), 62038 - 62030), ehT0Px3KOsy9(chr(0b110000) + chr(0b0 + 0o157) + chr(0b110001) + '\065', 0b1000), ehT0Px3KOsy9(chr(48) + chr(7367 - 7256) + chr(0b10110 + 0o36) + '\x37', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(48) + chr(1001 - 946), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(49) + '\x35' + '\066', 0b1000), ehT0Px3KOsy9(chr(48) + chr(4366 - 4255) + chr(0b110011) + chr(0b110010) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(4619 - 4508) + '\x33' + chr(0b10011 + 0o43) + '\067', 0b1000), ehT0Px3KOsy9(chr(857 - 809) + '\157' + chr(49) + '\x37' + '\063', 11400 - 11392), ehT0Px3KOsy9(chr(0b11 + 0o55) + chr(681 - 570) + '\x31' + chr(0b110110) + '\062', 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(111) + chr(0b1010 + 0o50) + chr(2568 - 2514) + '\063', 0b1000), ehT0Px3KOsy9(chr(780 - 732) + chr(2943 - 2832) + '\x31' + '\x32' + chr(1433 - 1384), 45526 - 45518), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\061' + chr(319 - 270) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(6734 - 6623) + '\x31' + chr(74 - 26) + chr(55), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\067' + chr(0b101 + 0o62), 0o10), ehT0Px3KOsy9(chr(48) + chr(4107 - 3996) + chr(50) + '\062' + chr(0b110101), 0o10), ehT0Px3KOsy9('\060' + chr(0b110100 + 0o73) + '\062' + chr(463 - 408) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(48) + chr(1064 - 953) + '\x35' + '\063', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1941 - 1889) + chr(1191 - 1139), 0b1000), ehT0Px3KOsy9(chr(911 - 863) + '\x6f' + '\x31' + '\x33' + chr(52), 993 - 985), ehT0Px3KOsy9(chr(0b110000) + chr(0b1011110 + 0o21) + chr(0b110010) + '\064' + chr(0b10000 + 0o40), 0o10), ehT0Px3KOsy9('\x30' + chr(3617 - 3506) + '\x35' + '\067', 27776 - 27768), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(49) + chr(432 - 380) + chr(55), 7637 - 7629), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110001) + chr(49) + '\x32', 34909 - 34901), ehT0Px3KOsy9(chr(384 - 336) + '\157' + chr(0b10011 + 0o37) + chr(1796 - 1747) + chr(0b110100), 11829 - 11821), ehT0Px3KOsy9(chr(1624 - 1576) + chr(0b10110 + 0o131) + '\x33' + chr(0b1101 + 0o47) + chr(0b1001 + 0o53), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(2066 - 2018) + '\x6f' + '\x35' + chr(48), 57222 - 57214)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), '\144' + chr(0b1010011 + 0o22) + chr(0b100 + 0o137) + '\x6f' + chr(0b1100100) + chr(101))('\x75' + chr(0b111110 + 0o66) + '\146' + '\055' + chr(0b10011 + 0o45)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def dctvAM1AW7Ye(oVre8I6UXc3b, KK0ERS7DqYrY) -> _X5hXy25Wy5s:
if not PlSM16l2KDPD(KK0ERS7DqYrY, T9eqK5bklWSI):
return None
VfDUS3nPlEGD = bN1Lyo8UJ4NS.resolve(KK0ERS7DqYrY.second)
if not VfDUS3nPlEGD:
return None
return RmHuX29pihDA(xafqLlk3kkUe(KK0ERS7DqYrY, xafqLlk3kkUe(SXOLrMavuUCe(b'\xcf\xfd\xeb\xc8\xc7`(\xbe\x0f\x7f\x1e\xbb'), '\144' + chr(0b1001111 + 0o26) + chr(0b11000 + 0o113) + chr(0b100100 + 0o113) + '\144' + chr(4185 - 4084))('\x75' + '\x74' + chr(10394 - 10292) + '\055' + chr(0b111000))))
|
allenai/allennlp
|
scripts/nlvr/get_nlvr_logical_forms.py
|
process_data
|
def process_data(input_file: str,
output_file: str,
max_path_length: int,
max_num_logical_forms: int,
ignore_agenda: bool,
write_sequences: bool) -> None:
"""
Reads an NLVR dataset and returns a JSON representation containing sentences, labels, correct and
incorrect logical forms. The output will contain at most `max_num_logical_forms` logical forms
each in both correct and incorrect lists. The output format is:
``[{"id": str, "label": str, "sentence": str, "correct": List[str], "incorrect": List[str]}]``
"""
processed_data: JsonDict = []
# We can instantiate the ``ActionSpaceWalker`` with any world because the action space is the
# same for all the ``NlvrWorlds``. It is just the execution that differs.
serialized_walker_path = f"serialized_action_space_walker_pl={max_path_length}.pkl"
if os.path.isfile(serialized_walker_path):
print("Reading walker from serialized file", file=sys.stderr)
walker = pickle.load(open(serialized_walker_path, "rb"))
else:
walker = ActionSpaceWalker(NlvrWorld({}), max_path_length=max_path_length)
pickle.dump(walker, open(serialized_walker_path, "wb"))
for line in open(input_file):
instance_id, sentence, structured_reps, label_strings = read_json_line(line)
worlds = [NlvrWorld(structured_rep) for structured_rep in structured_reps]
labels = [label_string == "true" for label_string in label_strings]
correct_logical_forms = []
incorrect_logical_forms = []
if ignore_agenda:
# Get 1000 shortest logical forms.
logical_forms = walker.get_all_logical_forms(max_num_logical_forms=1000)
else:
# TODO (pradeep): Assuming all worlds give the same agenda.
sentence_agenda = worlds[0].get_agenda_for_sentence(sentence, add_paths_to_agenda=False)
logical_forms = walker.get_logical_forms_with_agenda(sentence_agenda,
max_num_logical_forms * 10)
for logical_form in logical_forms:
if all([world.execute(logical_form) == label for world, label in zip(worlds, labels)]):
if len(correct_logical_forms) <= max_num_logical_forms:
correct_logical_forms.append(logical_form)
else:
if len(incorrect_logical_forms) <= max_num_logical_forms:
incorrect_logical_forms.append(logical_form)
if len(correct_logical_forms) >= max_num_logical_forms \
and len(incorrect_logical_forms) >= max_num_logical_forms:
break
if write_sequences:
parsed_correct_forms = [worlds[0].parse_logical_form(logical_form) for logical_form in
correct_logical_forms]
correct_sequences = [worlds[0].get_action_sequence(parsed_form) for parsed_form in
parsed_correct_forms]
parsed_incorrect_forms = [worlds[0].parse_logical_form(logical_form) for logical_form in
incorrect_logical_forms]
incorrect_sequences = [worlds[0].get_action_sequence(parsed_form) for parsed_form in
parsed_incorrect_forms]
processed_data.append({"id": instance_id,
"sentence": sentence,
"correct_sequences": correct_sequences,
"incorrect_sequences": incorrect_sequences,
"worlds": structured_reps,
"labels": label_strings})
else:
processed_data.append({"id": instance_id,
"sentence": sentence,
"correct_logical_forms": correct_logical_forms,
"incorrect_logical_forms": incorrect_logical_forms,
"worlds": structured_reps,
"labels": label_strings})
with open(output_file, "w") as outfile:
for instance_processed_data in processed_data:
json.dump(instance_processed_data, outfile)
outfile.write('\n')
outfile.close()
|
python
|
def process_data(input_file: str,
output_file: str,
max_path_length: int,
max_num_logical_forms: int,
ignore_agenda: bool,
write_sequences: bool) -> None:
"""
Reads an NLVR dataset and returns a JSON representation containing sentences, labels, correct and
incorrect logical forms. The output will contain at most `max_num_logical_forms` logical forms
each in both correct and incorrect lists. The output format is:
``[{"id": str, "label": str, "sentence": str, "correct": List[str], "incorrect": List[str]}]``
"""
processed_data: JsonDict = []
# We can instantiate the ``ActionSpaceWalker`` with any world because the action space is the
# same for all the ``NlvrWorlds``. It is just the execution that differs.
serialized_walker_path = f"serialized_action_space_walker_pl={max_path_length}.pkl"
if os.path.isfile(serialized_walker_path):
print("Reading walker from serialized file", file=sys.stderr)
walker = pickle.load(open(serialized_walker_path, "rb"))
else:
walker = ActionSpaceWalker(NlvrWorld({}), max_path_length=max_path_length)
pickle.dump(walker, open(serialized_walker_path, "wb"))
for line in open(input_file):
instance_id, sentence, structured_reps, label_strings = read_json_line(line)
worlds = [NlvrWorld(structured_rep) for structured_rep in structured_reps]
labels = [label_string == "true" for label_string in label_strings]
correct_logical_forms = []
incorrect_logical_forms = []
if ignore_agenda:
# Get 1000 shortest logical forms.
logical_forms = walker.get_all_logical_forms(max_num_logical_forms=1000)
else:
# TODO (pradeep): Assuming all worlds give the same agenda.
sentence_agenda = worlds[0].get_agenda_for_sentence(sentence, add_paths_to_agenda=False)
logical_forms = walker.get_logical_forms_with_agenda(sentence_agenda,
max_num_logical_forms * 10)
for logical_form in logical_forms:
if all([world.execute(logical_form) == label for world, label in zip(worlds, labels)]):
if len(correct_logical_forms) <= max_num_logical_forms:
correct_logical_forms.append(logical_form)
else:
if len(incorrect_logical_forms) <= max_num_logical_forms:
incorrect_logical_forms.append(logical_form)
if len(correct_logical_forms) >= max_num_logical_forms \
and len(incorrect_logical_forms) >= max_num_logical_forms:
break
if write_sequences:
parsed_correct_forms = [worlds[0].parse_logical_form(logical_form) for logical_form in
correct_logical_forms]
correct_sequences = [worlds[0].get_action_sequence(parsed_form) for parsed_form in
parsed_correct_forms]
parsed_incorrect_forms = [worlds[0].parse_logical_form(logical_form) for logical_form in
incorrect_logical_forms]
incorrect_sequences = [worlds[0].get_action_sequence(parsed_form) for parsed_form in
parsed_incorrect_forms]
processed_data.append({"id": instance_id,
"sentence": sentence,
"correct_sequences": correct_sequences,
"incorrect_sequences": incorrect_sequences,
"worlds": structured_reps,
"labels": label_strings})
else:
processed_data.append({"id": instance_id,
"sentence": sentence,
"correct_logical_forms": correct_logical_forms,
"incorrect_logical_forms": incorrect_logical_forms,
"worlds": structured_reps,
"labels": label_strings})
with open(output_file, "w") as outfile:
for instance_processed_data in processed_data:
json.dump(instance_processed_data, outfile)
outfile.write('\n')
outfile.close()
|
[
"def",
"process_data",
"(",
"input_file",
":",
"str",
",",
"output_file",
":",
"str",
",",
"max_path_length",
":",
"int",
",",
"max_num_logical_forms",
":",
"int",
",",
"ignore_agenda",
":",
"bool",
",",
"write_sequences",
":",
"bool",
")",
"->",
"None",
":",
"processed_data",
":",
"JsonDict",
"=",
"[",
"]",
"# We can instantiate the ``ActionSpaceWalker`` with any world because the action space is the",
"# same for all the ``NlvrWorlds``. It is just the execution that differs.",
"serialized_walker_path",
"=",
"f\"serialized_action_space_walker_pl={max_path_length}.pkl\"",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"serialized_walker_path",
")",
":",
"print",
"(",
"\"Reading walker from serialized file\"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"walker",
"=",
"pickle",
".",
"load",
"(",
"open",
"(",
"serialized_walker_path",
",",
"\"rb\"",
")",
")",
"else",
":",
"walker",
"=",
"ActionSpaceWalker",
"(",
"NlvrWorld",
"(",
"{",
"}",
")",
",",
"max_path_length",
"=",
"max_path_length",
")",
"pickle",
".",
"dump",
"(",
"walker",
",",
"open",
"(",
"serialized_walker_path",
",",
"\"wb\"",
")",
")",
"for",
"line",
"in",
"open",
"(",
"input_file",
")",
":",
"instance_id",
",",
"sentence",
",",
"structured_reps",
",",
"label_strings",
"=",
"read_json_line",
"(",
"line",
")",
"worlds",
"=",
"[",
"NlvrWorld",
"(",
"structured_rep",
")",
"for",
"structured_rep",
"in",
"structured_reps",
"]",
"labels",
"=",
"[",
"label_string",
"==",
"\"true\"",
"for",
"label_string",
"in",
"label_strings",
"]",
"correct_logical_forms",
"=",
"[",
"]",
"incorrect_logical_forms",
"=",
"[",
"]",
"if",
"ignore_agenda",
":",
"# Get 1000 shortest logical forms.",
"logical_forms",
"=",
"walker",
".",
"get_all_logical_forms",
"(",
"max_num_logical_forms",
"=",
"1000",
")",
"else",
":",
"# TODO (pradeep): Assuming all worlds give the same agenda.",
"sentence_agenda",
"=",
"worlds",
"[",
"0",
"]",
".",
"get_agenda_for_sentence",
"(",
"sentence",
",",
"add_paths_to_agenda",
"=",
"False",
")",
"logical_forms",
"=",
"walker",
".",
"get_logical_forms_with_agenda",
"(",
"sentence_agenda",
",",
"max_num_logical_forms",
"*",
"10",
")",
"for",
"logical_form",
"in",
"logical_forms",
":",
"if",
"all",
"(",
"[",
"world",
".",
"execute",
"(",
"logical_form",
")",
"==",
"label",
"for",
"world",
",",
"label",
"in",
"zip",
"(",
"worlds",
",",
"labels",
")",
"]",
")",
":",
"if",
"len",
"(",
"correct_logical_forms",
")",
"<=",
"max_num_logical_forms",
":",
"correct_logical_forms",
".",
"append",
"(",
"logical_form",
")",
"else",
":",
"if",
"len",
"(",
"incorrect_logical_forms",
")",
"<=",
"max_num_logical_forms",
":",
"incorrect_logical_forms",
".",
"append",
"(",
"logical_form",
")",
"if",
"len",
"(",
"correct_logical_forms",
")",
">=",
"max_num_logical_forms",
"and",
"len",
"(",
"incorrect_logical_forms",
")",
">=",
"max_num_logical_forms",
":",
"break",
"if",
"write_sequences",
":",
"parsed_correct_forms",
"=",
"[",
"worlds",
"[",
"0",
"]",
".",
"parse_logical_form",
"(",
"logical_form",
")",
"for",
"logical_form",
"in",
"correct_logical_forms",
"]",
"correct_sequences",
"=",
"[",
"worlds",
"[",
"0",
"]",
".",
"get_action_sequence",
"(",
"parsed_form",
")",
"for",
"parsed_form",
"in",
"parsed_correct_forms",
"]",
"parsed_incorrect_forms",
"=",
"[",
"worlds",
"[",
"0",
"]",
".",
"parse_logical_form",
"(",
"logical_form",
")",
"for",
"logical_form",
"in",
"incorrect_logical_forms",
"]",
"incorrect_sequences",
"=",
"[",
"worlds",
"[",
"0",
"]",
".",
"get_action_sequence",
"(",
"parsed_form",
")",
"for",
"parsed_form",
"in",
"parsed_incorrect_forms",
"]",
"processed_data",
".",
"append",
"(",
"{",
"\"id\"",
":",
"instance_id",
",",
"\"sentence\"",
":",
"sentence",
",",
"\"correct_sequences\"",
":",
"correct_sequences",
",",
"\"incorrect_sequences\"",
":",
"incorrect_sequences",
",",
"\"worlds\"",
":",
"structured_reps",
",",
"\"labels\"",
":",
"label_strings",
"}",
")",
"else",
":",
"processed_data",
".",
"append",
"(",
"{",
"\"id\"",
":",
"instance_id",
",",
"\"sentence\"",
":",
"sentence",
",",
"\"correct_logical_forms\"",
":",
"correct_logical_forms",
",",
"\"incorrect_logical_forms\"",
":",
"incorrect_logical_forms",
",",
"\"worlds\"",
":",
"structured_reps",
",",
"\"labels\"",
":",
"label_strings",
"}",
")",
"with",
"open",
"(",
"output_file",
",",
"\"w\"",
")",
"as",
"outfile",
":",
"for",
"instance_processed_data",
"in",
"processed_data",
":",
"json",
".",
"dump",
"(",
"instance_processed_data",
",",
"outfile",
")",
"outfile",
".",
"write",
"(",
"'\\n'",
")",
"outfile",
".",
"close",
"(",
")"
] |
Reads an NLVR dataset and returns a JSON representation containing sentences, labels, correct and
incorrect logical forms. The output will contain at most `max_num_logical_forms` logical forms
each in both correct and incorrect lists. The output format is:
``[{"id": str, "label": str, "sentence": str, "correct": List[str], "incorrect": List[str]}]``
|
[
"Reads",
"an",
"NLVR",
"dataset",
"and",
"returns",
"a",
"JSON",
"representation",
"containing",
"sentences",
"labels",
"correct",
"and",
"incorrect",
"logical",
"forms",
".",
"The",
"output",
"will",
"contain",
"at",
"most",
"max_num_logical_forms",
"logical",
"forms",
"each",
"in",
"both",
"correct",
"and",
"incorrect",
"lists",
".",
"The",
"output",
"format",
"is",
":",
"[",
"{",
"id",
":",
"str",
"label",
":",
"str",
"sentence",
":",
"str",
"correct",
":",
"List",
"[",
"str",
"]",
"incorrect",
":",
"List",
"[",
"str",
"]",
"}",
"]"
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/nlvr/get_nlvr_logical_forms.py#L32-L104
|
train
|
Reads an NLVR dataset and returns a JSON representation of the data.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuR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E,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(0b1010110 + 0o31) + chr(1057 - 1008) + chr(0b110100) + chr(0b101000 + 0o12), 20295 - 20287), ehT0Px3KOsy9('\060' + '\157' + chr(0b11110 + 0o25) + chr(190 - 140) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b11 + 0o56) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(0b1100 + 0o143) + chr(0b110011) + chr(1250 - 1196) + chr(0b11011 + 0o31), 45721 - 45713), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2358 - 2307) + '\062' + chr(2350 - 2300), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(9208 - 9097) + '\x32' + chr(0b100001 + 0o22) + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + chr(1246 - 1193) + '\062', 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + '\063' + chr(49), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(5149 - 5038) + '\063' + chr(0b101101 + 0o6) + chr(0b11010 + 0o27), 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b10110 + 0o33) + chr(0b11100 + 0o26) + '\x30', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1000001 + 0o56) + chr(0b110011) + chr(54) + chr(0b101011 + 0o6), 0b1000), ehT0Px3KOsy9('\060' + chr(12132 - 12021) + chr(0b10111 + 0o33) + chr(274 - 226) + chr(1866 - 1812), 11222 - 11214), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\061' + '\x36' + '\x34', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x32', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + '\065' + chr(0b110110), 11714 - 11706), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + chr(0b110110) + '\062', 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + chr(0b100000 + 0o21) + '\066' + chr(632 - 581), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10101 + 0o36) + chr(0b101111 + 0o5) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2462 - 2407), ord("\x08")), ehT0Px3KOsy9(chr(1137 - 1089) + chr(8394 - 8283) + chr(0b1000 + 0o52) + chr(2297 - 2246), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(54) + '\x32', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b101111 + 0o100) + '\x32' + chr(1437 - 1387) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(662 - 614) + '\157' + chr(50) + chr(0b110101) + '\063', 0b1000), ehT0Px3KOsy9(chr(1778 - 1730) + chr(0b1000000 + 0o57) + chr(2540 - 2486), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\063' + '\062' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b111 + 0o53) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(2413 - 2302) + chr(2446 - 2396) + chr(0b11000 + 0o30) + chr(1241 - 1193), 0o10), ehT0Px3KOsy9(chr(48) + chr(9254 - 9143) + chr(0b110011) + chr(0b110100) + chr(50), 0o10), ehT0Px3KOsy9('\x30' + chr(4693 - 4582) + chr(2401 - 2347), 8), ehT0Px3KOsy9('\060' + chr(111) + '\061' + chr(0b110111) + chr(0b101 + 0o60), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(1225 - 1174) + '\065' + chr(2414 - 2363), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b101110 + 0o3) + chr(0b1100 + 0o46) + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b110010 + 0o75) + chr(1896 - 1847) + '\x30' + '\x36', ord("\x08")), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(111) + chr(955 - 906) + '\x32', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1325 - 1275) + chr(0b110101) + chr(1215 - 1163), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(2614 - 2559) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(790 - 742) + chr(0b101 + 0o152) + chr(0b110010) + '\061' + chr(0b10100 + 0o41), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + '\x6f' + chr(51) + chr(2746 - 2691) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + chr(9128 - 9017) + chr(281 - 230) + chr(0b110001) + chr(0b110000), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(896 - 848) + chr(0b1101111) + '\x35' + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'L'), '\x64' + chr(0b110100 + 0o61) + chr(99) + '\x6f' + chr(718 - 618) + chr(101))(chr(117) + chr(0b1110100) + '\146' + chr(132 - 87) + chr(56)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def bi5qAQxgA8NU(ZS43hVvGhK4C, mkvzj_PhLPP2, P0_2Hzww0XlY, JSu18uxNdEXR, BzxeQWvQ3GaN, eFoTdKLG4F6P) -> None:
Aq7y0fJIkLo6 = []
qItacBEd14S7 = f'serialized_action_space_walker_pl={P0_2Hzww0XlY}.pkl'
if xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xa6\xab\x9d\xbe\xfd'), chr(6541 - 6441) + chr(1153 - 1052) + '\143' + chr(2024 - 1913) + chr(100) + chr(0b110011 + 0o62))(chr(0b1110101) + chr(116) + '\x66' + chr(1236 - 1191) + chr(0b11111 + 0o31)))(qItacBEd14S7):
zLUzGokYBM2Z(xafqLlk3kkUe(SXOLrMavuUCe(b"0\xb0\xac\x90\xbb\xf6\xcdy\xae1\x9d\xed\x11p\xce\x14\x01j\x88'`\x97\xe1\xc2g\xbc{\xfa\x87b]\x8d<*o"), '\x64' + chr(0b100101 + 0o100) + '\x63' + chr(0b1101111) + '\144' + '\145')(chr(2360 - 2243) + '\x74' + '\146' + chr(0b101101) + chr(56)), file=xafqLlk3kkUe(a2SYDDomXDZ2, xafqLlk3kkUe(SXOLrMavuUCe(b'#\xe6\xbd\x90\xab\xe9\xc2+\x83\x06\xa3\xcd'), chr(100) + chr(7687 - 7586) + chr(99) + chr(0b1101111) + '\x64' + chr(101))('\x75' + chr(0b111 + 0o155) + chr(0b1011000 + 0o16) + chr(0b101101) + '\070')))
nchsoADJWuln = b1Ng5DsPF9ZY.mxtdQMeiwJZJ(_fwkIVCGgtAN(qItacBEd14S7, xafqLlk3kkUe(SXOLrMavuUCe(b'\x10\xb7'), chr(0b1100100) + '\145' + chr(2751 - 2652) + '\157' + chr(5830 - 5730) + chr(0b1100101))(chr(0b1001011 + 0o52) + chr(0b1110100) + chr(0b1100110) + chr(1378 - 1333) + chr(0b101101 + 0o13))))
else:
nchsoADJWuln = sxUDJWUAm7E_(SQwrmoH9LLyI({}), max_path_length=P0_2Hzww0XlY)
xafqLlk3kkUe(b1Ng5DsPF9ZY, xafqLlk3kkUe(SXOLrMavuUCe(b'\x06\xa0\xa0\x84'), chr(0b1100100) + '\145' + '\x63' + chr(111) + '\144' + chr(0b1011101 + 0o10))(chr(6556 - 6439) + '\x74' + '\x66' + '\055' + '\070'))(nchsoADJWuln, _fwkIVCGgtAN(qItacBEd14S7, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\xb7'), chr(0b1100100) + chr(0b1000011 + 0o42) + chr(0b1100011) + chr(0b1100001 + 0o16) + chr(4898 - 4798) + '\x65')('\x75' + chr(3335 - 3219) + chr(102) + '\x2d' + chr(0b111000))))
for LycYkDpyelF6 in _fwkIVCGgtAN(ZS43hVvGhK4C):
(pj8u1hDpF7b4, pamQPTGoym5v, aXwdfXbZcS8V, IHbm0hP4I074) = QJ5OhZ6XmvnQ(LycYkDpyelF6)
bAEvLqWX737r = [SQwrmoH9LLyI(VnWcQnjcCNd5) for VnWcQnjcCNd5 in aXwdfXbZcS8V]
uXMK81tmdpTM = [an_u38qr8QsB == xafqLlk3kkUe(SXOLrMavuUCe(b'\x16\xa7\xb8\x91'), chr(0b1100100) + chr(101) + chr(3967 - 3868) + chr(111) + chr(1865 - 1765) + '\145')(chr(117) + chr(0b1100100 + 0o20) + chr(0b1100110) + chr(45) + chr(0b11101 + 0o33)) for an_u38qr8QsB in IHbm0hP4I074]
z9GW3zBW40wL = []
fpOoJRI8Az_5 = []
if BzxeQWvQ3GaN:
ghrilDEBtsWX = nchsoADJWuln.get_all_logical_forms(max_num_logical_forms=ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b101110 + 0o3) + '\067' + '\x35' + chr(0b110000), ord("\x08")))
else:
zJKNkaBlwTay = bAEvLqWX737r[ehT0Px3KOsy9(chr(0b10100 + 0o34) + chr(11220 - 11109) + chr(48), 0o10)].get_agenda_for_sentence(pamQPTGoym5v, add_paths_to_agenda=ehT0Px3KOsy9('\060' + '\x6f' + chr(1642 - 1594), 8))
ghrilDEBtsWX = nchsoADJWuln.get_logical_forms_with_agenda(zJKNkaBlwTay, JSu18uxNdEXR * ehT0Px3KOsy9('\x30' + chr(0b101111 + 0o100) + '\x31' + '\x32', 8))
for kh68tYwZhgrY in ghrilDEBtsWX:
if Dl48nj1rbi23([xafqLlk3kkUe(pxv6w2yhAgdj, xafqLlk3kkUe(SXOLrMavuUCe(b'\x07\xad\xa8\x97\xa7\xec\xcf'), chr(100) + chr(5339 - 5238) + chr(0b111011 + 0o50) + chr(0b100101 + 0o112) + chr(0b1100100) + chr(5854 - 5753))(chr(0b111100 + 0o71) + chr(8010 - 7894) + chr(102) + chr(0b11001 + 0o24) + '\x38'))(kh68tYwZhgrY) == TRUOLFLuD08x for (pxv6w2yhAgdj, TRUOLFLuD08x) in pZ0NK2y6HRbn(bAEvLqWX737r, uXMK81tmdpTM)]):
if c2A0yzQpDQB3(z9GW3zBW40wL) <= JSu18uxNdEXR:
xafqLlk3kkUe(z9GW3zBW40wL, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03\xa5\xbd\x91\xbc\xfc'), chr(0b1100100) + '\145' + chr(99) + chr(0b1001010 + 0o45) + chr(5584 - 5484) + chr(9699 - 9598))(chr(117) + '\164' + chr(0b1100110) + '\055' + '\070'))(kh68tYwZhgrY)
elif c2A0yzQpDQB3(fpOoJRI8Az_5) <= JSu18uxNdEXR:
xafqLlk3kkUe(fpOoJRI8Az_5, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03\xa5\xbd\x91\xbc\xfc'), chr(1880 - 1780) + '\x65' + chr(5799 - 5700) + chr(0b101010 + 0o105) + '\144' + '\x65')('\165' + chr(0b1001001 + 0o53) + '\146' + chr(0b101101) + chr(56)))(kh68tYwZhgrY)
if c2A0yzQpDQB3(z9GW3zBW40wL) >= JSu18uxNdEXR and c2A0yzQpDQB3(fpOoJRI8Az_5) >= JSu18uxNdEXR:
break
if eFoTdKLG4F6P:
nTHApkU88ijp = [bAEvLqWX737r[ehT0Px3KOsy9('\060' + chr(0b10100 + 0o133) + chr(48), 8)].parse_logical_form(kh68tYwZhgrY) for kh68tYwZhgrY in z9GW3zBW40wL]
JoUAzTEJOsOS = [bAEvLqWX737r[ehT0Px3KOsy9('\x30' + chr(6533 - 6422) + chr(0b1000 + 0o50), 8)].get_action_sequence(MYNOgOBOENEt) for MYNOgOBOENEt in nTHApkU88ijp]
XUqF5l2kYfZX = [bAEvLqWX737r[ehT0Px3KOsy9('\x30' + chr(0b1011011 + 0o24) + chr(0b101000 + 0o10), 8)].parse_logical_form(kh68tYwZhgrY) for kh68tYwZhgrY in fpOoJRI8Az_5]
h_Ix0_rWwakT = [bAEvLqWX737r[ehT0Px3KOsy9(chr(688 - 640) + chr(111) + chr(0b100100 + 0o14), 8)].get_action_sequence(MYNOgOBOENEt) for MYNOgOBOENEt in XUqF5l2kYfZX]
xafqLlk3kkUe(Aq7y0fJIkLo6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03\xa5\xbd\x91\xbc\xfc'), chr(0b1100100) + '\145' + chr(99) + '\157' + chr(5488 - 5388) + '\145')('\165' + chr(0b1110100) + chr(1966 - 1864) + chr(0b100000 + 0o15) + '\070'))({xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xb1'), chr(0b1000001 + 0o43) + chr(101) + chr(0b1100011) + chr(0b1101111) + chr(4324 - 4224) + '\x65')('\165' + chr(0b1101 + 0o147) + '\146' + chr(45) + chr(0b111000)): pj8u1hDpF7b4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11\xb0\xa3\x80\xb7\xf6\xc9<'), chr(0b1100100) + chr(0b1100101) + chr(3221 - 3122) + chr(0b1001001 + 0o46) + '\x64' + chr(101))(chr(0b100010 + 0o123) + '\x74' + chr(0b11001 + 0o115) + chr(45) + chr(2681 - 2625)): pamQPTGoym5v, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xba\xbf\x86\xb7\xfb\xde\x06\xaa5\x80\xf3\x11l\x8d\x17\x00'), '\x64' + chr(101) + '\x63' + chr(111) + '\x64' + chr(101))(chr(4942 - 4825) + chr(0b1100100 + 0o20) + '\146' + chr(1492 - 1447) + '\x38'): JoUAzTEJOsOS, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xbb\xae\x9b\xa0\xea\xcf:\xad\x0f\x82\xe3\x05w\x8b\x1c\x10`\x96'), chr(0b1001001 + 0o33) + chr(0b1100101) + '\143' + chr(111) + chr(0b101010 + 0o72) + chr(101))('\165' + chr(0b110110 + 0o76) + chr(0b1100110) + chr(0b101101) + chr(0b111000)): h_Ix0_rWwakT, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\xba\xbf\x98\xb6\xeb'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(0b1101111) + '\x64' + chr(101))('\165' + chr(0b1010101 + 0o37) + chr(102) + chr(0b1001 + 0o44) + chr(1633 - 1577)): aXwdfXbZcS8V, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0e\xb4\xaf\x91\xbe\xeb'), chr(7473 - 7373) + chr(0b100100 + 0o101) + chr(4289 - 4190) + '\x6f' + chr(0b1001000 + 0o34) + chr(0b1100101))(chr(0b100111 + 0o116) + chr(0b1110100) + '\x66' + chr(0b100000 + 0o15) + chr(617 - 561)): IHbm0hP4I074})
else:
xafqLlk3kkUe(Aq7y0fJIkLo6, xafqLlk3kkUe(SXOLrMavuUCe(b'\x03\xa5\xbd\x91\xbc\xfc'), '\x64' + chr(0b1100101) + chr(0b100110 + 0o75) + chr(0b1101111) + '\144' + chr(0b111001 + 0o54))(chr(9432 - 9315) + chr(12084 - 11968) + chr(0b111000 + 0o56) + '\x2d' + chr(0b111000)))({xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xb1'), chr(100) + chr(0b1000100 + 0o41) + chr(1699 - 1600) + chr(111) + chr(100) + '\x65')('\x75' + chr(0b1110100) + chr(0b1100110) + '\x2d' + chr(0b110100 + 0o4)): pj8u1hDpF7b4, xafqLlk3kkUe(SXOLrMavuUCe(b'\x11\xb0\xa3\x80\xb7\xf6\xc9<'), chr(100) + '\145' + chr(0b111110 + 0o45) + '\157' + chr(0b1100100) + chr(101))('\165' + chr(0b1101 + 0o147) + chr(102) + '\055' + chr(1612 - 1556)): pamQPTGoym5v, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xba\xbf\x86\xb7\xfb\xde\x06\xb5?\x96\xef\x17c\x82-\x15j\x97j`'), chr(524 - 424) + chr(4746 - 4645) + chr(0b10110 + 0o115) + chr(7516 - 7405) + '\x64' + chr(0b1001001 + 0o34))(chr(117) + '\x74' + '\146' + '\x2d' + chr(434 - 378)): z9GW3zBW40wL, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0b\xbb\xae\x9b\xa0\xea\xcf:\xad\x0f\x9d\xe9\x13k\x8d\x13\x1fZ\x83ha\x9f\xe0'), chr(1291 - 1191) + '\145' + chr(0b1100011) + chr(2159 - 2048) + '\x64' + '\145')(chr(0b1001111 + 0o46) + chr(116) + chr(102) + '\x2d' + '\x38'): fpOoJRI8Az_5, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\xba\xbf\x98\xb6\xeb'), chr(7518 - 7418) + chr(977 - 876) + chr(99) + chr(0b1101111) + chr(0b1011100 + 0o10) + chr(0b1000100 + 0o41))('\x75' + chr(116) + chr(4859 - 4757) + chr(0b101101) + '\070'): aXwdfXbZcS8V, xafqLlk3kkUe(SXOLrMavuUCe(b'\x0e\xb4\xaf\x91\xbe\xeb'), chr(0b1100100) + '\x65' + chr(99) + chr(0b1101111) + chr(0b100101 + 0o77) + '\x65')('\165' + chr(6003 - 5887) + chr(260 - 158) + '\x2d' + '\070'): IHbm0hP4I074})
with _fwkIVCGgtAN(mkvzj_PhLPP2, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15'), '\x64' + '\x65' + chr(0b1100011) + '\157' + chr(0b1100100) + '\145')('\x75' + chr(0b1110100) + chr(0b1100110) + chr(1726 - 1681) + chr(0b10111 + 0o41))) as VYUfp6Ou9W7x:
for vGVcNcScmWbU in Aq7y0fJIkLo6:
xafqLlk3kkUe(fXk443epxtd5, xafqLlk3kkUe(SXOLrMavuUCe(b'\x06\xa0\xa0\x84'), chr(5923 - 5823) + '\145' + chr(99) + chr(9860 - 9749) + chr(100) + '\145')(chr(0b1110101) + chr(116) + '\146' + chr(0b101101 + 0o0) + chr(56)))(vGVcNcScmWbU, VYUfp6Ou9W7x)
xafqLlk3kkUe(VYUfp6Ou9W7x, xafqLlk3kkUe(SXOLrMavuUCe(b'\x15\xa7\xa4\x80\xb7'), chr(0b1100100) + '\x65' + chr(0b1100011) + chr(0b1001 + 0o146) + chr(0b11111 + 0o105) + '\x65')('\165' + '\164' + chr(0b1011111 + 0o7) + chr(0b101101) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'h'), chr(0b1100100) + '\x65' + chr(99) + chr(7351 - 7240) + chr(0b1100100) + chr(7039 - 6938))('\165' + chr(0b1001011 + 0o51) + chr(5181 - 5079) + chr(0b101101) + chr(56)))
xafqLlk3kkUe(VYUfp6Ou9W7x, xafqLlk3kkUe(SXOLrMavuUCe(b'\x01\xb9\xa2\x87\xb7'), chr(724 - 624) + '\145' + chr(99) + '\157' + chr(0b11100 + 0o110) + chr(101))(chr(0b1010011 + 0o42) + '\x74' + chr(102) + '\055' + chr(999 - 943)))()
|
allenai/allennlp
|
allennlp/data/tokenizers/sentence_splitter.py
|
SentenceSplitter.batch_split_sentences
|
def batch_split_sentences(self, texts: List[str]) -> List[List[str]]:
"""
This method lets you take advantage of spacy's batch processing.
Default implementation is to just iterate over the texts and call ``split_sentences``.
"""
return [self.split_sentences(text) for text in texts]
|
python
|
def batch_split_sentences(self, texts: List[str]) -> List[List[str]]:
"""
This method lets you take advantage of spacy's batch processing.
Default implementation is to just iterate over the texts and call ``split_sentences``.
"""
return [self.split_sentences(text) for text in texts]
|
[
"def",
"batch_split_sentences",
"(",
"self",
",",
"texts",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
":",
"return",
"[",
"self",
".",
"split_sentences",
"(",
"text",
")",
"for",
"text",
"in",
"texts",
"]"
] |
This method lets you take advantage of spacy's batch processing.
Default implementation is to just iterate over the texts and call ``split_sentences``.
|
[
"This",
"method",
"lets",
"you",
"take",
"advantage",
"of",
"spacy",
"s",
"batch",
"processing",
".",
"Default",
"implementation",
"is",
"to",
"just",
"iterate",
"over",
"the",
"texts",
"and",
"call",
"split_sentences",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/tokenizers/sentence_splitter.py#L22-L27
|
train
|
This method will iterate over the texts and call split_sentences on each.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4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ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(292 - 244) + chr(111) + '\065' + '\x32', 43456 - 43448), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b100000 + 0o21) + chr(48) + chr(0b110101), ord("\x08")), ehT0Px3KOsy9(chr(1812 - 1764) + chr(111) + chr(0b110001) + '\060' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(1288 - 1240) + '\157' + chr(55) + chr(2326 - 2274), 36814 - 36806), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2162 - 2113) + chr(0b100010 + 0o16) + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\063' + '\x34' + chr(2014 - 1959), 22358 - 22350), ehT0Px3KOsy9(chr(461 - 413) + '\x6f' + chr(0b10011 + 0o40) + chr(55) + '\061', 10890 - 10882), ehT0Px3KOsy9(chr(48) + '\157' + chr(53) + chr(2555 - 2502), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110001) + '\x33' + chr(2300 - 2251), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(49) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(1696 - 1648) + chr(0b1101111) + chr(0b10111 + 0o34) + chr(49) + '\x31', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110010) + '\062' + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(600 - 550) + chr(48) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(0b110010) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(1709 - 1661) + chr(0b1101111) + '\x33' + '\x30', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + chr(0b11100 + 0o24) + chr(0b110110), 61127 - 61119), ehT0Px3KOsy9(chr(1203 - 1155) + chr(0b1101111) + chr(0b110011) + chr(53) + chr(2209 - 2155), 0o10), ehT0Px3KOsy9(chr(48) + chr(8485 - 8374) + '\061' + chr(701 - 649) + '\x32', 25420 - 25412), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(841 - 792) + chr(51) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1 + 0o60) + chr(0b110011) + chr(0b101101 + 0o7), 8), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + '\x37' + chr(1083 - 1033), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b110110 + 0o71) + chr(0b100110 + 0o21) + chr(1730 - 1682), 24178 - 24170), ehT0Px3KOsy9('\x30' + '\157' + chr(0b1011 + 0o50) + chr(0b110001) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(55) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110011) + chr(0b110110) + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(53) + chr(55), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b1100 + 0o47) + chr(55) + chr(0b101111 + 0o1), 31518 - 31510), ehT0Px3KOsy9('\060' + chr(0b11011 + 0o124) + chr(2050 - 1999) + chr(0b100011 + 0o17) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(51) + '\063' + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1110 + 0o45), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b111111 + 0o60) + chr(1092 - 1042) + chr(1491 - 1439) + chr(0b100000 + 0o25), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(0b100000 + 0o27) + '\065', 0o10), ehT0Px3KOsy9(chr(305 - 257) + chr(5189 - 5078) + chr(0b101000 + 0o12) + chr(51) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(4779 - 4668) + '\x32' + chr(0b110110) + chr(0b10111 + 0o33), 0o10), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(0b100001 + 0o116) + '\064' + '\x37', 0b1000), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(3138 - 3027) + '\062' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(1450 - 1402) + chr(0b1001101 + 0o42) + chr(50) + chr(666 - 615) + chr(0b110000), 59591 - 59583), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(0b110000 + 0o4) + chr(0b11 + 0o56), 0b1000), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(9686 - 9575) + chr(1668 - 1618) + chr(48) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(6789 - 6678) + chr(0b10100 + 0o36) + chr(102 - 53) + chr(0b1100 + 0o50), ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(9624 - 9513) + chr(53) + chr(0b100011 + 0o15), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x04'), '\144' + '\145' + chr(9029 - 8930) + chr(0b110110 + 0o71) + chr(0b1 + 0o143) + chr(0b1100101))('\x75' + '\x74' + '\x66' + '\055' + chr(1466 - 1410)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def BK5QBtWLuYmr(oVre8I6UXc3b, qEEOZdZZaFyI) -> qRxF7OQ0y39T[qRxF7OQ0y39T[M8_cKLkHVB2V]]:
return [xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'Y5*U4\xb8\x8aH7{\xac\xfb\xe7\xf5k'), chr(0b1010010 + 0o22) + chr(0b100101 + 0o100) + chr(7896 - 7797) + chr(0b1101111) + chr(3303 - 3203) + chr(101))(chr(117) + '\x74' + '\x66' + '\x2d' + '\x38'))(Ah1rInvg48Hb) for Ah1rInvg48Hb in qEEOZdZZaFyI]
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes.dataset_iterator
|
def dataset_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
"""
An iterator over the entire dataset, yielding all sentences processed.
"""
for conll_file in self.dataset_path_iterator(file_path):
yield from self.sentence_iterator(conll_file)
|
python
|
def dataset_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
"""
An iterator over the entire dataset, yielding all sentences processed.
"""
for conll_file in self.dataset_path_iterator(file_path):
yield from self.sentence_iterator(conll_file)
|
[
"def",
"dataset_iterator",
"(",
"self",
",",
"file_path",
":",
"str",
")",
"->",
"Iterator",
"[",
"OntonotesSentence",
"]",
":",
"for",
"conll_file",
"in",
"self",
".",
"dataset_path_iterator",
"(",
"file_path",
")",
":",
"yield",
"from",
"self",
".",
"sentence_iterator",
"(",
"conll_file",
")"
] |
An iterator over the entire dataset, yielding all sentences processed.
|
[
"An",
"iterator",
"over",
"the",
"entire",
"dataset",
"yielding",
"all",
"sentences",
"processed",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L176-L181
|
train
|
An iterator over the entire dataset yielding all sentences processed.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJ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yh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(111) + '\x31' + '\062' + chr(382 - 329), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100110 + 0o13) + chr(0b110111) + chr(2350 - 2301), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + '\x36' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(0b10 + 0o57) + chr(0b0 + 0o63), 0b1000), ehT0Px3KOsy9(chr(2149 - 2101) + chr(3832 - 3721) + chr(0b110010) + chr(0b101000 + 0o15) + chr(0b1 + 0o60), 0o10), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\x33' + '\066' + chr(0b100100 + 0o20), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\061' + '\x31', 41134 - 41126), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\062' + chr(51) + '\060', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110000 + 0o1) + chr(0b100101 + 0o13), 0b1000), ehT0Px3KOsy9('\060' + chr(0b100001 + 0o116) + '\x36' + chr(0b110111), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + '\x34' + '\x31', 0o10), ehT0Px3KOsy9(chr(120 - 72) + chr(0b1101111) + chr(55) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x34' + chr(223 - 171), 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b110 + 0o151) + chr(0b100111 + 0o12) + chr(2102 - 2048) + chr(49), 59979 - 59971), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(1513 - 1463) + chr(0b110011), 98 - 90), ehT0Px3KOsy9(chr(1105 - 1057) + '\157' + '\x32' + chr(0b110000) + chr(52), 0b1000), ehT0Px3KOsy9(chr(0b10001 + 0o37) + chr(7992 - 7881) + chr(0b110101) + chr(1052 - 1001), 14687 - 14679), ehT0Px3KOsy9(chr(2010 - 1962) + chr(111) + '\x32' + chr(2409 - 2359) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(6933 - 6822) + chr(54) + '\066', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b100111 + 0o13) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(1499 - 1451) + chr(111) + chr(0b11111 + 0o24) + chr(0b100110 + 0o15), 0b1000), ehT0Px3KOsy9(chr(48) + chr(600 - 489) + chr(1481 - 1431) + chr(1287 - 1239), 58798 - 58790), ehT0Px3KOsy9(chr(1533 - 1485) + '\157' + '\x33' + chr(0b110010) + chr(0b0 + 0o64), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(902 - 850) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(623 - 575) + '\x32', 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + chr(0b1100100 + 0o13) + '\x31' + '\061' + chr(1552 - 1500), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(4112 - 4001) + '\063' + '\064' + chr(53), 8), ehT0Px3KOsy9('\060' + '\157' + '\063' + chr(50) + chr(0b101110 + 0o5), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2395 - 2346) + chr(77 - 28) + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(0b110010 + 0o4) + '\066', 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11001 + 0o30) + '\066' + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x31' + chr(49), 8), ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + chr(0b11000 + 0o32) + chr(0b110101) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(715 - 667) + chr(111) + chr(0b100001 + 0o23) + chr(1416 - 1366), 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(11491 - 11380) + '\x32' + chr(0b101010 + 0o13) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(51) + chr(0b110010) + chr(54), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\062' + chr(0b11101 + 0o26) + '\x35', 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\062' + '\063', 8), ehT0Px3KOsy9(chr(48) + chr(3668 - 3557) + chr(0b101011 + 0o10) + '\x32' + chr(0b10111 + 0o32), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1010011 + 0o34) + chr(0b110011) + '\x34' + '\064', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(48) + '\157' + '\x35' + chr(0b11101 + 0o23), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'{'), '\x64' + chr(101) + chr(4242 - 4143) + chr(0b10100 + 0o133) + chr(0b1100100) + chr(0b1010010 + 0o23))(chr(0b1110101) + '\x74' + '\x66' + chr(0b101101) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Qpn3VFdmbHp4(oVre8I6UXc3b, Ti9e_bxaCVyu) -> NKxwUdYx2IOh[Dlfvtq0su6XO]:
for jaos51o1ltUL in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'1\x18\x87\xaa\xda\x91}\xc7xV\x95U{\x18g\xe1Y\xf0Byi'), '\x64' + chr(0b1100101 + 0o0) + chr(1418 - 1319) + chr(111) + '\144' + chr(7196 - 7095))(chr(577 - 460) + chr(0b1000001 + 0o63) + chr(0b1100110) + chr(45) + chr(0b111000)))(Ti9e_bxaCVyu):
yield from xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'&\x1c\x9d\xbf\xcc\x9aj\xfdW^\x95XV\x10g\xebY'), '\144' + chr(0b1 + 0o144) + chr(1207 - 1108) + '\x6f' + chr(4375 - 4275) + chr(9378 - 9277))(chr(117) + chr(7188 - 7072) + '\x66' + '\x2d' + chr(2332 - 2276)))(jaos51o1ltUL)
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes.dataset_path_iterator
|
def dataset_path_iterator(file_path: str) -> Iterator[str]:
"""
An iterator returning file_paths in a directory
containing CONLL-formatted files.
"""
logger.info("Reading CONLL sentences from dataset files at: %s", file_path)
for root, _, files in list(os.walk(file_path)):
for data_file in files:
# These are a relic of the dataset pre-processing. Every
# file will be duplicated - one file called filename.gold_skel
# and one generated from the preprocessing called filename.gold_conll.
if not data_file.endswith("gold_conll"):
continue
yield os.path.join(root, data_file)
|
python
|
def dataset_path_iterator(file_path: str) -> Iterator[str]:
"""
An iterator returning file_paths in a directory
containing CONLL-formatted files.
"""
logger.info("Reading CONLL sentences from dataset files at: %s", file_path)
for root, _, files in list(os.walk(file_path)):
for data_file in files:
# These are a relic of the dataset pre-processing. Every
# file will be duplicated - one file called filename.gold_skel
# and one generated from the preprocessing called filename.gold_conll.
if not data_file.endswith("gold_conll"):
continue
yield os.path.join(root, data_file)
|
[
"def",
"dataset_path_iterator",
"(",
"file_path",
":",
"str",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"logger",
".",
"info",
"(",
"\"Reading CONLL sentences from dataset files at: %s\"",
",",
"file_path",
")",
"for",
"root",
",",
"_",
",",
"files",
"in",
"list",
"(",
"os",
".",
"walk",
"(",
"file_path",
")",
")",
":",
"for",
"data_file",
"in",
"files",
":",
"# These are a relic of the dataset pre-processing. Every",
"# file will be duplicated - one file called filename.gold_skel",
"# and one generated from the preprocessing called filename.gold_conll.",
"if",
"not",
"data_file",
".",
"endswith",
"(",
"\"gold_conll\"",
")",
":",
"continue",
"yield",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"data_file",
")"
] |
An iterator returning file_paths in a directory
containing CONLL-formatted files.
|
[
"An",
"iterator",
"returning",
"file_paths",
"in",
"a",
"directory",
"containing",
"CONLL",
"-",
"formatted",
"files",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L184-L198
|
train
|
An iterator returning file_paths in a directory containing CONLL - formatted files.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl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ertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(0b101110 + 0o3) + chr(0b110111), 37924 - 37916), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(53) + chr(0b1011 + 0o54), 54016 - 54008), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1207 - 1158) + '\061' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(0b110100), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110000 + 0o2) + chr(0b11010 + 0o30) + chr(917 - 863), ord("\x08")), ehT0Px3KOsy9('\060' + chr(449 - 338) + chr(1354 - 1305) + chr(982 - 931) + chr(0b110000), 0b1000), ehT0Px3KOsy9(chr(1153 - 1105) + chr(111) + chr(179 - 130) + '\065' + chr(800 - 751), 27185 - 27177), ehT0Px3KOsy9(chr(0b101111 + 0o1) + '\x6f' + chr(2473 - 2423) + chr(0b110110) + chr(0b0 + 0o67), 6871 - 6863), ehT0Px3KOsy9('\x30' + chr(0b11001 + 0o126) + chr(0b110011) + chr(0b110111) + chr(1804 - 1756), 0b1000), ehT0Px3KOsy9(chr(0b10 + 0o56) + '\x6f' + '\x31' + '\062' + chr(0b110000), 0o10), ehT0Px3KOsy9('\060' + chr(111) + '\066' + '\x37', 48798 - 48790), ehT0Px3KOsy9('\060' + chr(0b10010 + 0o135) + '\x33' + chr(0b100101 + 0o21) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x33' + chr(51) + '\x32', 38055 - 38047), ehT0Px3KOsy9('\x30' + '\x6f' + chr(3000 - 2945) + chr(1777 - 1729), 0b1000), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(0b101000 + 0o107) + chr(67 - 12) + '\x30', 8), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(0b110100 + 0o2) + chr(51), 8), ehT0Px3KOsy9(chr(1295 - 1247) + chr(6477 - 6366) + chr(49) + chr(2340 - 2288) + chr(54), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + chr(0b110010) + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + '\x37' + chr(51), 51150 - 51142), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b1101111) + '\062' + chr(2475 - 2425) + chr(0b1111 + 0o50), 56956 - 56948), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + '\063' + chr(345 - 294) + chr(0b110100 + 0o0), 54537 - 54529), ehT0Px3KOsy9(chr(74 - 26) + chr(1556 - 1445) + chr(51) + chr(0b110100) + '\x34', ord("\x08")), ehT0Px3KOsy9(chr(2045 - 1997) + chr(0b1101111) + chr(0b110001) + '\x30' + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(9738 - 9627) + chr(49) + chr(0b110111), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + chr(48) + '\x37', 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b10100 + 0o35) + chr(0b110010) + chr(1869 - 1820), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110011) + chr(1836 - 1786) + '\x30', 47865 - 47857), ehT0Px3KOsy9('\060' + chr(0b1100 + 0o143) + chr(50) + chr(52) + chr(0b101111 + 0o3), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(0b110100) + chr(2667 - 2614), 53764 - 53756), ehT0Px3KOsy9(chr(0b101000 + 0o10) + chr(0b1101111) + chr(50) + chr(49) + '\061', 19332 - 19324), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b10111 + 0o32) + '\x31' + '\x35', 20696 - 20688), ehT0Px3KOsy9(chr(1623 - 1575) + '\157' + '\063' + '\067' + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(0b110001) + '\067', 8), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b100110 + 0o15) + chr(55) + '\066', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1000010 + 0o55) + chr(51) + chr(52) + '\064', 8), ehT0Px3KOsy9(chr(0b11001 + 0o27) + chr(111) + chr(51), 16480 - 16472), ehT0Px3KOsy9('\060' + chr(111) + chr(2335 - 2284) + chr(2432 - 2378) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1148 - 1097), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(0b110010) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + '\x31', ord("\x08"))][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\157' + '\065' + '\x30', 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), chr(2429 - 2329) + chr(2473 - 2372) + chr(99) + chr(0b1000011 + 0o54) + '\144' + chr(0b101 + 0o140))('\165' + '\x74' + chr(3627 - 3525) + chr(45) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def Qt9bg1A_zamt(Ti9e_bxaCVyu) -> NKxwUdYx2IOh[M8_cKLkHVB2V]:
xafqLlk3kkUe(hdK8qOUhR6Or, xafqLlk3kkUe(SXOLrMavuUCe(b'\xdc\xd8\x06t\xe3;\x0e\x80\x92<m\x98'), '\x64' + '\x65' + '\143' + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(0b1110101) + chr(0b1011111 + 0o25) + chr(0b1000101 + 0o41) + '\x2d' + chr(1258 - 1202)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xdd\x8a/h\xff6\x0e\x97\xbb\x1fy\xbf\x96\x18K\x96\x08%\x9e\xf9\xbf\x811/\xa1#\xbf\xcf\x85\xed,\x8d\xee\x8d\x81w\xd6e<u\xea\x9cnm\xe2bI\x92\x8b'), '\144' + '\145' + chr(0b10110 + 0o115) + chr(0b1001 + 0o146) + '\x64' + chr(0b1100101))(chr(0b111111 + 0o66) + chr(116) + chr(4006 - 3904) + chr(0b10000 + 0o35) + '\070'), Ti9e_bxaCVyu)
for (FiL2Xt3u2AMN, VNGQdHSFPrso, uyc48vokp5OE) in YyaZ4tpXu4lf(xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'\xf8\x8e"g'), '\x64' + '\145' + chr(7506 - 7407) + chr(0b1101111) + chr(0b1001000 + 0o34) + chr(101))('\165' + '\164' + '\146' + chr(522 - 477) + chr(56)))(Ti9e_bxaCVyu)):
for CRm8xD274Xgy in uyc48vokp5OE:
if not xafqLlk3kkUe(CRm8xD274Xgy, xafqLlk3kkUe(SXOLrMavuUCe(b'\xea\x81*\x7f\xe11\x1d\xdf'), '\x64' + chr(2897 - 2796) + chr(5806 - 5707) + chr(877 - 766) + chr(6348 - 6248) + '\x65')(chr(0b1110101) + chr(116) + chr(0b110100 + 0o62) + chr(45) + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xe8\x80"h\xc9;\x06\xd9\x94<'), '\144' + '\x65' + chr(99) + chr(111) + chr(8981 - 8881) + chr(101))('\165' + chr(0b1110100) + '\x66' + chr(0b101101) + chr(56))):
continue
yield xafqLlk3kkUe(oqhJDdMJfuwx.path, xafqLlk3kkUe(SXOLrMavuUCe(b'\xd0\x80\x19T\xec,?\xf9\x96!\x7f\xb5'), chr(0b1101 + 0o127) + chr(101) + chr(99) + chr(111) + '\x64' + chr(0b101111 + 0o66))(chr(0b1000 + 0o155) + chr(0b1010011 + 0o41) + '\146' + chr(1108 - 1063) + '\070'))(FiL2Xt3u2AMN, CRm8xD274Xgy)
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes.dataset_document_iterator
|
def dataset_document_iterator(self, file_path: str) -> Iterator[List[OntonotesSentence]]:
"""
An iterator over CONLL formatted files which yields documents, regardless
of the number of document annotations in a particular file. This is useful
for conll data which has been preprocessed, such as the preprocessing which
takes place for the 2012 CONLL Coreference Resolution task.
"""
with codecs.open(file_path, 'r', encoding='utf8') as open_file:
conll_rows = []
document: List[OntonotesSentence] = []
for line in open_file:
line = line.strip()
if line != '' and not line.startswith('#'):
# Non-empty line. Collect the annotation.
conll_rows.append(line)
else:
if conll_rows:
document.append(self._conll_rows_to_sentence(conll_rows))
conll_rows = []
if line.startswith("#end document"):
yield document
document = []
if document:
# Collect any stragglers or files which might not
# have the '#end document' format for the end of the file.
yield document
|
python
|
def dataset_document_iterator(self, file_path: str) -> Iterator[List[OntonotesSentence]]:
"""
An iterator over CONLL formatted files which yields documents, regardless
of the number of document annotations in a particular file. This is useful
for conll data which has been preprocessed, such as the preprocessing which
takes place for the 2012 CONLL Coreference Resolution task.
"""
with codecs.open(file_path, 'r', encoding='utf8') as open_file:
conll_rows = []
document: List[OntonotesSentence] = []
for line in open_file:
line = line.strip()
if line != '' and not line.startswith('#'):
# Non-empty line. Collect the annotation.
conll_rows.append(line)
else:
if conll_rows:
document.append(self._conll_rows_to_sentence(conll_rows))
conll_rows = []
if line.startswith("#end document"):
yield document
document = []
if document:
# Collect any stragglers or files which might not
# have the '#end document' format for the end of the file.
yield document
|
[
"def",
"dataset_document_iterator",
"(",
"self",
",",
"file_path",
":",
"str",
")",
"->",
"Iterator",
"[",
"List",
"[",
"OntonotesSentence",
"]",
"]",
":",
"with",
"codecs",
".",
"open",
"(",
"file_path",
",",
"'r'",
",",
"encoding",
"=",
"'utf8'",
")",
"as",
"open_file",
":",
"conll_rows",
"=",
"[",
"]",
"document",
":",
"List",
"[",
"OntonotesSentence",
"]",
"=",
"[",
"]",
"for",
"line",
"in",
"open_file",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
"!=",
"''",
"and",
"not",
"line",
".",
"startswith",
"(",
"'#'",
")",
":",
"# Non-empty line. Collect the annotation.",
"conll_rows",
".",
"append",
"(",
"line",
")",
"else",
":",
"if",
"conll_rows",
":",
"document",
".",
"append",
"(",
"self",
".",
"_conll_rows_to_sentence",
"(",
"conll_rows",
")",
")",
"conll_rows",
"=",
"[",
"]",
"if",
"line",
".",
"startswith",
"(",
"\"#end document\"",
")",
":",
"yield",
"document",
"document",
"=",
"[",
"]",
"if",
"document",
":",
"# Collect any stragglers or files which might not",
"# have the '#end document' format for the end of the file.",
"yield",
"document"
] |
An iterator over CONLL formatted files which yields documents, regardless
of the number of document annotations in a particular file. This is useful
for conll data which has been preprocessed, such as the preprocessing which
takes place for the 2012 CONLL Coreference Resolution task.
|
[
"An",
"iterator",
"over",
"CONLL",
"formatted",
"files",
"which",
"yields",
"documents",
"regardless",
"of",
"the",
"number",
"of",
"document",
"annotations",
"in",
"a",
"particular",
"file",
".",
"This",
"is",
"useful",
"for",
"conll",
"data",
"which",
"has",
"been",
"preprocessed",
"such",
"as",
"the",
"preprocessing",
"which",
"takes",
"place",
"for",
"the",
"2012",
"CONLL",
"Coreference",
"Resolution",
"task",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L200-L225
|
train
|
An iterator over the files which yields documents regardless of the number of document annotations in a particular file.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd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OIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1825 - 1777) + chr(111) + chr(0b11001 + 0o30) + '\x33' + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b101100 + 0o4) + chr(111) + chr(0b110010) + chr(0b110100) + chr(0b101100 + 0o4), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010000 + 0o37) + chr(1832 - 1783) + chr(50) + chr(0b100000 + 0o22), 0o10), ehT0Px3KOsy9(chr(0b101001 + 0o7) + chr(0b100010 + 0o115) + chr(2286 - 2234) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(1427 - 1379) + chr(12022 - 11911) + chr(251 - 201) + '\063' + '\x32', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2219 - 2170) + chr(0b110100) + '\x32', 0b1000), ehT0Px3KOsy9(chr(820 - 772) + chr(111) + chr(0b101000 + 0o11) + '\066' + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\062' + '\060' + '\x30', 58981 - 58973), ehT0Px3KOsy9(chr(48) + chr(2041 - 1930) + chr(0b101101 + 0o4) + chr(2365 - 2312) + '\064', 24449 - 24441), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + chr(62 - 11) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + chr(0b110010) + chr(54) + '\064', 64021 - 64013), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110 + 0o53) + '\065' + chr(0b100010 + 0o21), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b10101 + 0o36) + chr(0b110001 + 0o4) + chr(1763 - 1713), ord("\x08")), ehT0Px3KOsy9(chr(239 - 191) + chr(0b1101111) + chr(53) + '\067', 0b1000), ehT0Px3KOsy9(chr(470 - 422) + chr(111) + chr(50) + '\065' + chr(0b110010 + 0o3), 37968 - 37960), ehT0Px3KOsy9(chr(48) + chr(10055 - 9944) + chr(50) + chr(1856 - 1807) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110010) + chr(0b100100 + 0o16), 0b1000), ehT0Px3KOsy9(chr(522 - 474) + '\x6f' + chr(0b11111 + 0o22) + chr(0b11110 + 0o22) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(52) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(418 - 370) + '\x6f' + '\x35' + chr(2194 - 2143), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1111 + 0o140) + chr(2499 - 2449) + chr(0b1 + 0o57) + chr(931 - 876), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(50) + chr(0b11110 + 0o23) + chr(55), 55871 - 55863), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1298 - 1249) + '\060' + chr(1630 - 1580), 0o10), ehT0Px3KOsy9(chr(720 - 672) + '\x6f' + chr(0b110011) + '\067', 34680 - 34672), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b11001 + 0o30) + '\x32' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\x31' + chr(0b110100) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(1117 - 1069) + chr(111) + chr(50) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1011100 + 0o23) + '\x33' + chr(0b1101 + 0o47) + '\x37', 0b1000), ehT0Px3KOsy9(chr(1128 - 1080) + chr(7261 - 7150) + '\x31' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(0b110110) + chr(0b0 + 0o67), 0o10), ehT0Px3KOsy9(chr(114 - 66) + chr(0b1001110 + 0o41) + chr(0b110001) + chr(0b101 + 0o57) + chr(50), 8), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + '\x36' + '\063', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1304 - 1254) + chr(2040 - 1989) + chr(0b101111 + 0o7), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b101001 + 0o106) + '\x33' + chr(1673 - 1622) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(0b100011 + 0o15) + chr(0b1000001 + 0o56) + '\x33' + chr(0b110100) + chr(50), 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(111) + '\063' + chr(55) + chr(502 - 449), 14472 - 14464), ehT0Px3KOsy9('\x30' + chr(0b111 + 0o150) + chr(1165 - 1115) + chr(2507 - 2454) + chr(385 - 330), ord("\x08")), ehT0Px3KOsy9(chr(489 - 441) + chr(0b1101111) + chr(0b10 + 0o60) + chr(55), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1822 - 1767) + chr(55), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + '\x34' + chr(53), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(6479 - 6368) + chr(0b110101) + chr(48), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'q'), chr(100) + chr(0b1010 + 0o133) + '\143' + chr(9566 - 9455) + chr(0b1100100) + chr(8513 - 8412))('\165' + chr(116) + chr(0b111010 + 0o54) + chr(0b101101) + chr(2417 - 2361)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def KY6X88gvdvCQ(oVre8I6UXc3b, Ti9e_bxaCVyu) -> NKxwUdYx2IOh[qRxF7OQ0y39T[Dlfvtq0su6XO]]:
with xafqLlk3kkUe(aABRNn2PDIOX, xafqLlk3kkUe(SXOLrMavuUCe(b'0\xd07K'), chr(0b1100100) + chr(365 - 264) + '\143' + '\157' + chr(0b1010110 + 0o16) + chr(0b1100101))(chr(9130 - 9013) + '\x74' + chr(0b1000010 + 0o44) + '\055' + chr(56)))(Ti9e_bxaCVyu, xafqLlk3kkUe(SXOLrMavuUCe(b'-'), chr(100) + chr(101) + chr(99) + '\157' + '\x64' + chr(8984 - 8883))('\165' + chr(9051 - 8935) + '\146' + chr(1904 - 1859) + chr(0b110101 + 0o3)), encoding=xafqLlk3kkUe(SXOLrMavuUCe(b'*\xd44\x1d'), chr(0b100100 + 0o100) + chr(0b1000010 + 0o43) + chr(7069 - 6970) + chr(0b1101111) + '\144' + chr(101))(chr(5830 - 5713) + chr(116) + chr(102) + '\055' + '\070')) as KRuylbtr89b_:
TkNr6vvmZhq0 = []
KivJ174MVuLn = []
for LycYkDpyelF6 in KRuylbtr89b_:
LycYkDpyelF6 = LycYkDpyelF6.strip()
if LycYkDpyelF6 != xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + chr(101) + '\x63' + chr(111) + chr(0b1010 + 0o132) + '\145')(chr(117) + '\x74' + chr(596 - 494) + chr(45) + chr(56)) and (not xafqLlk3kkUe(LycYkDpyelF6, xafqLlk3kkUe(SXOLrMavuUCe(b',\xd43W\xee\x11\x05\xe9\x181'), chr(0b1100100) + '\145' + chr(439 - 340) + chr(0b1010 + 0o145) + '\x64' + chr(0b1100101))(chr(1725 - 1608) + '\164' + chr(102) + '\055' + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'|'), '\x64' + chr(1082 - 981) + '\143' + '\x6f' + chr(0b1100100) + chr(0b1100101))(chr(567 - 450) + chr(116) + chr(7518 - 7416) + chr(0b110 + 0o47) + '\070'))):
xafqLlk3kkUe(TkNr6vvmZhq0, xafqLlk3kkUe(SXOLrMavuUCe(b'>\xd0"@\xf4\x06'), '\x64' + '\x65' + chr(1808 - 1709) + chr(0b1000100 + 0o53) + chr(0b111000 + 0o54) + chr(0b1010001 + 0o24))(chr(0b1011 + 0o152) + chr(116) + chr(0b110111 + 0o57) + chr(0b101101) + chr(56)))(LycYkDpyelF6)
elif TkNr6vvmZhq0:
xafqLlk3kkUe(KivJ174MVuLn, xafqLlk3kkUe(SXOLrMavuUCe(b'>\xd0"@\xf4\x06'), chr(100) + chr(101) + chr(0b11011 + 0o110) + chr(0b1101111) + '\144' + chr(4451 - 4350))('\165' + chr(116) + chr(0b1100110) + chr(0b101101) + chr(0b10101 + 0o43)))(xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b"\x00\xc3=K\xf6\x0e-\xf2\x03.\xc74\x9e@\xf2\xf9w/WN\xe9\xec'"), chr(4053 - 3953) + chr(0b1100101) + '\143' + chr(111) + '\x64' + '\x65')(chr(117) + chr(1610 - 1494) + chr(102) + '\055' + chr(0b111000)))(TkNr6vvmZhq0))
TkNr6vvmZhq0 = []
if xafqLlk3kkUe(LycYkDpyelF6, xafqLlk3kkUe(SXOLrMavuUCe(b',\xd43W\xee\x11\x05\xe9\x181'), '\x64' + '\x65' + chr(0b111000 + 0o53) + chr(2027 - 1916) + '\x64' + chr(0b110010 + 0o63))(chr(117) + chr(0b1101101 + 0o7) + chr(102) + '\055' + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'|\xc5<A\xba\x06\x1d\xe3\x194\xd1\x05\x9e'), chr(100) + chr(101) + '\143' + '\x6f' + '\144' + '\x65')(chr(0b1110101) + '\164' + chr(2491 - 2389) + chr(0b11110 + 0o17) + '\x38')):
yield KivJ174MVuLn
KivJ174MVuLn = []
if KivJ174MVuLn:
yield KivJ174MVuLn
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes.sentence_iterator
|
def sentence_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
"""
An iterator over the sentences in an individual CONLL formatted file.
"""
for document in self.dataset_document_iterator(file_path):
for sentence in document:
yield sentence
|
python
|
def sentence_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
"""
An iterator over the sentences in an individual CONLL formatted file.
"""
for document in self.dataset_document_iterator(file_path):
for sentence in document:
yield sentence
|
[
"def",
"sentence_iterator",
"(",
"self",
",",
"file_path",
":",
"str",
")",
"->",
"Iterator",
"[",
"OntonotesSentence",
"]",
":",
"for",
"document",
"in",
"self",
".",
"dataset_document_iterator",
"(",
"file_path",
")",
":",
"for",
"sentence",
"in",
"document",
":",
"yield",
"sentence"
] |
An iterator over the sentences in an individual CONLL formatted file.
|
[
"An",
"iterator",
"over",
"the",
"sentences",
"in",
"an",
"individual",
"CONLL",
"formatted",
"file",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L227-L233
|
train
|
An iterator over the sentences in an individual CONLL formatted file.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCV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reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\065' + chr(0b10101 + 0o35), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + '\x35' + '\060', 0b1000), ehT0Px3KOsy9(chr(389 - 341) + chr(111) + '\x31' + chr(0b110110) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b110101 + 0o72) + chr(107 - 56) + chr(49) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(2913 - 2802) + chr(0b101 + 0o55) + chr(0b110001) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001 + 0o0) + chr(0b101 + 0o54) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(2334 - 2285) + chr(0b101010 + 0o10) + '\063', 39041 - 39033), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(289 - 240) + chr(55) + '\x30', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + chr(0b110001) + chr(51), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b100010 + 0o115) + '\061' + chr(48) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(1935 - 1824) + '\x34' + chr(0b110110), 62997 - 62989), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(290 - 240) + chr(0b10 + 0o63) + '\065', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x33' + chr(0b100001 + 0o26) + chr(0b110110), 0b1000), ehT0Px3KOsy9('\x30' + chr(3146 - 3035) + '\x31' + '\062' + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(0b110010) + chr(0b110000) + chr(50), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110101) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b11101 + 0o32) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(1546 - 1498) + '\x6f' + chr(0b110010) + chr(610 - 560) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(274 - 226) + '\x6f' + chr(2887 - 2833) + '\064', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(574 - 525) + '\x37' + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(1680 - 1569) + chr(0b100011 + 0o17) + '\x37' + chr(50), 25534 - 25526), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110001) + chr(0b110001) + chr(55), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + '\x31' + '\x33', 8), ehT0Px3KOsy9(chr(0b11000 + 0o30) + chr(11663 - 11552) + '\062' + chr(1127 - 1076) + chr(2343 - 2294), 0b1000), ehT0Px3KOsy9('\060' + chr(0b110101 + 0o72) + chr(0b1010 + 0o51) + chr(2255 - 2200), ord("\x08")), ehT0Px3KOsy9(chr(1604 - 1556) + '\157' + chr(0b110011) + chr(54) + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(10078 - 9967) + '\065' + '\063', ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(2225 - 2176) + chr(55) + chr(1793 - 1738), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(49) + '\061' + chr(0b11001 + 0o36), 8), ehT0Px3KOsy9(chr(2141 - 2093) + chr(111) + '\062' + chr(1802 - 1752) + chr(1325 - 1277), ord("\x08")), ehT0Px3KOsy9(chr(867 - 819) + chr(9832 - 9721) + chr(0b1 + 0o61) + '\062' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b10110 + 0o32) + chr(2752 - 2641) + '\x32' + '\065' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b111101 + 0o62) + chr(50) + chr(0b110100) + '\x34', 43229 - 43221), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(78 - 28) + chr(0b10010 + 0o45) + chr(1688 - 1640), 0b1000), ehT0Px3KOsy9('\x30' + chr(111) + chr(1728 - 1676) + chr(0b10111 + 0o31), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(51) + chr(0b1 + 0o57) + chr(50), 45064 - 45056), ehT0Px3KOsy9(chr(0b110 + 0o52) + chr(111) + chr(49) + chr(0b110010) + chr(0b10101 + 0o36), 8), ehT0Px3KOsy9(chr(0b100100 + 0o14) + '\157' + '\063' + '\x35' + '\x37', 12829 - 12821), ehT0Px3KOsy9(chr(0b110000) + chr(0b111101 + 0o62) + chr(0b1 + 0o61) + chr(0b110001), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11 + 0o56) + '\x32' + chr(0b101111 + 0o5), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9('\060' + chr(872 - 761) + chr(0b110101) + chr(0b110000), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x04'), chr(0b1100100) + chr(918 - 817) + '\x63' + chr(10570 - 10459) + chr(0b1100100) + '\145')('\165' + chr(11563 - 11447) + chr(0b1100110) + '\x2d' + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def h_mCAUZpaSN0(oVre8I6UXc3b, Ti9e_bxaCVyu) -> NKxwUdYx2IOh[Dlfvtq0su6XO]:
for KivJ174MVuLn in xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b"N\xc9\x00\xad\xfb-''/.E\xd8\x935\xecZg\xfb@\x1b\xc8.?\xf6m"), chr(100) + '\x65' + chr(0b1010011 + 0o20) + chr(0b1101111) + '\144' + chr(0b111000 + 0o55))(chr(117) + chr(0b1010 + 0o152) + chr(0b110000 + 0o66) + '\055' + '\x38'))(Ti9e_bxaCVyu):
for pamQPTGoym5v in KivJ174MVuLn:
yield pamQPTGoym5v
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes._process_coref_span_annotations_for_word
|
def _process_coref_span_annotations_for_word(label: str,
word_index: int,
clusters: DefaultDict[int, List[Tuple[int, int]]],
coref_stacks: DefaultDict[int, List[int]]) -> None:
"""
For a given coref label, add it to a currently open span(s), complete a span(s) or
ignore it, if it is outside of all spans. This method mutates the clusters and coref_stacks
dictionaries.
Parameters
----------
label : ``str``
The coref label for this word.
word_index : ``int``
The word index into the sentence.
clusters : ``DefaultDict[int, List[Tuple[int, int]]]``
A dictionary mapping cluster ids to lists of inclusive spans into the
sentence.
coref_stacks: ``DefaultDict[int, List[int]]``
Stacks for each cluster id to hold the start indices of active spans (spans
which we are inside of when processing a given word). Spans with the same id
can be nested, which is why we collect these opening spans on a stack, e.g:
[Greg, the baker who referred to [himself]_ID1 as 'the bread man']_ID1
"""
if label != "-":
for segment in label.split("|"):
# The conll representation of coref spans allows spans to
# overlap. If spans end or begin at the same word, they are
# separated by a "|".
if segment[0] == "(":
# The span begins at this word.
if segment[-1] == ")":
# The span begins and ends at this word (single word span).
cluster_id = int(segment[1:-1])
clusters[cluster_id].append((word_index, word_index))
else:
# The span is starting, so we record the index of the word.
cluster_id = int(segment[1:])
coref_stacks[cluster_id].append(word_index)
else:
# The span for this id is ending, but didn't start at this word.
# Retrieve the start index from the document state and
# add the span to the clusters for this id.
cluster_id = int(segment[:-1])
start = coref_stacks[cluster_id].pop()
clusters[cluster_id].append((start, word_index))
|
python
|
def _process_coref_span_annotations_for_word(label: str,
word_index: int,
clusters: DefaultDict[int, List[Tuple[int, int]]],
coref_stacks: DefaultDict[int, List[int]]) -> None:
"""
For a given coref label, add it to a currently open span(s), complete a span(s) or
ignore it, if it is outside of all spans. This method mutates the clusters and coref_stacks
dictionaries.
Parameters
----------
label : ``str``
The coref label for this word.
word_index : ``int``
The word index into the sentence.
clusters : ``DefaultDict[int, List[Tuple[int, int]]]``
A dictionary mapping cluster ids to lists of inclusive spans into the
sentence.
coref_stacks: ``DefaultDict[int, List[int]]``
Stacks for each cluster id to hold the start indices of active spans (spans
which we are inside of when processing a given word). Spans with the same id
can be nested, which is why we collect these opening spans on a stack, e.g:
[Greg, the baker who referred to [himself]_ID1 as 'the bread man']_ID1
"""
if label != "-":
for segment in label.split("|"):
# The conll representation of coref spans allows spans to
# overlap. If spans end or begin at the same word, they are
# separated by a "|".
if segment[0] == "(":
# The span begins at this word.
if segment[-1] == ")":
# The span begins and ends at this word (single word span).
cluster_id = int(segment[1:-1])
clusters[cluster_id].append((word_index, word_index))
else:
# The span is starting, so we record the index of the word.
cluster_id = int(segment[1:])
coref_stacks[cluster_id].append(word_index)
else:
# The span for this id is ending, but didn't start at this word.
# Retrieve the start index from the document state and
# add the span to the clusters for this id.
cluster_id = int(segment[:-1])
start = coref_stacks[cluster_id].pop()
clusters[cluster_id].append((start, word_index))
|
[
"def",
"_process_coref_span_annotations_for_word",
"(",
"label",
":",
"str",
",",
"word_index",
":",
"int",
",",
"clusters",
":",
"DefaultDict",
"[",
"int",
",",
"List",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
"]",
",",
"coref_stacks",
":",
"DefaultDict",
"[",
"int",
",",
"List",
"[",
"int",
"]",
"]",
")",
"->",
"None",
":",
"if",
"label",
"!=",
"\"-\"",
":",
"for",
"segment",
"in",
"label",
".",
"split",
"(",
"\"|\"",
")",
":",
"# The conll representation of coref spans allows spans to",
"# overlap. If spans end or begin at the same word, they are",
"# separated by a \"|\".",
"if",
"segment",
"[",
"0",
"]",
"==",
"\"(\"",
":",
"# The span begins at this word.",
"if",
"segment",
"[",
"-",
"1",
"]",
"==",
"\")\"",
":",
"# The span begins and ends at this word (single word span).",
"cluster_id",
"=",
"int",
"(",
"segment",
"[",
"1",
":",
"-",
"1",
"]",
")",
"clusters",
"[",
"cluster_id",
"]",
".",
"append",
"(",
"(",
"word_index",
",",
"word_index",
")",
")",
"else",
":",
"# The span is starting, so we record the index of the word.",
"cluster_id",
"=",
"int",
"(",
"segment",
"[",
"1",
":",
"]",
")",
"coref_stacks",
"[",
"cluster_id",
"]",
".",
"append",
"(",
"word_index",
")",
"else",
":",
"# The span for this id is ending, but didn't start at this word.",
"# Retrieve the start index from the document state and",
"# add the span to the clusters for this id.",
"cluster_id",
"=",
"int",
"(",
"segment",
"[",
":",
"-",
"1",
"]",
")",
"start",
"=",
"coref_stacks",
"[",
"cluster_id",
"]",
".",
"pop",
"(",
")",
"clusters",
"[",
"cluster_id",
"]",
".",
"append",
"(",
"(",
"start",
",",
"word_index",
")",
")"
] |
For a given coref label, add it to a currently open span(s), complete a span(s) or
ignore it, if it is outside of all spans. This method mutates the clusters and coref_stacks
dictionaries.
Parameters
----------
label : ``str``
The coref label for this word.
word_index : ``int``
The word index into the sentence.
clusters : ``DefaultDict[int, List[Tuple[int, int]]]``
A dictionary mapping cluster ids to lists of inclusive spans into the
sentence.
coref_stacks: ``DefaultDict[int, List[int]]``
Stacks for each cluster id to hold the start indices of active spans (spans
which we are inside of when processing a given word). Spans with the same id
can be nested, which is why we collect these opening spans on a stack, e.g:
[Greg, the baker who referred to [himself]_ID1 as 'the bread man']_ID1
|
[
"For",
"a",
"given",
"coref",
"label",
"add",
"it",
"to",
"a",
"currently",
"open",
"span",
"(",
"s",
")",
"complete",
"a",
"span",
"(",
"s",
")",
"or",
"ignore",
"it",
"if",
"it",
"is",
"outside",
"of",
"all",
"spans",
".",
"This",
"method",
"mutates",
"the",
"clusters",
"and",
"coref_stacks",
"dictionaries",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L362-L408
|
train
|
This method processes the coref span annotations for a given word.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9r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ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b10 + 0o61) + '\063' + chr(0b10100 + 0o34), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(0b10011 + 0o43) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(2138 - 2090) + chr(0b1101111) + chr(0b11111 + 0o24) + chr(49) + chr(1820 - 1767), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b111000 + 0o67) + '\x35' + chr(126 - 75), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\066' + chr(2452 - 2401), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b101011 + 0o11) + '\067', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11100 + 0o25) + chr(0b11100 + 0o32), ord("\x08")), ehT0Px3KOsy9(chr(1089 - 1041) + chr(111) + chr(52) + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(7263 - 7152) + chr(0b10000 + 0o45) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\157' + '\x33' + chr(2317 - 2263) + '\x33', 0b1000), ehT0Px3KOsy9('\060' + chr(0b11000 + 0o127) + chr(0b110001) + chr(0b1100 + 0o53) + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\062' + chr(48) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\x31' + chr(49) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(1031 - 983) + chr(0b1101111) + chr(406 - 355) + chr(0b110100), 60359 - 60351), ehT0Px3KOsy9(chr(268 - 220) + chr(0b1101111) + chr(0b110011) + chr(0b110110) + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110001) + chr(1321 - 1271) + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\061' + chr(50) + chr(1822 - 1772), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\062' + chr(2752 - 2697) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + chr(1573 - 1518) + chr(0b110010), 8), ehT0Px3KOsy9(chr(1071 - 1023) + chr(4027 - 3916) + chr(0b100001 + 0o20) + chr(54) + chr(0b110110), 48215 - 48207), ehT0Px3KOsy9('\x30' + chr(0b101100 + 0o103) + chr(1062 - 1012) + chr(51) + '\x31', 0o10), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\x6f' + chr(1119 - 1070) + chr(1173 - 1122) + chr(908 - 859), 31166 - 31158), ehT0Px3KOsy9(chr(48) + chr(0b11110 + 0o121) + '\061' + chr(0b110010) + chr(0b11010 + 0o33), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101101 + 0o2) + chr(407 - 356) + '\x32' + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(55) + '\x34', 54499 - 54491), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x33' + chr(0b110011) + chr(0b110110), 20238 - 20230), ehT0Px3KOsy9('\060' + chr(111) + chr(1444 - 1395) + chr(51) + '\065', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(54) + '\064', 0b1000), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(6260 - 6149) + chr(441 - 392) + chr(0b110110 + 0o0) + '\061', ord("\x08")), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b1100101 + 0o12) + chr(53) + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + chr(1367 - 1316) + chr(0b101101 + 0o10) + '\x35', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b10010 + 0o135) + chr(0b110111) + '\x32', 15213 - 15205), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\063' + chr(0b101010 + 0o15) + '\x34', 28188 - 28180), ehT0Px3KOsy9(chr(0b110000) + chr(8099 - 7988) + '\x31' + chr(0b110101) + chr(0b11010 + 0o31), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(156 - 106) + chr(0b0 + 0o64) + chr(1639 - 1587), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(55), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + '\x6f' + chr(51) + '\x31' + chr(50), 31198 - 31190), ehT0Px3KOsy9(chr(2244 - 2196) + '\x6f' + chr(0b100 + 0o57) + chr(50) + chr(0b10011 + 0o35), 21123 - 21115), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + '\067' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(985 - 936) + chr(55) + chr(0b100101 + 0o14), 49665 - 49657)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x35' + '\060', 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf6'), '\144' + chr(0b1100101) + '\143' + chr(111) + chr(0b1100100) + chr(101))(chr(117) + chr(0b110110 + 0o76) + '\146' + chr(0b1000 + 0o45) + chr(694 - 638)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def gZTYE2Sj6g5q(TRUOLFLuD08x, sJgh6cqyH9Br, sAHNhSKkzJx7, BhlFLpyxOFWO) -> None:
if TRUOLFLuD08x != xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5'), chr(1174 - 1074) + chr(0b110111 + 0o56) + '\143' + '\157' + '\144' + chr(0b110000 + 0o65))(chr(117) + '\x74' + chr(0b1010101 + 0o21) + chr(1883 - 1838) + chr(0b1001 + 0o57)):
for _Wv4RRy2aVmP in xafqLlk3kkUe(TRUOLFLuD08x, xafqLlk3kkUe(SXOLrMavuUCe(b'\xab\xc0\xa1B\xc7'), chr(0b1100011 + 0o1) + chr(0b1100101) + '\x63' + chr(0b1100011 + 0o14) + chr(0b1100100) + chr(4704 - 4603))(chr(0b1110011 + 0o2) + chr(116) + '\x66' + chr(1008 - 963) + chr(56)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa4'), chr(100) + chr(101) + chr(0b101010 + 0o71) + '\157' + '\144' + '\145')(chr(117) + chr(0b1110100) + chr(0b1100110) + chr(45) + chr(2415 - 2359))):
if _Wv4RRy2aVmP[ehT0Px3KOsy9('\x30' + '\157' + '\x30', ord("\x08"))] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xf0'), chr(0b1100100) + '\x65' + chr(99) + chr(111) + chr(0b1100100 + 0o0) + chr(0b1010000 + 0o25))('\165' + '\164' + chr(0b111101 + 0o51) + chr(45) + chr(0b1100 + 0o54)):
if _Wv4RRy2aVmP[-ehT0Px3KOsy9(chr(48) + chr(111) + chr(49), 43432 - 43424)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xf1'), chr(100) + '\145' + '\143' + '\157' + chr(0b1100100) + chr(101))(chr(8059 - 7942) + chr(2243 - 2127) + chr(0b1100110) + '\x2d' + chr(56)):
TJIQQKs7AVsa = ehT0Px3KOsy9(_Wv4RRy2aVmP[ehT0Px3KOsy9('\x30' + chr(0b100111 + 0o110) + '\x31', 8):-ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10100 + 0o35), 8)])
xafqLlk3kkUe(sAHNhSKkzJx7[TJIQQKs7AVsa], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\xc0\xbdN\xddC'), '\x64' + chr(0b1100101) + chr(0b1100011) + chr(0b1001010 + 0o45) + '\144' + '\x65')('\165' + '\164' + '\x66' + chr(0b101101) + chr(56)))((sJgh6cqyH9Br, sJgh6cqyH9Br))
else:
TJIQQKs7AVsa = ehT0Px3KOsy9(_Wv4RRy2aVmP[ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(0b100110 + 0o111) + chr(0b110001), 8):])
xafqLlk3kkUe(BhlFLpyxOFWO[TJIQQKs7AVsa], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\xc0\xbdN\xddC'), chr(5744 - 5644) + chr(101) + '\143' + chr(111) + '\x64' + chr(0b1000101 + 0o40))('\165' + '\164' + '\146' + '\055' + chr(201 - 145)))(sJgh6cqyH9Br)
else:
TJIQQKs7AVsa = ehT0Px3KOsy9(_Wv4RRy2aVmP[:-ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b10101 + 0o34), 8)])
avRbFsnfJxQj = BhlFLpyxOFWO[TJIQQKs7AVsa].pop()
xafqLlk3kkUe(sAHNhSKkzJx7[TJIQQKs7AVsa], xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9\xc0\xbdN\xddC'), '\144' + '\145' + chr(0b1100011) + chr(0b1101111) + chr(4809 - 4709) + '\x65')(chr(826 - 709) + '\x74' + chr(0b11001 + 0o115) + chr(0b11011 + 0o22) + chr(0b101011 + 0o15)))((avRbFsnfJxQj, sJgh6cqyH9Br))
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/ontonotes.py
|
Ontonotes._process_span_annotations_for_word
|
def _process_span_annotations_for_word(annotations: List[str],
span_labels: List[List[str]],
current_span_labels: List[Optional[str]]) -> None:
"""
Given a sequence of different label types for a single word and the current
span label we are inside, compute the BIO tag for each label and append to a list.
Parameters
----------
annotations: ``List[str]``
A list of labels to compute BIO tags for.
span_labels : ``List[List[str]]``
A list of lists, one for each annotation, to incrementally collect
the BIO tags for a sequence.
current_span_labels : ``List[Optional[str]]``
The currently open span per annotation type, or ``None`` if there is no open span.
"""
for annotation_index, annotation in enumerate(annotations):
# strip all bracketing information to
# get the actual propbank label.
label = annotation.strip("()*")
if "(" in annotation:
# Entering into a span for a particular semantic role label.
# We append the label and set the current span for this annotation.
bio_label = "B-" + label
span_labels[annotation_index].append(bio_label)
current_span_labels[annotation_index] = label
elif current_span_labels[annotation_index] is not None:
# If there's no '(' token, but the current_span_label is not None,
# then we are inside a span.
bio_label = "I-" + current_span_labels[annotation_index]
span_labels[annotation_index].append(bio_label)
else:
# We're outside a span.
span_labels[annotation_index].append("O")
# Exiting a span, so we reset the current span label for this annotation.
if ")" in annotation:
current_span_labels[annotation_index] = None
|
python
|
def _process_span_annotations_for_word(annotations: List[str],
span_labels: List[List[str]],
current_span_labels: List[Optional[str]]) -> None:
"""
Given a sequence of different label types for a single word and the current
span label we are inside, compute the BIO tag for each label and append to a list.
Parameters
----------
annotations: ``List[str]``
A list of labels to compute BIO tags for.
span_labels : ``List[List[str]]``
A list of lists, one for each annotation, to incrementally collect
the BIO tags for a sequence.
current_span_labels : ``List[Optional[str]]``
The currently open span per annotation type, or ``None`` if there is no open span.
"""
for annotation_index, annotation in enumerate(annotations):
# strip all bracketing information to
# get the actual propbank label.
label = annotation.strip("()*")
if "(" in annotation:
# Entering into a span for a particular semantic role label.
# We append the label and set the current span for this annotation.
bio_label = "B-" + label
span_labels[annotation_index].append(bio_label)
current_span_labels[annotation_index] = label
elif current_span_labels[annotation_index] is not None:
# If there's no '(' token, but the current_span_label is not None,
# then we are inside a span.
bio_label = "I-" + current_span_labels[annotation_index]
span_labels[annotation_index].append(bio_label)
else:
# We're outside a span.
span_labels[annotation_index].append("O")
# Exiting a span, so we reset the current span label for this annotation.
if ")" in annotation:
current_span_labels[annotation_index] = None
|
[
"def",
"_process_span_annotations_for_word",
"(",
"annotations",
":",
"List",
"[",
"str",
"]",
",",
"span_labels",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"current_span_labels",
":",
"List",
"[",
"Optional",
"[",
"str",
"]",
"]",
")",
"->",
"None",
":",
"for",
"annotation_index",
",",
"annotation",
"in",
"enumerate",
"(",
"annotations",
")",
":",
"# strip all bracketing information to",
"# get the actual propbank label.",
"label",
"=",
"annotation",
".",
"strip",
"(",
"\"()*\"",
")",
"if",
"\"(\"",
"in",
"annotation",
":",
"# Entering into a span for a particular semantic role label.",
"# We append the label and set the current span for this annotation.",
"bio_label",
"=",
"\"B-\"",
"+",
"label",
"span_labels",
"[",
"annotation_index",
"]",
".",
"append",
"(",
"bio_label",
")",
"current_span_labels",
"[",
"annotation_index",
"]",
"=",
"label",
"elif",
"current_span_labels",
"[",
"annotation_index",
"]",
"is",
"not",
"None",
":",
"# If there's no '(' token, but the current_span_label is not None,",
"# then we are inside a span.",
"bio_label",
"=",
"\"I-\"",
"+",
"current_span_labels",
"[",
"annotation_index",
"]",
"span_labels",
"[",
"annotation_index",
"]",
".",
"append",
"(",
"bio_label",
")",
"else",
":",
"# We're outside a span.",
"span_labels",
"[",
"annotation_index",
"]",
".",
"append",
"(",
"\"O\"",
")",
"# Exiting a span, so we reset the current span label for this annotation.",
"if",
"\")\"",
"in",
"annotation",
":",
"current_span_labels",
"[",
"annotation_index",
"]",
"=",
"None"
] |
Given a sequence of different label types for a single word and the current
span label we are inside, compute the BIO tag for each label and append to a list.
Parameters
----------
annotations: ``List[str]``
A list of labels to compute BIO tags for.
span_labels : ``List[List[str]]``
A list of lists, one for each annotation, to incrementally collect
the BIO tags for a sequence.
current_span_labels : ``List[Optional[str]]``
The currently open span per annotation type, or ``None`` if there is no open span.
|
[
"Given",
"a",
"sequence",
"of",
"different",
"label",
"types",
"for",
"a",
"single",
"word",
"and",
"the",
"current",
"span",
"label",
"we",
"are",
"inside",
"compute",
"the",
"BIO",
"tag",
"for",
"each",
"label",
"and",
"append",
"to",
"a",
"list",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/ontonotes.py#L411-L449
|
train
|
Given a list of annotations for a single word and a list of span labels and a list of current span labels compute the BIO tags for each annotation and append to a list of lists.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnb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ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + chr(111) + chr(49) + chr(0b110111) + chr(0b1111 + 0o50), 9222 - 9214), ehT0Px3KOsy9('\060' + '\x6f' + chr(50) + chr(0b11110 + 0o31) + '\060', 0b1000), ehT0Px3KOsy9('\060' + chr(111) + chr(0b11001 + 0o30) + chr(0b110011 + 0o4), ord("\x08")), ehT0Px3KOsy9(chr(2026 - 1978) + chr(111) + '\061' + chr(781 - 729) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(1109 - 1061) + chr(0b1001011 + 0o44) + '\x35' + chr(53), 1690 - 1682), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\062' + chr(250 - 198) + chr(296 - 245), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(1476 - 1426) + chr(0b110110) + chr(54), ord("\x08")), ehT0Px3KOsy9(chr(0b100111 + 0o11) + chr(0b1101111) + chr(458 - 407) + chr(211 - 161) + '\x31', 59238 - 59230), ehT0Px3KOsy9('\x30' + chr(9194 - 9083) + chr(0b110111), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + chr(2133 - 2083) + chr(0b110100) + chr(0b110000 + 0o2), 52753 - 52745), ehT0Px3KOsy9(chr(0b100001 + 0o17) + chr(0b10110 + 0o131) + chr(51) + chr(0b11010 + 0o27) + chr(0b1110 + 0o50), ord("\x08")), ehT0Px3KOsy9('\060' + chr(111) + chr(1505 - 1454) + '\x30' + '\x32', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101 + 0o142) + chr(1270 - 1220) + chr(0b110100) + chr(2636 - 2583), 0o10), ehT0Px3KOsy9(chr(0b100010 + 0o16) + '\x6f' + chr(1749 - 1700) + chr(424 - 376) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + chr(12221 - 12110) + chr(0b110010) + chr(51) + chr(52), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1100000 + 0o17) + '\062' + chr(0b10011 + 0o44) + '\x34', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(50) + chr(0b110010) + chr(1898 - 1844), 0o10), ehT0Px3KOsy9(chr(1599 - 1551) + chr(111) + '\x31' + '\x36' + chr(51), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110010) + chr(0b101110 + 0o3) + '\060', 0o10), ehT0Px3KOsy9(chr(994 - 946) + chr(0b1101111) + chr(0b110011) + chr(2147 - 2095) + '\x37', 14417 - 14409), ehT0Px3KOsy9(chr(48) + '\157' + chr(2117 - 2068) + '\x35', 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(1604 - 1554) + '\x30' + chr(0b11101 + 0o31), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31' + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(533 - 485) + chr(0b111011 + 0o64) + '\062' + '\067' + chr(0b110 + 0o52), 8), ehT0Px3KOsy9(chr(1538 - 1490) + chr(111) + chr(0b110011) + chr(0b100110 + 0o21) + chr(1997 - 1949), 0b1000), ehT0Px3KOsy9('\060' + '\157' + chr(0b110010) + chr(422 - 369) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b11010 + 0o125) + chr(485 - 435) + chr(53) + '\061', 0b1000), ehT0Px3KOsy9(chr(0b101011 + 0o5) + chr(0b101001 + 0o106) + chr(1739 - 1688) + chr(53) + chr(1714 - 1661), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + chr(0b110010), 0o10), ehT0Px3KOsy9('\x30' + chr(885 - 774) + '\067' + chr(0b10001 + 0o40), ord("\x08")), ehT0Px3KOsy9(chr(1092 - 1044) + chr(111) + chr(0b110011) + chr(1437 - 1383), 0o10), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(528 - 417) + chr(51) + chr(0b110 + 0o56) + chr(95 - 43), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + chr(51) + chr(2291 - 2243), 17920 - 17912), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + '\062' + '\067', 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1000 + 0o52) + '\060' + chr(0b110100), 54910 - 54902), ehT0Px3KOsy9(chr(1023 - 975) + '\157' + '\x37' + '\x35', 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b101110 + 0o4) + '\x33' + '\x35', 26519 - 26511), ehT0Px3KOsy9(chr(48) + chr(0b1101000 + 0o7) + '\062' + chr(52) + '\x36', 0b1000), ehT0Px3KOsy9('\060' + chr(11831 - 11720) + chr(0b110010) + chr(79 - 29) + '\067', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\061' + chr(0b110100) + '\064', 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(1704 - 1651) + chr(48), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'Q'), '\x64' + chr(0b11101 + 0o110) + chr(0b1001101 + 0o26) + '\157' + '\x64' + chr(0b11100 + 0o111))(chr(1573 - 1456) + chr(0b101 + 0o157) + chr(0b1100110) + chr(45) + '\x38') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def _6Ytfh3fKECD(zvbVkvaN64xd, ELCtNG4F6LZC, PnhT7GAG8zuO) -> None:
for (y3OzwTRxDgyj, vIc_73L45y1x) in YlkZvXL8qwsX(zvbVkvaN64xd):
TRUOLFLuD08x = vIc_73L45y1x.strip(xafqLlk3kkUe(SXOLrMavuUCe(b'W\x91%'), chr(0b100111 + 0o75) + chr(101) + '\143' + chr(0b1100000 + 0o17) + '\144' + '\145')('\x75' + chr(2873 - 2757) + chr(0b100001 + 0o105) + chr(0b100111 + 0o6) + '\070'))
if xafqLlk3kkUe(SXOLrMavuUCe(b'W'), '\144' + chr(0b1011110 + 0o7) + chr(99) + chr(3184 - 3073) + '\x64' + chr(0b1100101))('\x75' + chr(0b1110100) + chr(0b1100110) + chr(0b100111 + 0o6) + '\x38') in vIc_73L45y1x:
f1oMXAjPonVw = xafqLlk3kkUe(SXOLrMavuUCe(b'=\x95'), '\x64' + chr(0b1100101) + chr(3352 - 3253) + '\157' + '\144' + chr(101))(chr(0b1110101) + '\164' + chr(4993 - 4891) + chr(0b100 + 0o51) + chr(195 - 139)) + TRUOLFLuD08x
xafqLlk3kkUe(ELCtNG4F6LZC[y3OzwTRxDgyj], xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e\xc8\x7f\x07C\xc7'), chr(0b1000011 + 0o41) + chr(0b1 + 0o144) + '\143' + chr(111) + chr(4470 - 4370) + chr(0b1100101))(chr(0b111001 + 0o74) + chr(0b1110100) + '\x66' + chr(0b11010 + 0o23) + chr(0b111000)))(f1oMXAjPonVw)
PnhT7GAG8zuO[y3OzwTRxDgyj] = TRUOLFLuD08x
elif PnhT7GAG8zuO[y3OzwTRxDgyj] is not None:
f1oMXAjPonVw = xafqLlk3kkUe(SXOLrMavuUCe(b'6\x95'), chr(0b1100100) + chr(3152 - 3051) + '\143' + chr(8661 - 8550) + chr(100) + '\x65')(chr(0b1110101 + 0o0) + chr(116) + chr(102) + '\055' + chr(0b111000)) + PnhT7GAG8zuO[y3OzwTRxDgyj]
xafqLlk3kkUe(ELCtNG4F6LZC[y3OzwTRxDgyj], xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e\xc8\x7f\x07C\xc7'), '\144' + chr(0b1100101) + chr(0b1001010 + 0o31) + '\157' + chr(0b1100100) + chr(101))('\x75' + chr(0b1001110 + 0o46) + '\146' + '\x2d' + chr(0b111000)))(f1oMXAjPonVw)
else:
xafqLlk3kkUe(ELCtNG4F6LZC[y3OzwTRxDgyj], xafqLlk3kkUe(SXOLrMavuUCe(b'\x1e\xc8\x7f\x07C\xc7'), chr(100) + chr(0b1100101) + '\143' + chr(0b1101111) + '\x64' + chr(0b1100101))(chr(2647 - 2530) + chr(0b1110100) + chr(0b10011 + 0o123) + '\055' + '\070'))(xafqLlk3kkUe(SXOLrMavuUCe(b'0'), '\x64' + chr(0b10010 + 0o123) + '\x63' + chr(4760 - 4649) + chr(100) + chr(101))(chr(0b11110 + 0o127) + chr(0b1110100) + '\146' + chr(1951 - 1906) + chr(0b100110 + 0o22)))
if xafqLlk3kkUe(SXOLrMavuUCe(b'V'), chr(0b1100100) + '\145' + chr(1405 - 1306) + '\x6f' + chr(2722 - 2622) + chr(678 - 577))('\165' + chr(0b1110100) + chr(0b10010 + 0o124) + chr(45) + '\070') in vIc_73L45y1x:
PnhT7GAG8zuO[y3OzwTRxDgyj] = None
|
allenai/allennlp
|
allennlp/commands/print_results.py
|
print_results_from_args
|
def print_results_from_args(args: argparse.Namespace):
"""
Prints results from an ``argparse.Namespace`` object.
"""
path = args.path
metrics_name = args.metrics_filename
keys = args.keys
results_dict = {}
for root, _, files in os.walk(path):
if metrics_name in files:
full_name = os.path.join(root, metrics_name)
metrics = json.load(open(full_name))
results_dict[full_name] = metrics
sorted_keys = sorted(list(results_dict.keys()))
print(f"model_run, {', '.join(keys)}")
for name in sorted_keys:
results = results_dict[name]
keys_to_print = [str(results.get(key, "N/A")) for key in keys]
print(f"{name}, {', '.join(keys_to_print)}")
|
python
|
def print_results_from_args(args: argparse.Namespace):
"""
Prints results from an ``argparse.Namespace`` object.
"""
path = args.path
metrics_name = args.metrics_filename
keys = args.keys
results_dict = {}
for root, _, files in os.walk(path):
if metrics_name in files:
full_name = os.path.join(root, metrics_name)
metrics = json.load(open(full_name))
results_dict[full_name] = metrics
sorted_keys = sorted(list(results_dict.keys()))
print(f"model_run, {', '.join(keys)}")
for name in sorted_keys:
results = results_dict[name]
keys_to_print = [str(results.get(key, "N/A")) for key in keys]
print(f"{name}, {', '.join(keys_to_print)}")
|
[
"def",
"print_results_from_args",
"(",
"args",
":",
"argparse",
".",
"Namespace",
")",
":",
"path",
"=",
"args",
".",
"path",
"metrics_name",
"=",
"args",
".",
"metrics_filename",
"keys",
"=",
"args",
".",
"keys",
"results_dict",
"=",
"{",
"}",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"if",
"metrics_name",
"in",
"files",
":",
"full_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"metrics_name",
")",
"metrics",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"full_name",
")",
")",
"results_dict",
"[",
"full_name",
"]",
"=",
"metrics",
"sorted_keys",
"=",
"sorted",
"(",
"list",
"(",
"results_dict",
".",
"keys",
"(",
")",
")",
")",
"print",
"(",
"f\"model_run, {', '.join(keys)}\"",
")",
"for",
"name",
"in",
"sorted_keys",
":",
"results",
"=",
"results_dict",
"[",
"name",
"]",
"keys_to_print",
"=",
"[",
"str",
"(",
"results",
".",
"get",
"(",
"key",
",",
"\"N/A\"",
")",
")",
"for",
"key",
"in",
"keys",
"]",
"print",
"(",
"f\"{name}, {', '.join(keys_to_print)}\"",
")"
] |
Prints results from an ``argparse.Namespace`` object.
|
[
"Prints",
"results",
"from",
"an",
"argparse",
".",
"Namespace",
"object",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/commands/print_results.py#L66-L88
|
train
|
Prints results from an argparse. Namespace object.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV,WTxpD_zsEOh2,LgE_IO_tHXvM,K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3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1051 - 1003) + '\x6f' + chr(0b110001) + chr(54) + '\061', 40442 - 40434), ehT0Px3KOsy9('\x30' + chr(0b10000 + 0o137) + '\x37' + chr(0b10001 + 0o40), ord("\x08")), ehT0Px3KOsy9(chr(303 - 255) + chr(111) + '\x31' + chr(0b110000) + chr(0b11111 + 0o22), 0b1000), ehT0Px3KOsy9(chr(685 - 637) + chr(8371 - 8260) + chr(0b10 + 0o62) + chr(0b110101), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + chr(51) + '\x33' + chr(50), 17950 - 17942), ehT0Px3KOsy9('\x30' + '\x6f' + chr(50) + chr(53) + chr(1148 - 1098), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\063' + '\x35' + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(825 - 777) + chr(0b1101111) + '\x33' + '\065' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10110 + 0o131) + chr(54) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b111101 + 0o62) + '\062' + '\x36' + chr(0b110001), 59202 - 59194), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(55) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(1283 - 1235) + '\x6f' + chr(0b101011 + 0o10) + '\x33' + '\065', 0o10), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(1411 - 1300) + '\065', ord("\x08")), ehT0Px3KOsy9(chr(644 - 596) + '\157' + chr(0b110011) + '\x32' + '\063', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101011 + 0o4) + chr(1118 - 1068) + chr(0b11100 + 0o32) + chr(0b100101 + 0o22), 0o10), ehT0Px3KOsy9('\060' + chr(0b100011 + 0o114) + chr(0b10 + 0o60) + chr(55) + '\063', 44806 - 44798), ehT0Px3KOsy9('\x30' + chr(0b100 + 0o153) + chr(0b111 + 0o53) + chr(51), 42987 - 42979), ehT0Px3KOsy9(chr(151 - 103) + '\x6f' + chr(1131 - 1077) + chr(0b1000 + 0o57), 8), ehT0Px3KOsy9('\060' + chr(0b110011 + 0o74) + chr(0b110011) + '\064' + '\062', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(4437 - 4326) + chr(49) + '\067' + chr(0b110010), 8018 - 8010), ehT0Px3KOsy9(chr(1483 - 1435) + '\x6f' + '\x34' + chr(0b10101 + 0o40), 8), ehT0Px3KOsy9(chr(0b10 + 0o56) + chr(0b1101111) + chr(0b110001) + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110101) + chr(0b110 + 0o52), 26327 - 26319), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + '\062' + chr(0b10110 + 0o37), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1001 + 0o50) + chr(0b110011 + 0o4) + chr(0b10100 + 0o42), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b100111 + 0o15) + chr(1602 - 1552), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x32' + chr(0b1101 + 0o52) + chr(0b101000 + 0o11), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\067' + chr(0b110001), 8), ehT0Px3KOsy9(chr(0b10111 + 0o31) + chr(111) + chr(53) + chr(0b110011), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(51) + '\x32' + chr(52), 0b1000), ehT0Px3KOsy9(chr(2128 - 2080) + chr(0b1010100 + 0o33) + chr(51) + '\063' + chr(0b101000 + 0o11), 0b1000), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(7259 - 7148) + chr(49) + '\065' + '\064', 21900 - 21892), ehT0Px3KOsy9(chr(2000 - 1952) + chr(2953 - 2842) + chr(0b100 + 0o55) + chr(55) + '\067', 0o10), ehT0Px3KOsy9(chr(48) + chr(1530 - 1419) + chr(0b110100) + chr(55), 0b1000), ehT0Px3KOsy9(chr(0b1011 + 0o45) + '\x6f' + chr(0b1011 + 0o50) + chr(0b110110) + '\x32', 61742 - 61734), ehT0Px3KOsy9(chr(0b110000) + chr(0b110101 + 0o72) + '\x33' + chr(49) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(111) + '\067' + chr(0b100 + 0o60), 0o10), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(0b110010 + 0o75) + chr(0b110100) + chr(53), 8), ehT0Px3KOsy9(chr(1311 - 1263) + chr(11410 - 11299) + chr(0b10111 + 0o33) + chr(865 - 817) + '\x32', ord("\x08")), ehT0Px3KOsy9(chr(624 - 576) + chr(0b1101111) + '\062' + '\x36' + chr(53), 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(795 - 742) + chr(293 - 245), 8)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'_'), chr(0b111101 + 0o47) + chr(0b1001010 + 0o33) + chr(0b1100011) + '\157' + chr(0b10110 + 0o116) + chr(0b101000 + 0o75))('\x75' + chr(9180 - 9064) + chr(102) + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def wvS314ekNF93(kJDRfRhcZHjS):
EaCjyhZptSer = kJDRfRhcZHjS.path
RtYvagR4WwDu = kJDRfRhcZHjS.metrics_filename
w8H8C9ec5BO1 = kJDRfRhcZHjS.keys
hzpoLpCUjUKY = {}
for (FiL2Xt3u2AMN, VNGQdHSFPrso, uyc48vokp5OE) in xafqLlk3kkUe(oqhJDdMJfuwx, xafqLlk3kkUe(SXOLrMavuUCe(b'\x06X-N'), '\144' + chr(0b1100101) + chr(2239 - 2140) + '\157' + chr(287 - 187) + chr(5246 - 5145))(chr(0b1110101) + chr(7242 - 7126) + '\146' + '\055' + chr(0b111000)))(EaCjyhZptSer):
if RtYvagR4WwDu in uyc48vokp5OE:
je7_3_Zvuq2o = oqhJDdMJfuwx.path._oWXztVNnqHF(FiL2Xt3u2AMN, RtYvagR4WwDu)
yYegMqDoSfs5 = fXk443epxtd5.mxtdQMeiwJZJ(_fwkIVCGgtAN(je7_3_Zvuq2o))
hzpoLpCUjUKY[je7_3_Zvuq2o] = yYegMqDoSfs5
BLAnPTKfUUc5 = vUlqIvNSaRMa(YyaZ4tpXu4lf(hzpoLpCUjUKY.keys()))
zLUzGokYBM2Z(f"model_run, {xafqLlk3kkUe(chr(0b110 + 0o46) + chr(32), chr(0b11 + 0o134) + chr(111) + chr(7071 - 6984) + chr(88) + chr(122) + chr(116) + chr(2546 - 2460) + chr(4571 - 4493) + chr(9259 - 9149) + chr(10606 - 10493) + chr(2520 - 2448) + chr(70))(w8H8C9ec5BO1)}")
for AIvJRzLdDfgF in BLAnPTKfUUc5:
iIGKX2zSEGYP = hzpoLpCUjUKY[AIvJRzLdDfgF]
pLqEw37Yxsle = [M8_cKLkHVB2V(iIGKX2zSEGYP.get(K3J4ZwSlE0sT, xafqLlk3kkUe(SXOLrMavuUCe(b'?\x16\x00'), '\x64' + chr(0b11 + 0o142) + chr(99) + chr(5750 - 5639) + '\144' + '\x65')(chr(0b1110101) + '\164' + chr(0b1100110) + chr(0b101101) + chr(56)))) for K3J4ZwSlE0sT in w8H8C9ec5BO1]
zLUzGokYBM2Z(f"{AIvJRzLdDfgF}, {xafqLlk3kkUe(chr(0b101100) + chr(32), chr(0b10010 + 0o115) + chr(0b1100000 + 0o17) + chr(0b1000111 + 0o20) + chr(0b1011000) + chr(0b1111010) + chr(0b1110100) + chr(5553 - 5467) + chr(78) + chr(110) + chr(237 - 124) + chr(2837 - 2765) + chr(0b1000110))(pLqEw37Yxsle)}")
|
allenai/allennlp
|
allennlp/modules/input_variational_dropout.py
|
InputVariationalDropout.forward
|
def forward(self, input_tensor):
# pylint: disable=arguments-differ
"""
Apply dropout to input tensor.
Parameters
----------
input_tensor: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)``
Returns
-------
output: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)`` with dropout applied.
"""
ones = input_tensor.data.new_ones(input_tensor.shape[0], input_tensor.shape[-1])
dropout_mask = torch.nn.functional.dropout(ones, self.p, self.training, inplace=False)
if self.inplace:
input_tensor *= dropout_mask.unsqueeze(1)
return None
else:
return dropout_mask.unsqueeze(1) * input_tensor
|
python
|
def forward(self, input_tensor):
# pylint: disable=arguments-differ
"""
Apply dropout to input tensor.
Parameters
----------
input_tensor: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)``
Returns
-------
output: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)`` with dropout applied.
"""
ones = input_tensor.data.new_ones(input_tensor.shape[0], input_tensor.shape[-1])
dropout_mask = torch.nn.functional.dropout(ones, self.p, self.training, inplace=False)
if self.inplace:
input_tensor *= dropout_mask.unsqueeze(1)
return None
else:
return dropout_mask.unsqueeze(1) * input_tensor
|
[
"def",
"forward",
"(",
"self",
",",
"input_tensor",
")",
":",
"# pylint: disable=arguments-differ",
"ones",
"=",
"input_tensor",
".",
"data",
".",
"new_ones",
"(",
"input_tensor",
".",
"shape",
"[",
"0",
"]",
",",
"input_tensor",
".",
"shape",
"[",
"-",
"1",
"]",
")",
"dropout_mask",
"=",
"torch",
".",
"nn",
".",
"functional",
".",
"dropout",
"(",
"ones",
",",
"self",
".",
"p",
",",
"self",
".",
"training",
",",
"inplace",
"=",
"False",
")",
"if",
"self",
".",
"inplace",
":",
"input_tensor",
"*=",
"dropout_mask",
".",
"unsqueeze",
"(",
"1",
")",
"return",
"None",
"else",
":",
"return",
"dropout_mask",
".",
"unsqueeze",
"(",
"1",
")",
"*",
"input_tensor"
] |
Apply dropout to input tensor.
Parameters
----------
input_tensor: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)``
Returns
-------
output: ``torch.FloatTensor``
A tensor of shape ``(batch_size, num_timesteps, embedding_dim)`` with dropout applied.
|
[
"Apply",
"dropout",
"to",
"input",
"tensor",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/input_variational_dropout.py#L13-L34
|
train
|
Forward computation of the log - likelihood of a single entry.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsD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ZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\157' + chr(2586 - 2535) + '\x33' + chr(0b100110 + 0o15), 50285 - 50277), ehT0Px3KOsy9('\x30' + chr(11217 - 11106) + '\067' + '\061', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(576 - 524) + chr(816 - 763), 0b1000), ehT0Px3KOsy9('\x30' + chr(3302 - 3191) + chr(851 - 802) + chr(1784 - 1730) + chr(0b110100), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(2272 - 2161) + chr(0b110010) + chr(435 - 384) + chr(49), ord("\x08")), ehT0Px3KOsy9(chr(1856 - 1808) + '\x6f' + chr(0b110110) + '\x31', 7608 - 7600), ehT0Px3KOsy9(chr(48) + chr(862 - 751) + chr(698 - 648) + chr(0b110011) + chr(2373 - 2319), 32776 - 32768), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + '\x37' + '\060', 7896 - 7888), ehT0Px3KOsy9(chr(0b11110 + 0o22) + chr(111) + chr(0b110011) + '\062' + chr(0b1100 + 0o44), 0o10), ehT0Px3KOsy9(chr(1109 - 1061) + chr(0b1101111) + chr(54) + '\060', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b101001 + 0o12) + '\061' + chr(0b100001 + 0o25), 10581 - 10573), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\x31' + '\x36' + chr(49), 0o10), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + chr(0b110110) + chr(0b0 + 0o60), 8), ehT0Px3KOsy9('\060' + '\157' + chr(1044 - 993) + '\x34' + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + chr(9501 - 9390) + '\062' + chr(2006 - 1951) + chr(0b110101), 54925 - 54917), ehT0Px3KOsy9(chr(0b110000) + chr(4854 - 4743) + chr(51) + '\x30' + chr(49), 0o10), ehT0Px3KOsy9(chr(1635 - 1587) + chr(0b101010 + 0o105) + chr(0b100100 + 0o17) + '\064' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(857 - 809) + '\x6f' + chr(50) + chr(769 - 719) + chr(0b110101 + 0o1), ord("\x08")), ehT0Px3KOsy9(chr(2144 - 2096) + '\x6f' + '\061' + '\x32' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\157' + '\x32' + chr(52) + '\x35', 15091 - 15083), ehT0Px3KOsy9(chr(48) + chr(9528 - 9417) + chr(2284 - 2235) + chr(0b101011 + 0o13) + chr(1009 - 958), 1925 - 1917), ehT0Px3KOsy9(chr(821 - 773) + '\x6f' + chr(0b110010) + '\064' + chr(0b110010 + 0o4), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(875 - 824) + chr(51) + chr(53), 49770 - 49762), ehT0Px3KOsy9(chr(0b110000) + chr(5354 - 5243) + chr(0b110001) + '\x34' + '\062', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + '\x30' + chr(48), 0o10), ehT0Px3KOsy9('\060' + chr(0b111111 + 0o60) + '\063' + chr(0b110111) + chr(0b100100 + 0o23), 21405 - 21397), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b101 + 0o152) + chr(1920 - 1866) + '\x31', 8), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + chr(51) + chr(938 - 883) + '\x33', 0b1000), ehT0Px3KOsy9(chr(0b100101 + 0o13) + '\157' + chr(0b110011 + 0o4) + '\x32', 0b1000), ehT0Px3KOsy9(chr(1104 - 1056) + '\x6f' + chr(728 - 677) + '\x32', 0o10), ehT0Px3KOsy9('\060' + chr(11014 - 10903) + '\061' + '\x36' + chr(0b110100), 8), ehT0Px3KOsy9('\x30' + chr(8960 - 8849) + chr(402 - 353) + chr(0b110001), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + '\x31' + '\064' + '\x32', 8), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110110) + chr(54), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b11010 + 0o125) + chr(0b110010) + '\066' + chr(0b110111), 45287 - 45279), ehT0Px3KOsy9(chr(0b110000) + chr(254 - 143) + '\063' + '\064' + chr(0b11100 + 0o30), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110001) + chr(0b110000) + chr(0b110000), 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(1963 - 1913) + chr(55), 63610 - 63602), ehT0Px3KOsy9(chr(0b110000) + chr(0b1110 + 0o141) + chr(0b110011) + chr(0b110010), 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(2337 - 2287) + '\x34' + chr(54), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110101) + chr(132 - 84), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5'), chr(2704 - 2604) + '\x65' + chr(99) + chr(0b1101111) + '\144' + chr(0b110100 + 0o61))(chr(117) + '\164' + '\146' + '\055' + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def GbbcCHUNFMj5(oVre8I6UXc3b, q72q5IycyilC):
Q9MMic9MQj7n = q72q5IycyilC.data.new_ones(q72q5IycyilC.nauYfLglTpcb[ehT0Px3KOsy9('\060' + '\157' + chr(0b110000), 0b1000)], q72q5IycyilC.nauYfLglTpcb[-ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x31', 0o10)])
HyMmWPuGKzDp = cEkFpYktkSeK.nn.functional.ag0mwEgWzjYv(Q9MMic9MQj7n, oVre8I6UXc3b.p, oVre8I6UXc3b.training, inplace=ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b110000), 8))
if xafqLlk3kkUe(oVre8I6UXc3b, xafqLlk3kkUe(SXOLrMavuUCe(b'\xb2WU\x18\xf8R\xfb'), '\144' + chr(0b1100101) + '\x63' + '\x6f' + '\144' + chr(0b1100101))('\x75' + chr(476 - 360) + chr(102) + chr(45) + '\x38')):
q72q5IycyilC *= HyMmWPuGKzDp.unsqueeze(ehT0Px3KOsy9(chr(1351 - 1303) + '\x6f' + '\x31', 8))
return None
else:
return xafqLlk3kkUe(HyMmWPuGKzDp, xafqLlk3kkUe(SXOLrMavuUCe(b'\xaeWV\x05\xecT\xfb\x02\xb5'), chr(0b101010 + 0o72) + chr(0b1100101) + chr(8537 - 8438) + chr(111) + '\x64' + '\145')(chr(117) + '\x74' + chr(0b101110 + 0o70) + '\055' + chr(914 - 858)))(ehT0Px3KOsy9(chr(0b101110 + 0o2) + '\x6f' + chr(0b110001), 8)) * q72q5IycyilC
|
allenai/allennlp
|
allennlp/training/metrics/metric.py
|
Metric.get_metric
|
def get_metric(self, reset: bool) -> Union[float, Tuple[float, ...], Dict[str, float], Dict[str, List[float]]]:
"""
Compute and return the metric. Optionally also call :func:`self.reset`.
"""
raise NotImplementedError
|
python
|
def get_metric(self, reset: bool) -> Union[float, Tuple[float, ...], Dict[str, float], Dict[str, List[float]]]:
"""
Compute and return the metric. Optionally also call :func:`self.reset`.
"""
raise NotImplementedError
|
[
"def",
"get_metric",
"(",
"self",
",",
"reset",
":",
"bool",
")",
"->",
"Union",
"[",
"float",
",",
"Tuple",
"[",
"float",
",",
"...",
"]",
",",
"Dict",
"[",
"str",
",",
"float",
"]",
",",
"Dict",
"[",
"str",
",",
"List",
"[",
"float",
"]",
"]",
"]",
":",
"raise",
"NotImplementedError"
] |
Compute and return the metric. Optionally also call :func:`self.reset`.
|
[
"Compute",
"and",
"return",
"the",
"metric",
".",
"Optionally",
"also",
"call",
":",
"func",
":",
"self",
".",
"reset",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metrics/metric.py#L29-L33
|
train
|
Compute and return the metric. Optionally reset the metric.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,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40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1942 - 1894) + '\157' + '\063' + chr(0b110001) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(411 - 363) + '\x6f' + chr(49) + '\x30' + chr(0b110001), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(49) + chr(0b101110 + 0o7) + chr(246 - 196), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(0b1110 + 0o47), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110010) + '\065' + chr(2137 - 2084), 31387 - 31379), ehT0Px3KOsy9(chr(365 - 317) + '\157' + chr(51) + chr(0b10 + 0o64) + '\x31', 0o10), ehT0Px3KOsy9(chr(1477 - 1429) + chr(111) + chr(0b110010) + '\067' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b11110 + 0o22) + '\x6f' + chr(0b110010) + chr(53) + '\x30', 18420 - 18412), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1804 - 1754) + '\x33' + chr(49), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\x33' + chr(50) + chr(586 - 538), 0o10), ehT0Px3KOsy9(chr(0b11010 + 0o26) + '\157' + '\x34', 0o10), ehT0Px3KOsy9(chr(2251 - 2203) + chr(0b1101111) + chr(0b100010 + 0o20) + chr(0b1 + 0o66), 31183 - 31175), ehT0Px3KOsy9('\060' + chr(0b1000010 + 0o55) + '\x32' + '\063' + '\x35', 0b1000), ehT0Px3KOsy9('\060' + chr(7550 - 7439) + chr(0b110011 + 0o0) + chr(0b110101) + chr(0b110000), 39201 - 39193), ehT0Px3KOsy9(chr(48) + chr(9895 - 9784) + '\062' + '\x30', 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\061' + '\x37' + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + chr(1592 - 1541) + chr(0b110100), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(0b110001) + chr(2292 - 2242), 60946 - 60938), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\063' + chr(0b11001 + 0o32) + chr(425 - 376), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1782 - 1733) + chr(1695 - 1646) + chr(0b100001 + 0o20), ord("\x08")), ehT0Px3KOsy9(chr(1788 - 1740) + '\157' + '\061' + chr(1825 - 1776) + chr(0b11110 + 0o30), 0o10), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(0b11000 + 0o33) + chr(0b110010) + '\x33', 5175 - 5167), ehT0Px3KOsy9(chr(391 - 343) + '\157' + chr(0b110011) + '\x32', 44801 - 44793), ehT0Px3KOsy9(chr(2112 - 2064) + chr(111) + chr(2018 - 1967) + chr(0b110000) + chr(2156 - 2108), 0b1000), ehT0Px3KOsy9('\x30' + chr(9752 - 9641) + chr(0b1001 + 0o51) + chr(746 - 695), 0o10), ehT0Px3KOsy9('\060' + '\157' + chr(0b1000 + 0o52) + '\066' + '\064', 47284 - 47276), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\157' + '\063' + chr(0b100101 + 0o16) + '\060', ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + '\x32' + chr(1565 - 1512), 0b1000), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(111) + chr(0b110111), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1011110 + 0o21) + chr(49) + chr(0b101110 + 0o4) + chr(0b110011), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1000 + 0o147) + chr(0b110010) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(0b1101111) + '\x35' + chr(0b11111 + 0o24), 29577 - 29569), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\x32' + chr(0b1100 + 0o45) + '\x33', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1010110 + 0o31) + chr(2605 - 2550) + chr(0b110010), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101100 + 0o3) + '\061' + '\066' + chr(49), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b10110 + 0o131) + '\062' + chr(1907 - 1855) + chr(1126 - 1071), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001) + '\064' + '\x32', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + '\063' + chr(0b110100) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100 + 0o57) + chr(539 - 485) + chr(564 - 513), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1101 + 0o46) + chr(52), 13424 - 13416)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\065' + chr(0b10100 + 0o34), 63995 - 63987)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xe7'), chr(8351 - 8251) + chr(5618 - 5517) + '\143' + chr(0b10100 + 0o133) + chr(100) + chr(0b1110 + 0o127))(chr(117) + chr(0b1110100) + chr(0b11010 + 0o114) + chr(1226 - 1181) + chr(0b10100 + 0o44)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def P26JJOvom4uc(oVre8I6UXc3b, G0V856pwkJmZ) -> xS28O63k1eqo[kkSX4ccExqw4, MRK8Uzg2En3D[kkSX4ccExqw4, ...], zBnV56fc6HrA[M8_cKLkHVB2V, kkSX4ccExqw4], zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[kkSX4ccExqw4]]]:
raise _zJ24Vce7wp0
|
allenai/allennlp
|
allennlp/training/metrics/metric.py
|
Metric.unwrap_to_tensors
|
def unwrap_to_tensors(*tensors: torch.Tensor):
"""
If you actually passed gradient-tracking Tensors to a Metric, there will be
a huge memory leak, because it will prevent garbage collection for the computation
graph. This method ensures that you're using tensors directly and that they are on
the CPU.
"""
return (x.detach().cpu() if isinstance(x, torch.Tensor) else x for x in tensors)
|
python
|
def unwrap_to_tensors(*tensors: torch.Tensor):
"""
If you actually passed gradient-tracking Tensors to a Metric, there will be
a huge memory leak, because it will prevent garbage collection for the computation
graph. This method ensures that you're using tensors directly and that they are on
the CPU.
"""
return (x.detach().cpu() if isinstance(x, torch.Tensor) else x for x in tensors)
|
[
"def",
"unwrap_to_tensors",
"(",
"*",
"tensors",
":",
"torch",
".",
"Tensor",
")",
":",
"return",
"(",
"x",
".",
"detach",
"(",
")",
".",
"cpu",
"(",
")",
"if",
"isinstance",
"(",
"x",
",",
"torch",
".",
"Tensor",
")",
"else",
"x",
"for",
"x",
"in",
"tensors",
")"
] |
If you actually passed gradient-tracking Tensors to a Metric, there will be
a huge memory leak, because it will prevent garbage collection for the computation
graph. This method ensures that you're using tensors directly and that they are on
the CPU.
|
[
"If",
"you",
"actually",
"passed",
"gradient",
"-",
"tracking",
"Tensors",
"to",
"a",
"Metric",
"there",
"will",
"be",
"a",
"huge",
"memory",
"leak",
"because",
"it",
"will",
"prevent",
"garbage",
"collection",
"for",
"the",
"computation",
"graph",
".",
"This",
"method",
"ensures",
"that",
"you",
"re",
"using",
"tensors",
"directly",
"and",
"that",
"they",
"are",
"on",
"the",
"CPU",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metrics/metric.py#L42-L49
|
train
|
Unwraps a list of tensors into a Metric.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,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YwBvYW,iDQ_gSK8V7h0,Rurm1zTRfSmY,reqGiMiVQ77y,bsS9P6_LpdIe,sbGAZlkZOtyh,Cf_Qef15s3_F,eX02hlZjMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(48) + '\x6f' + '\064' + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x31' + '\064' + chr(2535 - 2482), 0o10), ehT0Px3KOsy9('\060' + chr(0b111100 + 0o63) + chr(841 - 791) + chr(0b1101 + 0o43) + '\x34', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110011) + chr(49) + chr(51), 0o10), ehT0Px3KOsy9('\x30' + chr(5880 - 5769) + '\064' + chr(49), 58373 - 58365), ehT0Px3KOsy9(chr(48) + chr(11557 - 11446) + '\x36' + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x32' + '\062' + chr(0b111 + 0o53), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x33' + '\x33' + '\066', 0o10), ehT0Px3KOsy9('\060' + chr(0b1001110 + 0o41) + chr(0b1110 + 0o44) + chr(0b110110), 0b1000), ehT0Px3KOsy9(chr(0b101 + 0o53) + chr(0b1101111) + '\061' + chr(2155 - 2103) + chr(0b110100), 59806 - 59798), ehT0Px3KOsy9('\x30' + chr(0b1010101 + 0o32) + chr(0b101000 + 0o11) + chr(0b110110) + '\x37', ord("\x08")), ehT0Px3KOsy9(chr(0b10011 + 0o35) + '\157' + chr(49) + '\063' + chr(1442 - 1392), 40496 - 40488), ehT0Px3KOsy9(chr(0b101 + 0o53) + '\x6f' + '\x36' + chr(55), 8), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b110100) + '\x34', 0b1000), ehT0Px3KOsy9('\060' + chr(0b1011011 + 0o24) + chr(0b110001) + chr(1883 - 1831) + '\061', ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + chr(0b1100 + 0o44) + chr(54), 0b1000), ehT0Px3KOsy9(chr(48) + '\x6f' + chr(51) + chr(0b101001 + 0o7) + '\066', 8), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b110010) + chr(0b10101 + 0o41) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101001 + 0o6) + chr(0b110011) + chr(48) + chr(804 - 755), 0o10), ehT0Px3KOsy9('\x30' + chr(5241 - 5130) + '\067' + chr(0b101110 + 0o3), 0b1000), ehT0Px3KOsy9(chr(0b110 + 0o52) + '\157' + '\063' + '\x34' + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\062' + chr(2336 - 2286) + chr(54), 46078 - 46070), ehT0Px3KOsy9(chr(48) + '\157' + chr(51) + chr(0b10 + 0o65) + chr(0b110001), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10000 + 0o41) + chr(0b110100) + chr(0b110011), 31435 - 31427), ehT0Px3KOsy9('\060' + chr(111) + chr(2116 - 2065) + chr(0b110111) + '\x33', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(6472 - 6361) + '\062' + '\066', 8), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b110111) + chr(0b110100), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b1000 + 0o53) + '\067' + chr(0b110 + 0o54), 0b1000), ehT0Px3KOsy9('\x30' + '\x6f' + '\x31' + chr(0b110010 + 0o5) + chr(1006 - 952), 20267 - 20259), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(8919 - 8808) + chr(49) + '\060' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b110100 + 0o3) + chr(1535 - 1486), 31776 - 31768), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(0b110101) + '\x30', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b110011) + chr(2565 - 2514) + chr(0b110000 + 0o4), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x31' + '\x35' + chr(950 - 898), 0b1000), ehT0Px3KOsy9('\x30' + chr(3327 - 3216) + chr(0b10101 + 0o36) + chr(0b100000 + 0o23) + chr(0b110010), 53504 - 53496), ehT0Px3KOsy9(chr(1380 - 1332) + '\157' + chr(51) + '\x33' + chr(0b110010), 8), ehT0Px3KOsy9(chr(48) + chr(111) + chr(2408 - 2358) + chr(53) + chr(0b110101), 54796 - 54788), ehT0Px3KOsy9('\060' + '\157' + chr(51) + '\067', 36768 - 36760), ehT0Px3KOsy9(chr(48) + chr(2075 - 1964) + '\066' + chr(0b110110), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b1110 + 0o45) + chr(53) + chr(485 - 437), 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + '\x6f' + chr(1422 - 1369) + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\x08'), chr(2795 - 2695) + chr(101) + chr(0b1100011) + '\x6f' + '\144' + '\145')('\x75' + chr(0b1110100) + chr(102) + '\055' + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def H3MEcTx2AM43(*Tyy4rche81dW):
return (xafqLlk3kkUe(OeWW0F1dBPRQ.detach(), xafqLlk3kkUe(SXOLrMavuUCe(b'E\x15\xf1'), '\144' + chr(0b1100101) + chr(4441 - 4342) + '\x6f' + chr(0b1000100 + 0o40) + chr(0b1101 + 0o130))('\x75' + chr(116) + chr(0b111 + 0o137) + chr(0b101101) + chr(0b11011 + 0o35)))() if PlSM16l2KDPD(OeWW0F1dBPRQ, xafqLlk3kkUe(cEkFpYktkSeK, xafqLlk3kkUe(SXOLrMavuUCe(b'r\x00\xea\xb8NE'), chr(0b1100100) + '\145' + chr(0b1100011) + chr(12126 - 12015) + '\144' + chr(0b1100101))(chr(0b100001 + 0o124) + chr(116) + '\146' + chr(45) + chr(0b111000)))) else OeWW0F1dBPRQ for OeWW0F1dBPRQ in Tyy4rche81dW)
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py
|
replace_variables
|
def replace_variables(sentence: List[str],
sentence_variables: Dict[str, str]) -> Tuple[List[str], List[str]]:
"""
Replaces abstract variables in text with their concrete counterparts.
"""
tokens = []
tags = []
for token in sentence:
if token not in sentence_variables:
tokens.append(token)
tags.append("O")
else:
for word in sentence_variables[token].split():
tokens.append(word)
tags.append(token)
return tokens, tags
|
python
|
def replace_variables(sentence: List[str],
sentence_variables: Dict[str, str]) -> Tuple[List[str], List[str]]:
"""
Replaces abstract variables in text with their concrete counterparts.
"""
tokens = []
tags = []
for token in sentence:
if token not in sentence_variables:
tokens.append(token)
tags.append("O")
else:
for word in sentence_variables[token].split():
tokens.append(word)
tags.append(token)
return tokens, tags
|
[
"def",
"replace_variables",
"(",
"sentence",
":",
"List",
"[",
"str",
"]",
",",
"sentence_variables",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"Tuple",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"str",
"]",
"]",
":",
"tokens",
"=",
"[",
"]",
"tags",
"=",
"[",
"]",
"for",
"token",
"in",
"sentence",
":",
"if",
"token",
"not",
"in",
"sentence_variables",
":",
"tokens",
".",
"append",
"(",
"token",
")",
"tags",
".",
"append",
"(",
"\"O\"",
")",
"else",
":",
"for",
"word",
"in",
"sentence_variables",
"[",
"token",
"]",
".",
"split",
"(",
")",
":",
"tokens",
".",
"append",
"(",
"word",
")",
"tags",
".",
"append",
"(",
"token",
")",
"return",
"tokens",
",",
"tags"
] |
Replaces abstract variables in text with their concrete counterparts.
|
[
"Replaces",
"abstract",
"variables",
"in",
"text",
"with",
"their",
"concrete",
"counterparts",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py#L65-L80
|
train
|
Replaces abstract variables in text with their concrete counterparts.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGF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jMfR0,wLqBDw8l0eIm,g1Uy6IV0tyJQ,f9CsFWzvg0Vq,YlkZvXL8qwsX,MCqssyYhLtLC,bpgWCAbiJWkL,CMUdZtaORwo4,hi1V0ySZcNds,kkSX4ccExqw4,V4roHaS3Ppej,o8rvoPw8ep3k,xafqLlk3kkUe,h0qciNl3EEEj,lot1PSoAwYhj,xfhwxiBOH72k,HcyiPkCViZiX,fOIXYo9a1WNS,z8EhBlYI2Bx4,Y3jVKaC8LEDU,ehT0Px3KOsy9,PlSM16l2KDPD,J6u1YyThfhgG,ZdP978XkGspL,c2A0yzQpDQB3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110011) + chr(0b1110 + 0o51) + chr(232 - 183), 852 - 844), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + chr(0b110100) + chr(2294 - 2240), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b11111 + 0o22) + chr(0b1010 + 0o53) + chr(2640 - 2587), 64815 - 64807), ehT0Px3KOsy9('\x30' + '\157' + chr(0b101011 + 0o7) + chr(0b11110 + 0o23), ord("\x08")), ehT0Px3KOsy9('\060' + chr(2200 - 2089) + chr(59 - 10) + chr(53) + chr(52), 41977 - 41969), ehT0Px3KOsy9('\060' + chr(8478 - 8367) + chr(0b110001) + '\x34' + chr(887 - 832), 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b111001 + 0o66) + chr(0b100011 + 0o17) + chr(1872 - 1822), 0o10), ehT0Px3KOsy9(chr(1031 - 983) + '\x6f' + chr(0b110010) + chr(0b110000) + '\065', 0o10), ehT0Px3KOsy9(chr(0b1100 + 0o44) + '\x6f' + chr(494 - 443) + chr(1309 - 1255) + '\065', 0o10), ehT0Px3KOsy9(chr(0b101110 + 0o2) + chr(0b1101111) + chr(0b1000 + 0o53) + chr(0b100000 + 0o20) + chr(0b101000 + 0o11), 38697 - 38689), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + '\x34' + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b11011 + 0o26), 8), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b110010) + '\066' + chr(0b1110 + 0o42), 0o10), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b110101) + chr(0b110010), 50859 - 50851), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110001) + '\061' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9(chr(400 - 352) + chr(0b1100110 + 0o11) + chr(0b1010 + 0o52) + '\064', 0b1000), ehT0Px3KOsy9('\060' + chr(0b100010 + 0o115) + '\063' + chr(52) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(1880 - 1832) + '\157' + chr(0b10001 + 0o42) + chr(0b10100 + 0o37) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(0b10101 + 0o41), 48386 - 48378), ehT0Px3KOsy9(chr(48) + chr(0b1001101 + 0o42) + chr(348 - 299) + chr(55) + chr(0b110110), 0o10), ehT0Px3KOsy9('\x30' + '\157' + '\063' + chr(0b110010) + chr(534 - 485), 0b1000), ehT0Px3KOsy9(chr(2103 - 2055) + '\x6f' + chr(49), 0b1000), ehT0Px3KOsy9(chr(1098 - 1050) + chr(5445 - 5334) + chr(2239 - 2189) + '\x33' + chr(0b110100), 30552 - 30544), ehT0Px3KOsy9(chr(0b10101 + 0o33) + '\x6f' + chr(1035 - 983) + '\060', 0o10), ehT0Px3KOsy9(chr(0b100001 + 0o17) + '\x6f' + '\061' + '\065' + '\x32', 40721 - 40713), ehT0Px3KOsy9(chr(496 - 448) + chr(0b1101111) + '\x37' + chr(0b10011 + 0o36), ord("\x08")), ehT0Px3KOsy9(chr(272 - 224) + chr(111) + chr(0b110011) + chr(0b110100 + 0o1) + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(7631 - 7520) + chr(49) + chr(0b110010) + chr(0b110001), 0o10), ehT0Px3KOsy9('\060' + chr(0b0 + 0o157) + chr(0b110010) + chr(0b110100) + '\065', 0o10), ehT0Px3KOsy9(chr(0b11011 + 0o25) + chr(0b1101110 + 0o1) + chr(975 - 926) + chr(51) + chr(55), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1001 + 0o146) + chr(467 - 416) + chr(743 - 690) + chr(3005 - 2950), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b1110 + 0o44) + '\x30' + chr(51), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b10110 + 0o33) + '\060' + chr(0b10000 + 0o46), 38523 - 38515), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061' + '\x31' + '\065', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(0b110101) + chr(0b11110 + 0o30), 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(765 - 714) + chr(50) + chr(0b110011), 33035 - 33027), ehT0Px3KOsy9(chr(0b10011 + 0o35) + chr(0b1101111) + chr(0b110000 + 0o2) + '\067' + '\x37', 0b1000), ehT0Px3KOsy9(chr(48) + chr(0b1001011 + 0o44) + '\061' + '\x31' + chr(267 - 216), 41446 - 41438), ehT0Px3KOsy9(chr(0b110000) + '\157' + '\062' + chr(0b110110) + chr(0b110000), 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(0b1100111 + 0o10) + '\065' + '\x30', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), '\144' + '\x65' + chr(0b11001 + 0o112) + '\x6f' + chr(0b1100100 + 0o0) + chr(101))('\x75' + chr(0b10000 + 0o144) + chr(102) + chr(0b0 + 0o55) + chr(0b110001 + 0o7)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def qUzVKdwNeyaO(pamQPTGoym5v, rVlqe6Feserk) -> MRK8Uzg2En3D[qRxF7OQ0y39T[M8_cKLkHVB2V], qRxF7OQ0y39T[M8_cKLkHVB2V]]:
Sz7tXxaCGqJ1 = []
MRGa81KE7QCh = []
for mTy3fac_AqJ5 in pamQPTGoym5v:
if mTy3fac_AqJ5 not in rVlqe6Feserk:
xafqLlk3kkUe(Sz7tXxaCGqJ1, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\xd6\x1dt\x02\x03'), '\144' + chr(101) + chr(99) + chr(111) + chr(0b1100100) + chr(0b11 + 0o142))('\165' + chr(0b0 + 0o164) + chr(0b1100001 + 0o5) + '\x2d' + chr(0b1101 + 0o53)))(mTy3fac_AqJ5)
xafqLlk3kkUe(MRGa81KE7QCh, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\xd6\x1dt\x02\x03'), chr(6308 - 6208) + '\x65' + chr(0b11101 + 0o106) + chr(0b1101000 + 0o7) + chr(0b10110 + 0o116) + '\x65')('\165' + chr(0b1110100) + '\146' + chr(0b101101) + chr(0b100100 + 0o24)))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb6'), chr(0b0 + 0o144) + chr(0b1100101) + '\143' + chr(0b1101111) + chr(0b1100100) + chr(0b1100010 + 0o3))(chr(13602 - 13485) + chr(0b1110100) + chr(4117 - 4015) + chr(45) + chr(0b111000)))
else:
for CWnx52wJLqEN in xafqLlk3kkUe(rVlqe6Feserk[mTy3fac_AqJ5], xafqLlk3kkUe(SXOLrMavuUCe(b'\x8a\xd6\x01x\x18'), chr(0b11001 + 0o113) + chr(101) + '\x63' + chr(0b1101111) + '\x64' + chr(0b1011011 + 0o12))(chr(117) + chr(12907 - 12791) + chr(102) + chr(0b100111 + 0o6) + '\070'))():
xafqLlk3kkUe(Sz7tXxaCGqJ1, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\xd6\x1dt\x02\x03'), chr(0b101010 + 0o72) + '\x65' + chr(0b1100011) + chr(0b1000011 + 0o54) + chr(0b110110 + 0o56) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(0b111011 + 0o53) + '\x2d' + chr(56)))(CWnx52wJLqEN)
xafqLlk3kkUe(MRGa81KE7QCh, xafqLlk3kkUe(SXOLrMavuUCe(b'\x98\xd6\x1dt\x02\x03'), chr(0b1100100) + chr(101) + chr(5612 - 5513) + chr(111) + chr(100) + '\x65')('\165' + '\164' + chr(458 - 356) + '\x2d' + chr(56)))(mTy3fac_AqJ5)
return (Sz7tXxaCGqJ1, MRGa81KE7QCh)
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py
|
clean_and_split_sql
|
def clean_and_split_sql(sql: str) -> List[str]:
"""
Cleans up and unifies a SQL query. This involves unifying quoted strings
and splitting brackets which aren't formatted consistently in the data.
"""
sql_tokens: List[str] = []
for token in sql.strip().split():
token = token.replace('"', "'").replace("%", "")
if token.endswith("(") and len(token) > 1:
sql_tokens.extend(split_table_and_column_names(token[:-1]))
sql_tokens.extend(split_table_and_column_names(token[-1]))
else:
sql_tokens.extend(split_table_and_column_names(token))
return sql_tokens
|
python
|
def clean_and_split_sql(sql: str) -> List[str]:
"""
Cleans up and unifies a SQL query. This involves unifying quoted strings
and splitting brackets which aren't formatted consistently in the data.
"""
sql_tokens: List[str] = []
for token in sql.strip().split():
token = token.replace('"', "'").replace("%", "")
if token.endswith("(") and len(token) > 1:
sql_tokens.extend(split_table_and_column_names(token[:-1]))
sql_tokens.extend(split_table_and_column_names(token[-1]))
else:
sql_tokens.extend(split_table_and_column_names(token))
return sql_tokens
|
[
"def",
"clean_and_split_sql",
"(",
"sql",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"sql_tokens",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"for",
"token",
"in",
"sql",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
":",
"token",
"=",
"token",
".",
"replace",
"(",
"'\"'",
",",
"\"'\"",
")",
".",
"replace",
"(",
"\"%\"",
",",
"\"\"",
")",
"if",
"token",
".",
"endswith",
"(",
"\"(\"",
")",
"and",
"len",
"(",
"token",
")",
">",
"1",
":",
"sql_tokens",
".",
"extend",
"(",
"split_table_and_column_names",
"(",
"token",
"[",
":",
"-",
"1",
"]",
")",
")",
"sql_tokens",
".",
"extend",
"(",
"split_table_and_column_names",
"(",
"token",
"[",
"-",
"1",
"]",
")",
")",
"else",
":",
"sql_tokens",
".",
"extend",
"(",
"split_table_and_column_names",
"(",
"token",
")",
")",
"return",
"sql_tokens"
] |
Cleans up and unifies a SQL query. This involves unifying quoted strings
and splitting brackets which aren't formatted consistently in the data.
|
[
"Cleans",
"up",
"and",
"unifies",
"a",
"SQL",
"query",
".",
"This",
"involves",
"unifying",
"quoted",
"strings",
"and",
"splitting",
"brackets",
"which",
"aren",
"t",
"formatted",
"consistently",
"in",
"the",
"data",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py#L89-L102
|
train
|
Cleans up and unifies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N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(2402 - 2352) + chr(0b110001) + chr(0b110111), 0o10), ehT0Px3KOsy9(chr(48) + '\157' + '\x32' + '\x30', 0b1000), ehT0Px3KOsy9('\060' + chr(0b10 + 0o155) + chr(0b110010) + chr(52) + chr(773 - 721), 14454 - 14446), ehT0Px3KOsy9('\x30' + '\x6f' + '\062' + chr(0b1100 + 0o53) + chr(0b110011), 0o10), ehT0Px3KOsy9(chr(0b11111 + 0o21) + '\x6f' + chr(0b10011 + 0o44) + '\063', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(0b100001 + 0o20), 0b1000), ehT0Px3KOsy9('\060' + chr(0b10011 + 0o134) + chr(0b110001) + '\x30' + '\060', 0o10), ehT0Px3KOsy9(chr(751 - 703) + chr(4017 - 3906) + chr(51) + '\x36' + chr(0b101100 + 0o12), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + '\062' + chr(0b110111) + chr(0b11100 + 0o31), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111 + 0o0) + chr(0b1100 + 0o45) + chr(0b110110) + chr(0b110110), 0o10), ehT0Px3KOsy9(chr(0b101011 + 0o5) + '\x6f' + chr(0b110010) + chr(2315 - 2261) + chr(0b100001 + 0o24), 25624 - 25616), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(1241 - 1190) + '\063' + chr(142 - 87), 0o10), ehT0Px3KOsy9('\060' + '\x6f' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b11 + 0o154) + chr(0b0 + 0o63) + chr(0b110111), 0b1000), ehT0Px3KOsy9(chr(48) + '\157' + '\065' + chr(0b110001), 47995 - 47987), ehT0Px3KOsy9(chr(48) + '\157' + '\063' + chr(53) + '\065', 43217 - 43209), ehT0Px3KOsy9(chr(0b110000) + chr(6131 - 6020) + chr(0b100001 + 0o22) + chr(54) + chr(0b110010), 59947 - 59939), ehT0Px3KOsy9('\x30' + '\x6f' + chr(49) + '\x34' + chr(0b110 + 0o57), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\063' + '\x33' + chr(53), ord("\x08")), ehT0Px3KOsy9(chr(0b10000 + 0o40) + chr(111) + chr(0b110001) + '\x35', 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1495 - 1444) + '\064' + '\x33', 51862 - 51854), ehT0Px3KOsy9(chr(48) + '\x6f' + '\063' + chr(476 - 422) + '\x32', 8), ehT0Px3KOsy9(chr(48) + chr(7332 - 7221) + '\x31' + chr(0b10010 + 0o40) + chr(0b11100 + 0o33), 6022 - 6014), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b1101111) + '\x34' + chr(0b111 + 0o60), 1716 - 1708), ehT0Px3KOsy9(chr(48) + '\157' + chr(0b110010) + chr(833 - 783) + chr(0b110010), 0o10), ehT0Px3KOsy9(chr(0b1101 + 0o43) + chr(0b101001 + 0o106) + chr(50) + chr(2079 - 2027) + '\064', 8), ehT0Px3KOsy9('\060' + chr(111) + '\062' + chr(2733 - 2680) + chr(1132 - 1081), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(10907 - 10796) + '\x32' + '\066' + chr(52), 0o10), ehT0Px3KOsy9('\060' + chr(111) + chr(2221 - 2171) + chr(48) + '\060', ord("\x08")), ehT0Px3KOsy9(chr(196 - 148) + chr(7946 - 7835) + chr(49) + chr(1406 - 1356) + chr(52), 0o10), ehT0Px3KOsy9('\x30' + chr(0b11001 + 0o126) + chr(0b110110) + chr(2717 - 2663), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10010 + 0o41) + '\x32' + chr(53), 0b1000), ehT0Px3KOsy9('\x30' + chr(2693 - 2582) + '\x31' + chr(0b110000) + chr(54), 0o10), ehT0Px3KOsy9('\060' + chr(0b1000010 + 0o55) + chr(49) + '\x30' + chr(1059 - 1010), ord("\x08")), ehT0Px3KOsy9(chr(0b110000 + 0o0) + chr(0b110001 + 0o76) + chr(51) + '\x33' + chr(2033 - 1983), 37070 - 37062), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + '\067' + chr(1712 - 1657), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100 + 0o55) + chr(53) + '\066', 0b1000), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + chr(0b100111 + 0o12) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b101111 + 0o1) + chr(8701 - 8590) + chr(0b110010) + '\067' + '\061', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + chr(1528 - 1477) + chr(389 - 339) + '\x31', 0b1000)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(136 - 88) + chr(0b1011011 + 0o24) + chr(53) + chr(48), ord("\x08"))] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xa1'), '\x64' + chr(0b10001 + 0o124) + chr(6876 - 6777) + '\x6f' + '\x64' + chr(0b1100101))('\165' + chr(116) + chr(0b1100110) + chr(0b101100 + 0o1) + chr(0b111000)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def TF5ssDnWfL9m(GWXd4kBaViZK) -> qRxF7OQ0y39T[M8_cKLkHVB2V]:
Q0VUMD_LPfia = []
for mTy3fac_AqJ5 in xafqLlk3kkUe(GWXd4kBaViZK.strip(), xafqLlk3kkUe(SXOLrMavuUCe(b'\xfc`\xc8\xd2O'), chr(430 - 330) + chr(0b1100101) + '\143' + chr(111) + chr(100) + chr(5166 - 5065))(chr(0b1100100 + 0o21) + chr(0b1110100) + chr(0b1100110) + chr(45) + chr(56)))():
mTy3fac_AqJ5 = mTy3fac_AqJ5.replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xad'), chr(0b11111 + 0o105) + chr(2174 - 2073) + chr(0b1100011) + '\x6f' + chr(1034 - 934) + chr(0b1100101))(chr(0b1110101) + '\164' + chr(102) + chr(45) + '\070'), xafqLlk3kkUe(SXOLrMavuUCe(b'\xa8'), chr(100) + chr(0b1010110 + 0o17) + chr(99) + '\x6f' + chr(6435 - 6335) + chr(0b1100101))(chr(0b1110101) + '\x74' + chr(8850 - 8748) + '\055' + '\x38')).replace(xafqLlk3kkUe(SXOLrMavuUCe(b'\xaa'), chr(100) + chr(3284 - 3183) + '\x63' + chr(0b1101 + 0o142) + chr(100) + chr(101))(chr(0b1110101) + '\x74' + chr(0b100111 + 0o77) + '\055' + chr(0b11010 + 0o36)), xafqLlk3kkUe(SXOLrMavuUCe(b''), chr(0b1100100) + '\x65' + '\x63' + chr(111) + chr(7274 - 7174) + chr(101))('\165' + '\x74' + chr(102) + chr(0b101101) + chr(1504 - 1448)))
if xafqLlk3kkUe(mTy3fac_AqJ5, xafqLlk3kkUe(SXOLrMavuUCe(b'\xea~\xc0\xc8Lh4\x9e'), '\144' + chr(6472 - 6371) + chr(0b1010101 + 0o16) + chr(111) + chr(0b1100100) + chr(430 - 329))('\x75' + chr(0b101000 + 0o114) + chr(102) + chr(768 - 723) + '\x38'))(xafqLlk3kkUe(SXOLrMavuUCe(b'\xa7'), '\x64' + chr(0b11010 + 0o113) + '\x63' + chr(0b1101111) + '\x64' + chr(0b1100101))('\x75' + '\x74' + chr(0b1101 + 0o131) + '\x2d' + '\x38')) and c2A0yzQpDQB3(mTy3fac_AqJ5) > ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\061', 8):
xafqLlk3kkUe(Q0VUMD_LPfia, xafqLlk3kkUe(SXOLrMavuUCe(b'\xeah\xd0\xdeUe'), chr(0b1000 + 0o134) + chr(0b1100101) + chr(99) + chr(5085 - 4974) + '\x64' + chr(101))(chr(7672 - 7555) + chr(0b1100010 + 0o22) + chr(0b1100110) + '\x2d' + chr(0b110011 + 0o5)))(RR_KiJruWgnN(mTy3fac_AqJ5[:-ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001), 8)]))
xafqLlk3kkUe(Q0VUMD_LPfia, xafqLlk3kkUe(SXOLrMavuUCe(b'\xeah\xd0\xdeUe'), chr(0b100100 + 0o100) + chr(5048 - 4947) + chr(0b1100000 + 0o3) + chr(111) + chr(100) + chr(0b1100101))('\165' + chr(0b1010000 + 0o44) + '\146' + chr(0b101101) + '\x38'))(RR_KiJruWgnN(mTy3fac_AqJ5[-ehT0Px3KOsy9(chr(0b110000) + chr(6520 - 6409) + '\x31', 8)]))
else:
xafqLlk3kkUe(Q0VUMD_LPfia, xafqLlk3kkUe(SXOLrMavuUCe(b'\xeah\xd0\xdeUe'), chr(0b1100100) + '\145' + chr(8009 - 7910) + chr(111) + chr(100) + chr(0b1100100 + 0o1))('\165' + chr(116) + chr(0b1100110) + chr(1977 - 1932) + chr(1733 - 1677)))(RR_KiJruWgnN(mTy3fac_AqJ5))
return Q0VUMD_LPfia
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py
|
resolve_primary_keys_in_schema
|
def resolve_primary_keys_in_schema(sql_tokens: List[str],
schema: Dict[str, List[TableColumn]]) -> List[str]:
"""
Some examples in the text2sql datasets use ID as a column reference to the
column of a table which has a primary key. This causes problems if you are trying
to constrain a grammar to only produce the column names directly, because you don't
know what ID refers to. So instead of dealing with that, we just replace it.
"""
primary_keys_for_tables = {name: max(columns, key=lambda x: x.is_primary_key).name
for name, columns in schema.items()}
resolved_tokens = []
for i, token in enumerate(sql_tokens):
if i > 2:
table_name = sql_tokens[i - 2]
if token == "ID" and table_name in primary_keys_for_tables.keys():
token = primary_keys_for_tables[table_name]
resolved_tokens.append(token)
return resolved_tokens
|
python
|
def resolve_primary_keys_in_schema(sql_tokens: List[str],
schema: Dict[str, List[TableColumn]]) -> List[str]:
"""
Some examples in the text2sql datasets use ID as a column reference to the
column of a table which has a primary key. This causes problems if you are trying
to constrain a grammar to only produce the column names directly, because you don't
know what ID refers to. So instead of dealing with that, we just replace it.
"""
primary_keys_for_tables = {name: max(columns, key=lambda x: x.is_primary_key).name
for name, columns in schema.items()}
resolved_tokens = []
for i, token in enumerate(sql_tokens):
if i > 2:
table_name = sql_tokens[i - 2]
if token == "ID" and table_name in primary_keys_for_tables.keys():
token = primary_keys_for_tables[table_name]
resolved_tokens.append(token)
return resolved_tokens
|
[
"def",
"resolve_primary_keys_in_schema",
"(",
"sql_tokens",
":",
"List",
"[",
"str",
"]",
",",
"schema",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"TableColumn",
"]",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"primary_keys_for_tables",
"=",
"{",
"name",
":",
"max",
"(",
"columns",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"is_primary_key",
")",
".",
"name",
"for",
"name",
",",
"columns",
"in",
"schema",
".",
"items",
"(",
")",
"}",
"resolved_tokens",
"=",
"[",
"]",
"for",
"i",
",",
"token",
"in",
"enumerate",
"(",
"sql_tokens",
")",
":",
"if",
"i",
">",
"2",
":",
"table_name",
"=",
"sql_tokens",
"[",
"i",
"-",
"2",
"]",
"if",
"token",
"==",
"\"ID\"",
"and",
"table_name",
"in",
"primary_keys_for_tables",
".",
"keys",
"(",
")",
":",
"token",
"=",
"primary_keys_for_tables",
"[",
"table_name",
"]",
"resolved_tokens",
".",
"append",
"(",
"token",
")",
"return",
"resolved_tokens"
] |
Some examples in the text2sql datasets use ID as a column reference to the
column of a table which has a primary key. This causes problems if you are trying
to constrain a grammar to only produce the column names directly, because you don't
know what ID refers to. So instead of dealing with that, we just replace it.
|
[
"Some",
"examples",
"in",
"the",
"text2sql",
"datasets",
"use",
"ID",
"as",
"a",
"column",
"reference",
"to",
"the",
"column",
"of",
"a",
"table",
"which",
"has",
"a",
"primary",
"key",
".",
"This",
"causes",
"problems",
"if",
"you",
"are",
"trying",
"to",
"constrain",
"a",
"grammar",
"to",
"only",
"produce",
"the",
"column",
"names",
"directly",
"because",
"you",
"don",
"t",
"know",
"what",
"ID",
"refers",
"to",
".",
"So",
"instead",
"of",
"dealing",
"with",
"that",
"we",
"just",
"replace",
"it",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py#L104-L121
|
train
|
Resolve primary keys in the SQL tokens.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZ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8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(0b11000 + 0o30) + '\x6f' + chr(51) + chr(387 - 339), 16239 - 16231), ehT0Px3KOsy9('\060' + '\157' + '\061' + chr(1094 - 1045) + chr(0b11001 + 0o30), 0o10), ehT0Px3KOsy9(chr(48) + chr(1274 - 1163) + '\x32' + chr(0b11110 + 0o30) + chr(51), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(9870 - 9759) + '\063' + chr(54) + chr(0b1 + 0o60), 49410 - 49402), ehT0Px3KOsy9('\060' + chr(11019 - 10908) + chr(1149 - 1101), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + '\x31' + chr(0b110000) + '\x33', 33829 - 33821), ehT0Px3KOsy9(chr(956 - 908) + chr(262 - 151) + chr(0b110001) + chr(1740 - 1685) + chr(1464 - 1409), 39909 - 39901), ehT0Px3KOsy9(chr(430 - 382) + chr(0b1011110 + 0o21) + chr(0b110111) + chr(0b110001), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(0b110101 + 0o72) + '\x33' + '\067' + '\066', ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101110 + 0o1) + chr(1300 - 1249) + '\061' + '\067', ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b100011 + 0o114) + chr(50) + chr(51) + chr(376 - 322), 47127 - 47119), ehT0Px3KOsy9(chr(0b110000) + chr(8301 - 8190) + chr(0b110011) + chr(1379 - 1329) + '\066', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(51) + chr(0b110100) + chr(0b110011), 32880 - 32872), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b11111 + 0o23) + chr(0b110100) + chr(1542 - 1494), ord("\x08")), ehT0Px3KOsy9(chr(1476 - 1428) + chr(111) + chr(2271 - 2222) + '\062' + chr(0b110010), 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(1353 - 1304) + '\062' + '\066', 0b1000), ehT0Px3KOsy9(chr(605 - 557) + '\x6f' + '\x33' + chr(51) + chr(2022 - 1969), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + '\x32' + chr(50) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b10101 + 0o132) + chr(0b1010 + 0o52) + '\064', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(0b110110) + '\x35', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b110011) + chr(2698 - 2644) + chr(0b110010 + 0o2), 57684 - 57676), ehT0Px3KOsy9(chr(0b1000 + 0o50) + chr(111) + chr(0b11010 + 0o31) + '\x31' + '\062', 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(555 - 505) + '\x30', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(193 - 144) + chr(49) + '\067', 0o10), ehT0Px3KOsy9(chr(0b100110 + 0o12) + '\x6f' + chr(388 - 337) + chr(668 - 619) + chr(0b110000), 11953 - 11945), ehT0Px3KOsy9(chr(48) + chr(0b10100 + 0o133) + chr(0b110001) + '\062' + chr(1644 - 1595), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(6460 - 6349) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + chr(111) + '\x33' + '\061' + chr(52), 0o10), ehT0Px3KOsy9(chr(0b110000) + chr(0b111111 + 0o60) + chr(51) + '\064' + chr(0b100111 + 0o11), 0o10), ehT0Px3KOsy9('\x30' + chr(9160 - 9049) + '\061' + chr(2350 - 2301) + '\x37', 8), ehT0Px3KOsy9(chr(48) + '\157' + '\x33' + '\x34' + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b100 + 0o54) + chr(0b1101111) + chr(50) + '\067' + chr(53), 58020 - 58012), ehT0Px3KOsy9(chr(0b100000 + 0o20) + chr(427 - 316) + chr(50) + '\065' + chr(0b10 + 0o62), 0b1000), ehT0Px3KOsy9(chr(115 - 67) + '\157' + chr(0b10011 + 0o42), 0b1000), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b1110 + 0o45) + '\x34' + '\x33', 8), ehT0Px3KOsy9(chr(625 - 577) + chr(0b1101111) + chr(50) + '\064' + chr(172 - 120), 65497 - 65489), ehT0Px3KOsy9('\060' + chr(3512 - 3401) + chr(1158 - 1107) + chr(0b110101), 0o10), ehT0Px3KOsy9(chr(0b1 + 0o57) + chr(111) + chr(251 - 200) + chr(547 - 492) + chr(0b110010), 22171 - 22163), ehT0Px3KOsy9(chr(2192 - 2144) + chr(0b1000100 + 0o53) + chr(49) + '\x30' + chr(0b101010 + 0o7), 44382 - 44374), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110001) + '\061' + '\067', 8)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(0b100001 + 0o116) + '\x35' + chr(542 - 494), 0o10)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'6'), chr(0b11100 + 0o110) + chr(0b1010 + 0o133) + '\143' + chr(0b1101111) + chr(2811 - 2711) + chr(0b1100101))(chr(0b111101 + 0o70) + chr(0b11001 + 0o133) + '\146' + chr(45) + chr(0b101001 + 0o17)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def X67bVimzKwxn(Q0VUMD_LPfia, P7DmIFVRivx6) -> qRxF7OQ0y39T[M8_cKLkHVB2V]:
ep3wWd97z1oL = {AIvJRzLdDfgF: tsdjvlgh9gDP(qKlXBtn3PKy4, key=lambda OeWW0F1dBPRQ: OeWW0F1dBPRQ.is_primary_key).AIvJRzLdDfgF for (AIvJRzLdDfgF, qKlXBtn3PKy4) in P7DmIFVRivx6.NzveIZ3IlSH9()}
nhiSkPTWXoqp = []
for (WVxHKyX45z_L, mTy3fac_AqJ5) in YlkZvXL8qwsX(Q0VUMD_LPfia):
if WVxHKyX45z_L > ehT0Px3KOsy9('\060' + chr(111) + '\x32', 0o10):
NKKFbr2Z4sr1 = Q0VUMD_LPfia[WVxHKyX45z_L - ehT0Px3KOsy9(chr(48) + chr(0b111110 + 0o61) + chr(0b1 + 0o61), 8)]
if mTy3fac_AqJ5 == xafqLlk3kkUe(SXOLrMavuUCe(b'Q\r'), '\x64' + chr(0b1100101) + chr(0b110011 + 0o60) + chr(6401 - 6290) + chr(0b101010 + 0o72) + '\145')(chr(11152 - 11035) + chr(116) + '\x66' + '\055' + '\x38') and NKKFbr2Z4sr1 in xafqLlk3kkUe(ep3wWd97z1oL, xafqLlk3kkUe(SXOLrMavuUCe(b's,\xca\x82'), '\x64' + '\x65' + chr(0b1100001 + 0o2) + chr(0b111010 + 0o65) + '\144' + chr(101))('\165' + chr(0b1110100) + chr(7207 - 7105) + chr(0b101101) + '\x38'))():
mTy3fac_AqJ5 = ep3wWd97z1oL[NKKFbr2Z4sr1]
xafqLlk3kkUe(nhiSkPTWXoqp, xafqLlk3kkUe(SXOLrMavuUCe(b"y9\xc3\x94n'"), '\144' + chr(0b100 + 0o141) + '\x63' + chr(0b11011 + 0o124) + chr(0b1100100) + chr(8809 - 8708))(chr(0b111110 + 0o67) + chr(5303 - 5187) + chr(102) + '\x2d' + chr(56)))(mTy3fac_AqJ5)
return nhiSkPTWXoqp
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py
|
read_dataset_schema
|
def read_dataset_schema(schema_path: str) -> Dict[str, List[TableColumn]]:
"""
Reads a schema from the text2sql data, returning a dictionary
mapping table names to their columns and respective types.
This handles columns in an arbitrary order and also allows
either ``{Table, Field}`` or ``{Table, Field} Name`` as headers,
because both appear in the data. It also uppercases table and
column names if they are not already uppercase.
Parameters
----------
schema_path : ``str``, required.
The path to the csv schema.
Returns
-------
A dictionary mapping table names to typed columns.
"""
schema: Dict[str, List[TableColumn]] = defaultdict(list)
for i, line in enumerate(open(schema_path, "r")):
if i == 0:
header = [x.strip() for x in line.split(",")]
elif line[0] == "-":
continue
else:
data = {key: value for key, value in zip(header, [x.strip() for x in line.split(",")])}
table = data.get("Table Name", None) or data.get("Table")
column = data.get("Field Name", None) or data.get("Field")
is_primary_key = data.get("Primary Key") == "y"
schema[table.upper()].append(TableColumn(column.upper(), data["Type"], is_primary_key))
return {**schema}
|
python
|
def read_dataset_schema(schema_path: str) -> Dict[str, List[TableColumn]]:
"""
Reads a schema from the text2sql data, returning a dictionary
mapping table names to their columns and respective types.
This handles columns in an arbitrary order and also allows
either ``{Table, Field}`` or ``{Table, Field} Name`` as headers,
because both appear in the data. It also uppercases table and
column names if they are not already uppercase.
Parameters
----------
schema_path : ``str``, required.
The path to the csv schema.
Returns
-------
A dictionary mapping table names to typed columns.
"""
schema: Dict[str, List[TableColumn]] = defaultdict(list)
for i, line in enumerate(open(schema_path, "r")):
if i == 0:
header = [x.strip() for x in line.split(",")]
elif line[0] == "-":
continue
else:
data = {key: value for key, value in zip(header, [x.strip() for x in line.split(",")])}
table = data.get("Table Name", None) or data.get("Table")
column = data.get("Field Name", None) or data.get("Field")
is_primary_key = data.get("Primary Key") == "y"
schema[table.upper()].append(TableColumn(column.upper(), data["Type"], is_primary_key))
return {**schema}
|
[
"def",
"read_dataset_schema",
"(",
"schema_path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"TableColumn",
"]",
"]",
":",
"schema",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"TableColumn",
"]",
"]",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"open",
"(",
"schema_path",
",",
"\"r\"",
")",
")",
":",
"if",
"i",
"==",
"0",
":",
"header",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"line",
".",
"split",
"(",
"\",\"",
")",
"]",
"elif",
"line",
"[",
"0",
"]",
"==",
"\"-\"",
":",
"continue",
"else",
":",
"data",
"=",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"zip",
"(",
"header",
",",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"line",
".",
"split",
"(",
"\",\"",
")",
"]",
")",
"}",
"table",
"=",
"data",
".",
"get",
"(",
"\"Table Name\"",
",",
"None",
")",
"or",
"data",
".",
"get",
"(",
"\"Table\"",
")",
"column",
"=",
"data",
".",
"get",
"(",
"\"Field Name\"",
",",
"None",
")",
"or",
"data",
".",
"get",
"(",
"\"Field\"",
")",
"is_primary_key",
"=",
"data",
".",
"get",
"(",
"\"Primary Key\"",
")",
"==",
"\"y\"",
"schema",
"[",
"table",
".",
"upper",
"(",
")",
"]",
".",
"append",
"(",
"TableColumn",
"(",
"column",
".",
"upper",
"(",
")",
",",
"data",
"[",
"\"Type\"",
"]",
",",
"is_primary_key",
")",
")",
"return",
"{",
"*",
"*",
"schema",
"}"
] |
Reads a schema from the text2sql data, returning a dictionary
mapping table names to their columns and respective types.
This handles columns in an arbitrary order and also allows
either ``{Table, Field}`` or ``{Table, Field} Name`` as headers,
because both appear in the data. It also uppercases table and
column names if they are not already uppercase.
Parameters
----------
schema_path : ``str``, required.
The path to the csv schema.
Returns
-------
A dictionary mapping table names to typed columns.
|
[
"Reads",
"a",
"schema",
"from",
"the",
"text2sql",
"data",
"returning",
"a",
"dictionary",
"mapping",
"table",
"names",
"to",
"their",
"columns",
"and",
"respective",
"types",
".",
"This",
"handles",
"columns",
"in",
"an",
"arbitrary",
"order",
"and",
"also",
"allows",
"either",
"{",
"Table",
"Field",
"}",
"or",
"{",
"Table",
"Field",
"}",
"Name",
"as",
"headers",
"because",
"both",
"appear",
"in",
"the",
"data",
".",
"It",
"also",
"uppercases",
"table",
"and",
"column",
"names",
"if",
"they",
"are",
"not",
"already",
"uppercase",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py#L152-L184
|
train
|
Reads a schema from the text2sql data file and returns a dictionary mapping table names to column names and respective types.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YGQ_x,yDcnbVVBZ5VZ,OTstrxJfIC1n,GXwwnDRMCHJX,a9IKoVgO_m3w,GNd6AVvhYicE,ixtrydDuthdu,n0ZkatoveZpF,eh4BeXwijHpf,ZMHESMWYyt8h,hr2QaoivbFQ2,Iiw8L0MH5qfg,koCeDPYTrOFe,qqrhSmCSbbqk,pz9FlfzsWoy1,BXIwDASQ0Qkq,NL8dtWOpbcjF,_bikzMuRfbJG,sznFqDbNBHlx,ZsDPvpP4xdo3,cW7yQuyEnJ6E,KOHQGQ8qLDWm,NE1Yam2HHroQ,ygAzbDzrvRMh,SBRjvOU1ufVC,hOkXjmluKZfJ,q1QCh3W88sgk,TLbJ60djyws0,rIcPej9ZqMqV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yTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b110010) + chr(0b110010) + '\x34', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(50) + chr(0b110110) + chr(534 - 486), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\157' + chr(623 - 573) + chr(50) + '\067', ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + chr(0b1101111) + '\x32' + chr(1047 - 998) + chr(939 - 885), 5585 - 5577), ehT0Px3KOsy9(chr(2257 - 2209) + chr(0b1101111) + '\x31' + chr(0b110100), 57063 - 57055), ehT0Px3KOsy9(chr(325 - 277) + chr(4035 - 3924) + chr(0b10010 + 0o41) + chr(2081 - 2029) + chr(1224 - 1171), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b110100) + chr(55), 25080 - 25072), ehT0Px3KOsy9(chr(0b100011 + 0o15) + '\x6f' + chr(51) + chr(1104 - 1049) + chr(52), 0o10), ehT0Px3KOsy9(chr(0b11111 + 0o21) + chr(0b1001111 + 0o40) + chr(1877 - 1827) + chr(49) + chr(0b11011 + 0o32), 0b1000), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b100110 + 0o14) + chr(0b110101 + 0o1) + chr(1867 - 1814), 52721 - 52713), ehT0Px3KOsy9(chr(1771 - 1723) + chr(111) + '\x33' + chr(0b10110 + 0o36), 0o10), ehT0Px3KOsy9('\x30' + '\157' + chr(50) + '\060' + chr(54), 0o10), ehT0Px3KOsy9(chr(0b10010 + 0o36) + chr(111) + '\x36' + '\x36', 0b1000), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(1759 - 1709) + chr(53) + chr(0b101101 + 0o5), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2040 - 1989) + chr(48) + chr(766 - 716), 0b1000), ehT0Px3KOsy9(chr(0b11101 + 0o23) + chr(111) + chr(0b11000 + 0o32) + chr(49) + chr(0b110100), 62343 - 62335), ehT0Px3KOsy9(chr(48) + chr(0b1010010 + 0o35) + chr(0b110001) + chr(0b110101) + chr(0b1101 + 0o43), 0o10), ehT0Px3KOsy9(chr(652 - 604) + chr(0b1101111) + chr(1094 - 1044) + chr(55) + chr(52), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b10101 + 0o34) + chr(50) + chr(50), 64886 - 64878), ehT0Px3KOsy9(chr(48) + chr(5506 - 5395) + chr(0b110100) + '\x34', 0o10), ehT0Px3KOsy9(chr(48) + chr(11460 - 11349) + '\x33' + chr(0b110010), 0b1000), ehT0Px3KOsy9(chr(0b0 + 0o60) + chr(0b1101111) + chr(479 - 430) + '\x33' + '\067', 0o10), ehT0Px3KOsy9('\060' + chr(7604 - 7493) + chr(0b11100 + 0o27) + '\063' + chr(52), 18160 - 18152), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(302 - 252) + chr(51) + chr(0b110011 + 0o1), 0o10), ehT0Px3KOsy9(chr(0b1001 + 0o47) + chr(8024 - 7913) + chr(53) + chr(0b110100 + 0o3), 0b1000), ehT0Px3KOsy9(chr(2261 - 2213) + chr(111) + '\x32' + chr(0b110110), 0o10), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(862 - 811) + chr(1891 - 1836) + '\063', 47083 - 47075), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(50) + '\x30' + chr(0b110001), 24201 - 24193), ehT0Px3KOsy9('\x30' + chr(111) + chr(0b110010) + chr(0b101011 + 0o5) + '\066', 8), ehT0Px3KOsy9('\x30' + '\x6f' + chr(0b101110 + 0o6) + chr(48), ord("\x08")), ehT0Px3KOsy9(chr(0b100101 + 0o13) + chr(0b110110 + 0o71) + chr(0b110011) + chr(0b110110) + chr(2037 - 1985), 56749 - 56741), ehT0Px3KOsy9(chr(0b110000) + chr(111) + chr(0b100000 + 0o23) + chr(51) + chr(0b110110), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(0b10001 + 0o41) + chr(2256 - 2207) + chr(55), 0b1000), ehT0Px3KOsy9(chr(1065 - 1017) + '\157' + chr(49) + '\x31' + chr(0b111 + 0o56), ord("\x08")), ehT0Px3KOsy9('\060' + '\157' + chr(2275 - 2224) + chr(2387 - 2332) + chr(0b11000 + 0o30), 1313 - 1305), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + chr(49) + chr(0b110100) + chr(54), 0o10), ehT0Px3KOsy9(chr(0b1010 + 0o46) + chr(0b1101111) + chr(0b100001 + 0o20) + '\x37' + chr(2183 - 2128), 0b1000), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(51) + chr(0b1001 + 0o54) + chr(0b101001 + 0o7), ord("\x08")), ehT0Px3KOsy9(chr(0b110000) + '\157' + chr(0b110001) + chr(1776 - 1722) + chr(0b110011), 0o10), ehT0Px3KOsy9('\x30' + chr(8254 - 8143) + chr(0b11111 + 0o22) + chr(0b1111 + 0o47), 0o10)][WVxHKyX45z_L % ehT0Px3KOsy9('\x30' + chr(111) + '\065' + '\060', 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xba'), chr(100) + chr(0b101000 + 0o75) + chr(99) + chr(11468 - 11357) + chr(100) + '\145')('\x75' + '\164' + chr(9809 - 9707) + chr(0b101101) + '\070') + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def DnlhC4GPDkwf(wHtXXIF7hMZD) -> zBnV56fc6HrA[M8_cKLkHVB2V, qRxF7OQ0y39T[cZqosP9MxQfw]]:
P7DmIFVRivx6 = rLgqW9imlCdX(YyaZ4tpXu4lf)
for (WVxHKyX45z_L, LycYkDpyelF6) in YlkZvXL8qwsX(_fwkIVCGgtAN(wHtXXIF7hMZD, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe6'), chr(100) + chr(0b1010011 + 0o22) + chr(7019 - 6920) + chr(0b1101111) + chr(100) + chr(0b1100101))(chr(117) + '\164' + chr(102) + chr(0b101101) + '\x38'))):
if WVxHKyX45z_L == ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(7822 - 7711) + chr(0b110000), 0o10):
ZmHK8Erhdn3m = [OeWW0F1dBPRQ.strip() for OeWW0F1dBPRQ in LycYkDpyelF6.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8'), '\x64' + '\x65' + chr(7939 - 7840) + '\157' + chr(0b110100 + 0o60) + '\145')(chr(117) + '\x74' + '\x66' + chr(0b100000 + 0o15) + chr(56)))]
elif LycYkDpyelF6[ehT0Px3KOsy9(chr(1836 - 1788) + '\x6f' + '\060', 8)] == xafqLlk3kkUe(SXOLrMavuUCe(b'\xb9'), chr(934 - 834) + chr(0b1010 + 0o133) + chr(0b101110 + 0o65) + chr(111) + chr(0b1100100) + chr(0b1001011 + 0o32))(chr(0b1000101 + 0o60) + chr(116) + chr(102) + chr(0b101101) + '\x38'):
continue
else:
ULnjp6D6efFH = {K3J4ZwSlE0sT: QmmgWUB13VCJ for (K3J4ZwSlE0sT, QmmgWUB13VCJ) in pZ0NK2y6HRbn(ZmHK8Erhdn3m, [OeWW0F1dBPRQ.strip() for OeWW0F1dBPRQ in LycYkDpyelF6.split(xafqLlk3kkUe(SXOLrMavuUCe(b'\xb8'), chr(100) + chr(101) + '\143' + chr(582 - 471) + '\x64' + chr(0b1100101))(chr(0b1110101) + chr(2863 - 2747) + '\146' + '\x2d' + chr(1324 - 1268)))])}
YbLi4ide0_3E = ULnjp6D6efFH.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0\xd1\xf5\xe2i\xc5i\x9d\xe0\xd0'), chr(100) + chr(0b1100101) + chr(4151 - 4052) + '\x6f' + chr(100) + chr(0b101101 + 0o70))(chr(0b1110101) + '\x74' + chr(0b1100110) + chr(0b101101) + chr(2042 - 1986)), None) or ULnjp6D6efFH.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0\xd1\xf5\xe2i'), chr(0b1100100) + chr(0b1011001 + 0o14) + chr(99) + chr(111) + '\x64' + chr(4697 - 4596))('\165' + chr(0b1110100) + '\146' + chr(0b11 + 0o52) + chr(56)))
Pl0JgJDv0QqN = ULnjp6D6efFH.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\xd9\xf2\xe2h\xc5i\x9d\xe0\xd0'), chr(100) + chr(0b1100101) + chr(546 - 447) + chr(111) + chr(100) + '\x65')(chr(0b101010 + 0o113) + '\x74' + chr(4093 - 3991) + '\x2d' + chr(0b111000)), None) or ULnjp6D6efFH.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\xd2\xd9\xf2\xe2h'), chr(0b1100100) + chr(101) + chr(99) + chr(111) + chr(0b101100 + 0o70) + chr(0b1100101))(chr(0b111011 + 0o72) + chr(116) + '\x66' + chr(910 - 865) + '\x38'))
TenT792GV0nv = ULnjp6D6efFH.get(xafqLlk3kkUe(SXOLrMavuUCe(b'\xc4\xc2\xfe\xe3m\x97^\xdc\xc6\xd0e'), chr(0b1001010 + 0o32) + '\145' + chr(0b1011101 + 0o6) + chr(111) + chr(0b1000101 + 0o37) + chr(0b1011011 + 0o12))(chr(117) + '\164' + '\x66' + '\055' + chr(0b111000))) == xafqLlk3kkUe(SXOLrMavuUCe(b'\xed'), '\x64' + '\145' + chr(0b101111 + 0o64) + '\157' + chr(4297 - 4197) + chr(101))(chr(9004 - 8887) + '\164' + chr(0b1000101 + 0o41) + chr(0b110 + 0o47) + '\x38')
xafqLlk3kkUe(P7DmIFVRivx6[YbLi4ide0_3E.upper()], xafqLlk3kkUe(SXOLrMavuUCe(b'\xf5\xc0\xe7\xebb\x81'), '\x64' + chr(3465 - 3364) + chr(99) + chr(0b1101111) + chr(0b1100100) + '\x65')('\165' + '\164' + chr(688 - 586) + chr(0b10000 + 0o35) + chr(56)))(cZqosP9MxQfw(xafqLlk3kkUe(Pl0JgJDv0QqN, xafqLlk3kkUe(SXOLrMavuUCe(b'\xe1\xc0\xe7\xeb~'), chr(710 - 610) + '\x65' + chr(6234 - 6135) + chr(3315 - 3204) + '\144' + chr(0b1100101))(chr(11386 - 11269) + chr(0b1110100) + chr(102) + chr(0b101101) + '\x38'))(), ULnjp6D6efFH[xafqLlk3kkUe(SXOLrMavuUCe(b'\xc0\xc9\xe7\xeb'), chr(4846 - 4746) + chr(101) + chr(0b1001001 + 0o32) + chr(9527 - 9416) + '\144' + chr(101))('\x75' + chr(0b1110100) + chr(0b1011101 + 0o11) + chr(0b101101) + chr(56))], TenT792GV0nv))
return {**P7DmIFVRivx6}
|
allenai/allennlp
|
allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py
|
process_sql_data
|
def process_sql_data(data: List[JsonDict],
use_all_sql: bool = False,
use_all_queries: bool = False,
remove_unneeded_aliases: bool = False,
schema: Dict[str, List[TableColumn]] = None) -> Iterable[SqlData]:
"""
A utility function for reading in text2sql data. The blob is
the result of loading the json from a file produced by the script
``scripts/reformat_text2sql_data.py``.
Parameters
----------
data : ``JsonDict``
use_all_sql : ``bool``, optional (default = False)
Whether to use all of the sql queries which have identical semantics,
or whether to just use the first one.
use_all_queries : ``bool``, (default = False)
Whether or not to enforce query sentence uniqueness. If false,
duplicated queries will occur in the dataset as separate instances,
as for a given SQL query, not only are there multiple queries with
the same template, but there are also duplicate queries.
remove_unneeded_aliases : ``bool``, (default = False)
The text2sql data by default creates alias names for `all` tables,
regardless of whether the table is derived or if it is identical to
the original (e.g SELECT TABLEalias0.COLUMN FROM TABLE AS TABLEalias0).
This is not necessary and makes the action sequence and grammar manipulation
much harder in a grammar based decoder. Note that this does not
remove aliases which are legitimately required, such as when a new
table is formed by performing operations on the original table.
schema : ``Dict[str, List[TableColumn]]``, optional, (default = None)
A schema to resolve primary keys against. Converts 'ID' column names
to their actual name with respect to the Primary Key for the table
in the schema.
"""
for example in data:
seen_sentences: Set[str] = set()
for sent_info in example['sentences']:
# Loop over the different sql statements with "equivalent" semantics
for sql in example["sql"]:
text_with_variables = sent_info['text'].strip().split()
text_vars = sent_info['variables']
query_tokens, tags = replace_variables(text_with_variables, text_vars)
if not use_all_queries:
key = " ".join(query_tokens)
if key in seen_sentences:
continue
else:
seen_sentences.add(key)
sql_tokens = clean_and_split_sql(sql)
if remove_unneeded_aliases:
sql_tokens = clean_unneeded_aliases(sql_tokens)
if schema is not None:
sql_tokens = resolve_primary_keys_in_schema(sql_tokens, schema)
sql_variables = {}
for variable in example['variables']:
sql_variables[variable['name']] = {'text': variable['example'], 'type': variable['type']}
sql_data = SqlData(text=query_tokens,
text_with_variables=text_with_variables,
variable_tags=tags,
sql=sql_tokens,
text_variables=text_vars,
sql_variables=sql_variables)
yield sql_data
# Some questions might have multiple equivalent SQL statements.
# By default, we just use the first one. TODO(Mark): Use the shortest?
if not use_all_sql:
break
|
python
|
def process_sql_data(data: List[JsonDict],
use_all_sql: bool = False,
use_all_queries: bool = False,
remove_unneeded_aliases: bool = False,
schema: Dict[str, List[TableColumn]] = None) -> Iterable[SqlData]:
"""
A utility function for reading in text2sql data. The blob is
the result of loading the json from a file produced by the script
``scripts/reformat_text2sql_data.py``.
Parameters
----------
data : ``JsonDict``
use_all_sql : ``bool``, optional (default = False)
Whether to use all of the sql queries which have identical semantics,
or whether to just use the first one.
use_all_queries : ``bool``, (default = False)
Whether or not to enforce query sentence uniqueness. If false,
duplicated queries will occur in the dataset as separate instances,
as for a given SQL query, not only are there multiple queries with
the same template, but there are also duplicate queries.
remove_unneeded_aliases : ``bool``, (default = False)
The text2sql data by default creates alias names for `all` tables,
regardless of whether the table is derived or if it is identical to
the original (e.g SELECT TABLEalias0.COLUMN FROM TABLE AS TABLEalias0).
This is not necessary and makes the action sequence and grammar manipulation
much harder in a grammar based decoder. Note that this does not
remove aliases which are legitimately required, such as when a new
table is formed by performing operations on the original table.
schema : ``Dict[str, List[TableColumn]]``, optional, (default = None)
A schema to resolve primary keys against. Converts 'ID' column names
to their actual name with respect to the Primary Key for the table
in the schema.
"""
for example in data:
seen_sentences: Set[str] = set()
for sent_info in example['sentences']:
# Loop over the different sql statements with "equivalent" semantics
for sql in example["sql"]:
text_with_variables = sent_info['text'].strip().split()
text_vars = sent_info['variables']
query_tokens, tags = replace_variables(text_with_variables, text_vars)
if not use_all_queries:
key = " ".join(query_tokens)
if key in seen_sentences:
continue
else:
seen_sentences.add(key)
sql_tokens = clean_and_split_sql(sql)
if remove_unneeded_aliases:
sql_tokens = clean_unneeded_aliases(sql_tokens)
if schema is not None:
sql_tokens = resolve_primary_keys_in_schema(sql_tokens, schema)
sql_variables = {}
for variable in example['variables']:
sql_variables[variable['name']] = {'text': variable['example'], 'type': variable['type']}
sql_data = SqlData(text=query_tokens,
text_with_variables=text_with_variables,
variable_tags=tags,
sql=sql_tokens,
text_variables=text_vars,
sql_variables=sql_variables)
yield sql_data
# Some questions might have multiple equivalent SQL statements.
# By default, we just use the first one. TODO(Mark): Use the shortest?
if not use_all_sql:
break
|
[
"def",
"process_sql_data",
"(",
"data",
":",
"List",
"[",
"JsonDict",
"]",
",",
"use_all_sql",
":",
"bool",
"=",
"False",
",",
"use_all_queries",
":",
"bool",
"=",
"False",
",",
"remove_unneeded_aliases",
":",
"bool",
"=",
"False",
",",
"schema",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"TableColumn",
"]",
"]",
"=",
"None",
")",
"->",
"Iterable",
"[",
"SqlData",
"]",
":",
"for",
"example",
"in",
"data",
":",
"seen_sentences",
":",
"Set",
"[",
"str",
"]",
"=",
"set",
"(",
")",
"for",
"sent_info",
"in",
"example",
"[",
"'sentences'",
"]",
":",
"# Loop over the different sql statements with \"equivalent\" semantics",
"for",
"sql",
"in",
"example",
"[",
"\"sql\"",
"]",
":",
"text_with_variables",
"=",
"sent_info",
"[",
"'text'",
"]",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"text_vars",
"=",
"sent_info",
"[",
"'variables'",
"]",
"query_tokens",
",",
"tags",
"=",
"replace_variables",
"(",
"text_with_variables",
",",
"text_vars",
")",
"if",
"not",
"use_all_queries",
":",
"key",
"=",
"\" \"",
".",
"join",
"(",
"query_tokens",
")",
"if",
"key",
"in",
"seen_sentences",
":",
"continue",
"else",
":",
"seen_sentences",
".",
"add",
"(",
"key",
")",
"sql_tokens",
"=",
"clean_and_split_sql",
"(",
"sql",
")",
"if",
"remove_unneeded_aliases",
":",
"sql_tokens",
"=",
"clean_unneeded_aliases",
"(",
"sql_tokens",
")",
"if",
"schema",
"is",
"not",
"None",
":",
"sql_tokens",
"=",
"resolve_primary_keys_in_schema",
"(",
"sql_tokens",
",",
"schema",
")",
"sql_variables",
"=",
"{",
"}",
"for",
"variable",
"in",
"example",
"[",
"'variables'",
"]",
":",
"sql_variables",
"[",
"variable",
"[",
"'name'",
"]",
"]",
"=",
"{",
"'text'",
":",
"variable",
"[",
"'example'",
"]",
",",
"'type'",
":",
"variable",
"[",
"'type'",
"]",
"}",
"sql_data",
"=",
"SqlData",
"(",
"text",
"=",
"query_tokens",
",",
"text_with_variables",
"=",
"text_with_variables",
",",
"variable_tags",
"=",
"tags",
",",
"sql",
"=",
"sql_tokens",
",",
"text_variables",
"=",
"text_vars",
",",
"sql_variables",
"=",
"sql_variables",
")",
"yield",
"sql_data",
"# Some questions might have multiple equivalent SQL statements.",
"# By default, we just use the first one. TODO(Mark): Use the shortest?",
"if",
"not",
"use_all_sql",
":",
"break"
] |
A utility function for reading in text2sql data. The blob is
the result of loading the json from a file produced by the script
``scripts/reformat_text2sql_data.py``.
Parameters
----------
data : ``JsonDict``
use_all_sql : ``bool``, optional (default = False)
Whether to use all of the sql queries which have identical semantics,
or whether to just use the first one.
use_all_queries : ``bool``, (default = False)
Whether or not to enforce query sentence uniqueness. If false,
duplicated queries will occur in the dataset as separate instances,
as for a given SQL query, not only are there multiple queries with
the same template, but there are also duplicate queries.
remove_unneeded_aliases : ``bool``, (default = False)
The text2sql data by default creates alias names for `all` tables,
regardless of whether the table is derived or if it is identical to
the original (e.g SELECT TABLEalias0.COLUMN FROM TABLE AS TABLEalias0).
This is not necessary and makes the action sequence and grammar manipulation
much harder in a grammar based decoder. Note that this does not
remove aliases which are legitimately required, such as when a new
table is formed by performing operations on the original table.
schema : ``Dict[str, List[TableColumn]]``, optional, (default = None)
A schema to resolve primary keys against. Converts 'ID' column names
to their actual name with respect to the Primary Key for the table
in the schema.
|
[
"A",
"utility",
"function",
"for",
"reading",
"in",
"text2sql",
"data",
".",
"The",
"blob",
"is",
"the",
"result",
"of",
"loading",
"the",
"json",
"from",
"a",
"file",
"produced",
"by",
"the",
"script",
"scripts",
"/",
"reformat_text2sql_data",
".",
"py",
"."
] |
648a36f77db7e45784c047176074f98534c76636
|
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/dataset_readers/dataset_utils/text2sql_utils.py#L187-L258
|
train
|
This function processes the sql data from text2sql data files and returns a list of SQLData objects.
|
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGLtp_O,sR2sPcm7Zrfn,yROw0HWBk0Qc,j9rjMYnN2BMp,hIlP7994qj8O,_fsda0v2_OKU,o0CgT5HPthxA,DXjfarvgFnbl,RQ6CSRrFArYB,RouZF7bjEXAv,jIl9qoALCRyb,bdLuls3EQFSd,FXUco0R3m83n,V5s4UV3vwoyK,Q6d3QdTENfxw,sbc9gub6LIFp,QWgp4ELTmqy4,_zJ24Vce7wp0,KlPSljPzIJ_u,N5Ee6d9YG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3,I7ZO3Ma9cXBb,YyaZ4tpXu4lf,eHmS9durw_Vs,abA97kOQKaLo,tsdjvlgh9gDP,VTYZGD68sBIs,Dx22bkKPdt5d,nSwwHEeM4cxI,sR_24x3xd4bh,xmV2riMOClNT,_fwkIVCGgtAN,Jp8aZ6mjyZZT,eO8Xfv8UVFey,zLUzGokYBM2Z,FL7SmUoxlR9h,k6bl9sLammpH,vQr8gNKaIaWE,S6hV9M2g7fO0,RFiwrCZH9Ie6,jB_HdqgHmVpI,MVEN8G6CxlvR,t0rOMsrOC7R_,W3g84rNiEdDQ,vUlqIvNSaRMa,gDnh40_OUDCn,M8_cKLkHVB2V,xkxBmo49x2An,KNx0Ujaz9UM0,KNyTy8rYcwji,wmQmyeWBmUpv,p1G5VS3dE_Ss,pZ0NK2y6HRbn,HByLaO1XdVEe,pgRJLRS7Iy8j,OZYzwAeSQh7N,tmzuw0hjv33u,RwRZiUMA3VWp,Gbej4oZqKLA6,TqkAMbUz4aLg,rw68imZ2Ikxp=ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EncodingWarning,EnvironmentError,Exception,False,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,None,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,True,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,WindowsError,ZeroDivisionError,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,aiter,all,anext,any,ascii,bin,bool,breakpoint,bytearray,bytes,callable,chr,classmethod,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,exit,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,isinstance,issubclass,iter,len,license,list,locals,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,vars,zip,__builtins__,__cached__,__doc__,__file__,__loader__,__name__,__package__,__spec__
SXOLrMavuUCe = lambda XbwU38w7NW8n: QOfmzcVJsrp8([OeWW0F1dBPRQ ^ [ehT0Px3KOsy9(chr(1689 - 1641) + chr(0b1101111) + chr(1556 - 1505) + chr(0b110110) + '\x37', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b10101 + 0o37) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + '\157' + '\x33' + chr(2520 - 2467) + '\064', 46189 - 46181), ehT0Px3KOsy9('\x30' + chr(8206 - 8095) + '\062' + chr(53) + chr(273 - 220), 9430 - 9422), ehT0Px3KOsy9('\x30' + chr(2631 - 2520) + chr(0b11010 + 0o31) + chr(800 - 752) + '\060', 0o10), ehT0Px3KOsy9(chr(0b110000) + '\x6f' + '\x31' + chr(0b110010) + '\066', 0o10), ehT0Px3KOsy9(chr(0b10101 + 0o33) + chr(0b1011011 + 0o24) + chr(0b1110 + 0o44) + '\x32' + chr(0b110001), 47216 - 47208), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(0b1000 + 0o57) + chr(50), 0o10), ehT0Px3KOsy9(chr(48) + chr(4137 - 4026) + chr(50) + '\x31' + chr(1925 - 1875), 0o10), ehT0Px3KOsy9(chr(48) + chr(0b1010110 + 0o31) + '\x33' + chr(55) + chr(0b110101), 0b1000), ehT0Px3KOsy9(chr(0b1111 + 0o41) + '\157' + '\x31' + chr(0b110101) + chr(0b110111), 13094 - 13086), ehT0Px3KOsy9(chr(0b11 + 0o55) + '\157' + '\061' + chr(0b110011) + chr(0b101101 + 0o5), ord("\x08")), ehT0Px3KOsy9('\x30' + '\157' + chr(683 - 632) + chr(0b110111) + chr(0b10111 + 0o33), ord("\x08")), ehT0Px3KOsy9('\060' + chr(0b1101111) + chr(0b1011 + 0o50) + chr(0b110011) + '\x33', 37619 - 37611), ehT0Px3KOsy9(chr(48) + chr(11037 - 10926) + chr(49) + chr(0b10111 + 0o37) + chr(423 - 369), 38953 - 38945), ehT0Px3KOsy9(chr(0b101000 + 0o10) + '\157' + chr(720 - 671) + '\067' + chr(0b110000), ord("\x08")), ehT0Px3KOsy9('\x30' + chr(9754 - 9643) + '\x32' + chr(0b110110) + '\062', 0o10), ehT0Px3KOsy9(chr(1887 - 1839) + '\157' + '\062' + chr(836 - 786) + '\067', 3421 - 3413), ehT0Px3KOsy9(chr(0b110000) + chr(798 - 687) + chr(2022 - 1972) + '\063' + chr(1405 - 1352), 47704 - 47696), ehT0Px3KOsy9('\060' + chr(4128 - 4017) + chr(0b110011) + chr(2347 - 2295) + chr(1043 - 995), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(0b1101111) + chr(2037 - 1988) + chr(0b11111 + 0o27) + chr(49), 48033 - 48025), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(111) + '\x33' + chr(2204 - 2150) + chr(0b110111), 8), ehT0Px3KOsy9('\060' + '\157' + chr(0b110001 + 0o2) + '\061', 0o10), ehT0Px3KOsy9(chr(1588 - 1540) + '\x6f' + '\x31' + chr(0b110001 + 0o2) + '\x35', 0o10), ehT0Px3KOsy9('\060' + chr(8460 - 8349) + '\063' + chr(0b110100) + chr(425 - 375), 42788 - 42780), ehT0Px3KOsy9(chr(48) + chr(111) + chr(52) + chr(0b10011 + 0o36), 3946 - 3938), ehT0Px3KOsy9(chr(0b0 + 0o60) + '\x6f' + chr(1781 - 1728) + chr(0b1 + 0o60), ord("\x08")), ehT0Px3KOsy9(chr(48) + chr(111) + chr(0b110010) + '\066' + chr(0b10011 + 0o43), ord("\x08")), ehT0Px3KOsy9(chr(48) + '\x6f' + '\x31' + chr(55) + '\064', ord("\x08")), ehT0Px3KOsy9('\x30' + '\x6f' + '\x32' + chr(51) + chr(0b101 + 0o56), 49218 - 49210), ehT0Px3KOsy9(chr(2013 - 1965) + chr(6955 - 6844) + chr(49) + chr(0b110111) + '\062', ord("\x08")), ehT0Px3KOsy9(chr(0b101010 + 0o6) + chr(4311 - 4200) + '\061' + chr(1823 - 1774) + '\060', 0b1000), ehT0Px3KOsy9(chr(0b1110 + 0o42) + '\x6f' + '\x36' + '\061', 0b1000), ehT0Px3KOsy9('\x30' + '\157' + chr(0b110011) + chr(50) + chr(0b1111 + 0o44), 27245 - 27237), ehT0Px3KOsy9(chr(1984 - 1936) + chr(0b100000 + 0o117) + chr(49) + '\x33' + chr(0b110111), ord("\x08")), ehT0Px3KOsy9('\060' + '\x6f' + chr(0b100110 + 0o14) + chr(48) + '\065', 5094 - 5086), ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(0b110010) + chr(0b110000 + 0o6) + '\x32', 8), ehT0Px3KOsy9(chr(48) + chr(4041 - 3930) + '\062' + chr(0b1011 + 0o53) + chr(2311 - 2261), 8), ehT0Px3KOsy9(chr(48) + chr(0b101000 + 0o107) + chr(0b11000 + 0o31) + chr(0b100100 + 0o15) + chr(0b110011), 0b1000), ehT0Px3KOsy9('\060' + '\x6f' + '\061' + chr(1853 - 1802) + '\062', 8)][WVxHKyX45z_L % ehT0Px3KOsy9(chr(0b110000) + chr(167 - 56) + chr(53) + chr(1770 - 1722), 0b1000)] for (WVxHKyX45z_L, OeWW0F1dBPRQ) in YlkZvXL8qwsX(XbwU38w7NW8n)])
def NPPHb59961Bv(RqocVGOryNPv, _CF03Rifpmdh):
try:
return jFWsnpHpAUWz(RqocVGOryNPv + xafqLlk3kkUe(SXOLrMavuUCe(b'\xd9'), chr(1923 - 1823) + chr(3455 - 3354) + '\143' + chr(111) + '\144' + '\145')(chr(0b1101100 + 0o11) + '\x74' + '\146' + chr(1432 - 1387) + chr(1706 - 1650)) + _CF03Rifpmdh)
except yROw0HWBk0Qc:
return jFWsnpHpAUWz(RqocVGOryNPv)
def yyqcxR3tjHam(ULnjp6D6efFH, N08Co8X558GD=ehT0Px3KOsy9(chr(1245 - 1197) + chr(0b101111 + 0o100) + chr(48), ord("\x08")), DSbGpaiAY6O6=ehT0Px3KOsy9(chr(0b110000) + chr(0b11001 + 0o126) + chr(0b11110 + 0o22), 8), bR0NJoCiB0J_=ehT0Px3KOsy9('\x30' + chr(0b1101111) + chr(1747 - 1699), 8), P7DmIFVRivx6=None) -> U1nE7SA1iyUR[IEOESmoG11iy]:
for kP4qaKv0ZkGv in ULnjp6D6efFH:
cLEWLd_MRyTt = MVEN8G6CxlvR()
for zVJ70WVCfQxJ in kP4qaKv0ZkGv[xafqLlk3kkUe(SXOLrMavuUCe(b'\x84F\x82\xd9\xa58\xf2_\xf9'), '\144' + chr(0b1100101) + chr(0b1100011) + chr(0b1101111) + '\x64' + chr(0b1011010 + 0o13))(chr(117) + chr(116) + chr(0b111110 + 0o50) + chr(0b1000 + 0o45) + '\070')]:
for GWXd4kBaViZK in kP4qaKv0ZkGv[xafqLlk3kkUe(SXOLrMavuUCe(b'\x84R\x80'), '\144' + chr(0b1100101) + chr(0b110010 + 0o61) + chr(111) + '\144' + chr(0b1100101))(chr(0b11 + 0o162) + '\x74' + chr(4305 - 4203) + '\x2d' + chr(0b111000))]:
xc_Gc7aNOsJ6 = zVJ70WVCfQxJ[xafqLlk3kkUe(SXOLrMavuUCe(b'\x83F\x94\xd9'), '\144' + chr(1877 - 1776) + chr(0b1100011) + '\x6f' + '\x64' + chr(101))(chr(3401 - 3284) + chr(0b1110100) + chr(0b1011101 + 0o11) + chr(0b11111 + 0o16) + chr(2639 - 2583))].strip().split()
wHyHgm_NAxCd = zVJ70WVCfQxJ[xafqLlk3kkUe(SXOLrMavuUCe(b'\x81B\x9e\xc4\xa14\xfd_\xf9'), chr(100) + chr(7479 - 7378) + chr(0b1100011) + chr(0b1101111) + '\144' + '\145')(chr(117) + chr(116) + chr(6724 - 6622) + chr(45) + chr(0b111000))]
(PvxvEDspdd_5, MRGa81KE7QCh) = qUzVKdwNeyaO(xc_Gc7aNOsJ6, wHyHgm_NAxCd)
if not DSbGpaiAY6O6:
K3J4ZwSlE0sT = xafqLlk3kkUe(SXOLrMavuUCe(b'\xd7'), chr(0b1100100) + chr(0b1100101) + chr(99) + chr(0b1000100 + 0o53) + '\x64' + chr(0b1000001 + 0o44))(chr(0b1110101) + chr(0b1001000 + 0o54) + chr(7160 - 7058) + chr(45) + chr(56))._oWXztVNnqHF(PvxvEDspdd_5)
if K3J4ZwSlE0sT in cLEWLd_MRyTt:
continue
else:
xafqLlk3kkUe(cLEWLd_MRyTt, xafqLlk3kkUe(SXOLrMavuUCe(b'\x82i\xdc\xdc\xf95\xd6\x0f\xd0\xb2=i'), chr(3937 - 3837) + chr(7898 - 7797) + chr(6868 - 6769) + chr(111) + chr(0b111111 + 0o45) + chr(0b101100 + 0o71))(chr(0b1110101) + '\x74' + '\146' + chr(0b1011 + 0o42) + '\x38'))(K3J4ZwSlE0sT)
Q0VUMD_LPfia = TF5ssDnWfL9m(GWXd4kBaViZK)
if bR0NJoCiB0J_:
Q0VUMD_LPfia = RUWWT8MDmlie(Q0VUMD_LPfia)
if P7DmIFVRivx6 is not None:
Q0VUMD_LPfia = X67bVimzKwxn(Q0VUMD_LPfia, P7DmIFVRivx6)
oH3PY75AjWhU = {}
for PsTvoRLhQ56a in kP4qaKv0ZkGv[xafqLlk3kkUe(SXOLrMavuUCe(b'\x81B\x9e\xc4\xa14\xfd_\xf9'), chr(0b1100100) + '\x65' + chr(0b1011001 + 0o12) + chr(0b101101 + 0o102) + chr(100) + '\x65')(chr(2094 - 1977) + chr(0b1100111 + 0o15) + chr(0b1100110) + '\055' + '\x38')]:
oH3PY75AjWhU[PsTvoRLhQ56a[xafqLlk3kkUe(SXOLrMavuUCe(b'\x99B\x81\xc8'), chr(0b111001 + 0o53) + '\x65' + chr(0b1000001 + 0o42) + '\x6f' + chr(100) + '\x65')(chr(12687 - 12570) + '\x74' + chr(0b1000 + 0o136) + chr(0b101101) + chr(2726 - 2670))]] = {xafqLlk3kkUe(SXOLrMavuUCe(b'\x83F\x94\xd9'), chr(5538 - 5438) + chr(608 - 507) + chr(0b1011100 + 0o7) + '\157' + chr(4325 - 4225) + '\145')('\165' + '\x74' + chr(0b1001 + 0o135) + chr(0b101101) + '\070'): PsTvoRLhQ56a[xafqLlk3kkUe(SXOLrMavuUCe(b'\x92[\x8d\xc0\xb0:\xf4'), '\x64' + chr(0b1010 + 0o133) + chr(0b1100011) + chr(0b1010011 + 0o34) + chr(0b1000111 + 0o35) + chr(0b111010 + 0o53))(chr(0b1011010 + 0o33) + chr(0b1110100) + '\146' + chr(45) + '\070')], xafqLlk3kkUe(SXOLrMavuUCe(b'\x83Z\x9c\xc8'), chr(100) + chr(0b1100101) + '\143' + '\157' + chr(1511 - 1411) + chr(0b1100101))(chr(117) + chr(116) + '\x66' + chr(0b101101) + chr(0b111000)): PsTvoRLhQ56a[xafqLlk3kkUe(SXOLrMavuUCe(b'\x83Z\x9c\xc8'), chr(100) + '\145' + '\x63' + chr(111) + chr(0b110000 + 0o64) + chr(930 - 829))('\165' + '\x74' + chr(102) + chr(45) + chr(0b111000))]}
u8ny9MGomy8L = IEOESmoG11iy(text=PvxvEDspdd_5, text_with_variables=xc_Gc7aNOsJ6, variable_tags=MRGa81KE7QCh, sql=Q0VUMD_LPfia, text_variables=wHyHgm_NAxCd, sql_variables=oH3PY75AjWhU)
yield u8ny9MGomy8L
if not N08Co8X558GD:
break
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.