/usr/local/lib/python3.6/site-packages/transformers/utils/__pycache__
NameSizeModeActions
doc.cpython-36.pyc345520644editdlrm
dummy_detectron2_objects.cpython-36.pyc7650644editdlrm
dummy_flax_objects.cpython-36.pyc476390644editdlrm
dummy_pt_objects.cpython-36.pyc2099100644editdlrm
dummy_pytorch_quantization_and_torch_objects.cpython-36.pyc38530644editdlrm
dummy_scatter_objects.cpython-36.pyc20440644editdlrm
dummy_sentencepiece_and_speech_objects.cpython-36.pyc6410644editdlrm
dummy_sentencepiece_and_tokenizers_objects.cpython-36.pyc4580644editdlrm
dummy_sentencepiece_objects.cpython-36.pyc76300644editdlrm
dummy_speech_objects.cpython-36.pyc6130644editdlrm
dummy_tf_objects.cpython-36.pyc985960644editdlrm
dummy_timm_and_vision_objects.cpython-36.pyc16240644editdlrm
dummy_timm_objects.cpython-36.pyc16470644editdlrm
dummy_tokenizers_objects.cpython-36.pyc147460644editdlrm
dummy_vision_objects.cpython-36.pyc65940644editdlrm
fx.cpython-36.pyc179760644editdlrm
fx_transformations.cpython-36.pyc95630644editdlrm
generic.cpython-36.pyc104930644editdlrm
hp_naming.cpython-36.pyc37510644editdlrm
hub.cpython-36.pyc316490644editdlrm
import_utils.cpython-36.pyc227740644editdlrm
logging.cpython-36.pyc95570644editdlrm
model_parallel_utils.cpython-36.pyc19760644editdlrm
notebook.cpython-36.pyc121900644editdlrm
sentencepiece_model_pb2.cpython-36.pyc128230644editdlrm
versions.cpython-36.pyc30620644editdlrm
__init__.cpython-36.pyc46450644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/utils/__pycache__/generic.cpython-36.pyc (10493B)
3 Eg\&@s"dZddlZddlmZmZddlmZddlmZddl m Z ddl m Z m Z mZmZddlZdd lmZmZmZmZGd d d eZd d ZddZddZddZddZddZddZddZ GdddeZ!Gddde Z"Gd d!d!e"Z#Gd"d#d#e"Z$Gd$d%d%Z%d&d'Z&dS)(z Generic utilities N) OrderedDictUserDict) ExitStack)fields)Enum)AnyContextManagerListTuple)is_flax_availableis_tf_availableis_torch_availableis_torch_fx_proxyc@seZdZdZdddZdS)cached_propertyz Descriptor that mimics @property but caches output in member variable. From tensorflow_datasets Built-in in functools from Python 3.8. NcCsX|dkr |S|jdkrtdd|jj}t||d}|dkrT|j|}t||||S)Nzunreadable attributeZ __cached_)fgetAttributeError__name__getattrsetattr)selfobjZobjtypeattrcachedrD/usr/local/lib/python3.6/site-packages/transformers/utils/generic.py__get__'s     zcached_property.__get__)N)r __module__ __qualname____doc__rrrrrrsrcCst|r dStr*ddl}t||jr*dStrHddl}t||jrHdStrxddlj }ddl m }t||j |frxdSt|t j S)zl Tests if `x` is a `torch.Tensor`, `tf.Tensor`, `jaxlib.xla_extension.DeviceArray` or `np.ndarray`. TrN)Tracer)rrtorch isinstanceTensorr tensorflowr jax.numpynumpyZjax.corer ndarraynp)xr!tfjnpr rrr is_tensor5s     r,cCs t|tjS)N)r"r(r')r)rrr _is_numpyPsr-cCsddl}t||jS)Nr)r!r"r#)r)r!rrr _is_torchTsr.cCsddl}t||jS)Nr)r!r"Zdevice)r)r!rrr_is_torch_deviceZsr/cCsddl}t||jS)Nr)r$r"r#)r)r*rrr_is_tensorflow`sr0cCsddlj}t||jS)Nr)r%r&r"r')r)r+rrr_is_jaxfs r1cCst|ttfr dd|jDSt|ttfrqszto_py_obj..cSsg|] }t|qSr)r2)r3orrr sszto_py_obj..N)r"dictritemslisttupler r0r&tolistrr.detachcpur r1r(asarrayr'number)rrrrr2ls r2cCst|ttfr dd|jDSt|ttfr8tj|StrNt |rN|j St rlt |rl|j jj Strt|rtj|S|SdS)zc Convert a TensorFlow tensor, PyTorch tensor, Numpy array or python list to a Numpy array. cSsi|]\}}t||qSr)to_numpy)r3r4r5rrrr6szto_numpy..N)r"r9rr:r;r<r(arrayr r0r&rr.r>r?r r1r@)rrrrrBs  rBcsneZdZdZddZddZddZdd Zd d Zd d Z fddZ fddZ e e dddZZS) ModelOutputa Base class for all model outputs as dataclass. Has a `__getitem__` that allows indexing by integer or slice (like a tuple) or strings (like a dictionary) that will ignore the `None` attributes. Otherwise behaves like a regular python dictionary. You can't unpack a `ModelOutput` directly. Use the [`~utils.ModelOutput.to_tuple`] method to convert it to a tuple before. c st}t|s"tjjdtdd|ddDsNtjjdt|dj}tfdd|ddD}|ot| rdt |t r|j }d}n*yt |}d}Wnt k rd }YnX|rJx|D]j}t |ttf st|d k st |dt rPt|d|d|ddk r|d|d<qWn|dk r||dj<n0x.|D]&}t|j}|dk rj||j<qjWdS) Nz has no fields.css|]}|jdkVqdS)N)default)r3fieldrrr sz,ModelOutput.__post_init__..r z. should not have more than one required field.rc3s|]}t|jdkVqdS)N)rname)r3rF)rrrrGsTF)rlen ValueError __class__rallrrHr,r"r9r:iter TypeErrorr;r<strr) rZ class_fieldsZ first_fieldZother_fields_are_noneiteratorZfirst_field_iteratorelementrFr5r)rr __post_init__s>        zModelOutput.__post_init__cOstd|jjddS)Nz$You cannot use ``__delitem__`` on a z instance.) ExceptionrLr)rargskwargsrrr __delitem__szModelOutput.__delitem__cOstd|jjddS)Nz#You cannot use ``setdefault`` on a z instance.)rTrLr)rrUrVrrr setdefaultszModelOutput.setdefaultcOstd|jjddS)NzYou cannot use ``pop`` on a z instance.)rTrLr)rrUrVrrrpopszModelOutput.popcOstd|jjddS)NzYou cannot use ``update`` on a z instance.)rTrLr)rrUrVrrrupdateszModelOutput.updatecCs4t|tr$dd|jD}||S|j|SdS)NcSsi|]\}}||qSrr)r3r4r5rrrr6sz+ModelOutput.__getitem__..)r"rPr:to_tuple)rr4Z inner_dictrrr __getitem__s zModelOutput.__getitem__cs4||jkr"|dk r"tj||tj||dS)N)keyssuper __setitem__ __setattr__)rrHvalue)rLrrr`szModelOutput.__setattr__cs tj||tj||dS)N)r^r_r`)rkeyra)rLrrr_szModelOutput.__setitem__)returncstfddjDS)za Convert self to a tuple containing all the attributes/keys that are not `None`. c3s|]}|VqdS)Nr)r3r4)rrrrGsz'ModelOutput.to_tuple..)r<r])rr)rrr[szModelOutput.to_tuple)rrrrrSrWrXrYrZr\r`r_r rr[ __classcell__rr)rLrrDs ,  rDc@seZdZdZeddZdS) ExplicitEnumzC Enum with more explicit error message for missing values. cCs(t|d|jdt|jjdS)Nz is not a valid z, please select one of )rKrr;_value2member_map_r])clsrarrr _missing_szExplicitEnum._missing_N)rrrr classmethodrhrrrrresrec@seZdZdZdZdZdZdS)PaddingStrategyz Possible values for the `padding` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. longest max_lengthZ do_not_padN)rrrrZLONGESTZ MAX_LENGTHZ DO_NOT_PADrrrrrjsrjc@s eZdZdZdZdZdZdZdS) TensorTypez Possible values for the `return_tensors` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. ptr*r(ZjaxN)rrrrZPYTORCHZ TENSORFLOWZNUMPYZJAXrrrrrm s rmc@s2eZdZdZeedddZddZddZd S) ContextManagersz Wrapper for `contextlib.ExitStack` which enters a collection of context managers. Adaptation of `ContextManagers` in the `fastcore` library. )context_managerscCs||_t|_dS)N)rprstack)rrprrr__init__szContextManagers.__init__cCs x|jD]}|jj|qWdS)N)rprq enter_context)rZcontext_managerrrr __enter__s zContextManagers.__enter__cOs|jj||dS)N)rq__exit__)rrUrVrrrru#szContextManagers.__exit__N) rrrrr rrrrtrurrrrrosrocCsn|j}|jdrtj|j}n$|jdr6tj|j}n tj|j}d|krZdd|jDSdd|jDSdS)zq Find the labels used by a given model. Args: model_class (`type`): The class of the model. ZTFZFlaxZQuestionAnsweringcSs g|]}d|ks|dkr|qS)labelstart_positions end_positions)rwrxr)r3prrrr86szfind_labels..cSsg|]}d|kr|qS)rvr)r3ryrrrr88sN)r startswithinspect signaturecall__call__Zforward parameters)Z model_classZ model_namer|rrr find_labels's   r)'rr{ collectionsrr contextlibrZ dataclassesrenumrtypingrrr r r&r(Z import_utilsr r rrpropertyrr,r-r.r/r0r1r2rBrDrerjrmrorrrrrs.   `