ghHddlmZmZddlmZmZddlZGddZdS))DictAny) AutoTokenizer"AutoModelForSequenceClassificationNcLeZdZddefdZdeeefdeeeffdZdS) EndpointHandler.pathcxtjtjrdnd|_t j||_tj||_|j |j|j |jj j |_ dS)Ncudacpu) torchdevicer is_availablerfrom_pretrained tokenizerrmodeltoevalconfigid2label)selfr s @/home/ray/efs/team/kelly/query2pack/query_to_pack_toy/handler.py__init__zEndpointHandler.__init__slUZ-D-D-F-F#Q66ERR &6t<<7GMM  dk"""  )2 datareturnc|dd}|sddiS|dddd}fd |D}tj5jdi|}tj|jd }tj|d  }j |p&j t|}|d |f }dddn #1swxYwY|t|d dS)NinputserrorzNo input provided.ptT)return_tensorspadding truncation max_lengthcLi|] \}}||j!S)rr).0kvrs r z,EndpointHandler.__call__..s-BBB41a!QTT$+&&BBBr)dimr)label confidencer)) getritemsrno_gradrsoftmaxlogitsargmaxitemrstrround) rr input_textroutputsprobs top_class_idtop_class_labeltop_class_probs ` r__call__zEndpointHandler.__call__sXXh++  312 2     CBBB6<<>>BBB ]__ ; ; dj**6**GM'.b999E <2666;;==L"m// ==eARARSVWcSdSdAeAeO"1l?388::N  ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;%22   s+B.D%%D),D)N)r )__name__ __module__ __qualname__r:rrrrBr)rrrrsf33S3333 T#s(^ S#X      rr)typingrr transformersrrrrr)rrrHspJJJJJJJJ # # # # # # # # # # r