~L iG ddlZddlZddlZddlmZddlmZmZmZddl m Z ddl m Z  ddedee deee eee ffd Zd ee dee fd ZGd d e Zej(dZdZGddeZdZy)N)dedent)Any NamedTupleOptional) ErrorReport)SourceRangeFactoryobj error_msgreturncd} tj|}tj|\}}|||fS#t$r!}d|d}|r|d|zz }t||d}~wwxYw)z{ Wrapper around inspect.getsourcelines and inspect.getsourcefile. Returns: (sourcelines, file_lino, filename) NzCan't get source for zs. TorchScript requires source access in order to carry out compilation, make sure original .py files are available. )inspect getsourcefilegetsourcelinesOSError)r r filename sourcelines file_linenoemsgs T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/_sources.pyget_source_lines_and_filer sH "((-#*#9#9##> [  X -- "#C5)   4)# #Ccl!"s-6 A AA rchd}d}t|D](\}}|jjds&|}n||S||}|jdd}|d|Dcgc]}||||z}}||dzdDcgc]}||||z} }|j ||| zScc}wcc}w)a  This helper function accepts a list of source lines. It finds the indentation level of the function definition (`def`), then it indents all lines in the function body to a point at or greater than that level. This allows for comments and continued string literals that are at a lower indentation than the rest of the code. Args: sourcelines: function source code, separated into lines by the ' ' character Returns: A list of source lines that have been correctly aligned cD||j|xr t|dSN) startswithlen)textprefixs r remove_prefixz-normalize_source_lines..remove_prefix4s"DOOF+;F =>>Ndefr) enumeratelstriprsplitappend) rr idxilfn_def whitespacesaligned_prefixaligned_suffixs rnormalize_source_linesr0&s? C+&1 88:  'C  { Fe$Q'JtddddjddS)Nrr#)r2make_raw_ranger!r fake_rangerGls T1a ( 7 71 ==r!cZeZdZUejed<eed<eed<eeed<e ed<y) ParsedDefastctxr9rrN) r<r=r>rJModule__annotations__r2strrintrFr!rrIrIps& O  Ksmr!rIc*t|tj\}}}t|}dj |}t |}t j|}t|jdk7s't|jdt jstd|d|t|jdddt|jdddz }t||||d|j}t!|||||S)NrDr#rz&Expected a single top-level function: :r T)rr call_stackr0joinrrJparserbody isinstance FunctionDef RuntimeErrorr&rBr<rI) fnrrrr9 dedent_srcpy_astr:rKs r parse_defr\xs)B K " " $*&Kh)5K WW[ !FJ YYz "F 6;;1Jv{{1~s$O4XJa } M  !dA!6q!9:Sq!!$> +'=tR[[ C VS&(K @@r!r)rJ functoolsrtextwraprtypingrrrtorch._Crtorch._C._jit_tree_viewsrrNtuplelistrOrr0r2cacherBrGrIr\rFr!rres ,, 7 $. .}. 49c8C= ().4,+S ,+d3i,+b !& !    > Ar!