L i+dZddlmZddlZddlmZddlmZddlZddl m Z m Z ddl m Z mZmZgd Zd Zd Zedd Zedd ZdZeZeZeddZedZeddZedZeddZeedddZy)zWrapper to mimic (parts of) np.random API surface. NumPy has strict guarantees on reproducibility etc; here we don't give any. Q: default dtype is float64 in numpy ) annotationsN)sqrt)Optional) _dtypes_impl_util)array_or_scalar ArrayLike normalizer) seed random_samplesamplerandomrandrandnnormalchoicerandintshuffleuniformc,ddlmcm}|jS)Nr)torch._dynamo.config_dynamoconfiguse_numpy_random_stream)rs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/_numpy/random.pyuse_numpy_randomr&s))  ) ))cBtjfd}|S)Nc ts|i|Sddl}ddlmt |j j }tfd|D}|jDcic].\}}|t|r|jjn|0}}}||i|}t||jrtj|}|Scc}}w)Nrrndarrayc3nK|],}t|r|jjn|.ywN) isinstancetensornumpy).0argr"s r z-deco_stream..inner..:s1LOjg&>   "CGs25) rr'_ndarrayr"getattrr__name__tupleitemsr%r&torch as_tensor) argskwdsr'fkeyvalvaluer"funcs @rinnerzdeco_stream..inner.s!&& &  ) dmm4ASWD !% C:c7+CSZZ%%'LD t$t$E%/ 67Ls&3C) functoolswraps)r8r9s` r deco_streamr<-s%__T6 LrcH| tjj|yyr$)r0r manual_seed)r s rr r Ms    &rc|d}tjj}tj||j }t ||dk(SNdtype return_scalarrdefault_dtypes float_dtyper0emptyuniform_r sizerCvaluess rr r SsJ |  ' ' ) 5 5E [[U + 4 4 6F 6 <>&,,q/ *D B LLrc|d}t|ttfs|f}|d|}}tj|||}t |t |dk(S)NrArrOrD)r%r.listr0rr int)rQrRrLrMs rrrsT | dUDM *w |sT ]]34 0F 63dbj AArc8|jdk(rtj|}|d}n&tj|rd}|D]}||z} n|}|%tj ||j dz }ttj|jj}t|jdz |kDr tdtj|||}tj|r|j|}||}|S)Nrr?zprobabilities do not sum to 1.) replacement)numelr0aranger is_sequence ones_liker\rfinforCepsabssum ValueError multinomialreshape) arLreplacepnum_elelatolindicessampless rrrs wwyA~ LLO  |   4  B bLF  y OOA  +  AGG$(( )D 1557S=D 9::6w?G //$'jG Nrr$)greN)NN)NTN)rrr rtzOptional[ArrayLike])__doc__ __future__rr:mathrtypingrr0rr_normalizationsr r r __all__rr<r r rrrrrrrrrrArrrs# !CC *@ ' '  = =   = = = =  = =      B B  "  "r