/usr/local/lib/python3.6/site-packages/datasets/__pycache__
NameSizeModeActions
arrow_dataset.cpython-36.pyc1898500644editdlrm
arrow_reader.cpython-36.pyc224830644editdlrm
arrow_writer.cpython-36.pyc221100644editdlrm
builder.cpython-36.pyc527790644editdlrm
combine.cpython-36.pyc55080644editdlrm
config.cpython-36.pyc51810644editdlrm
dataset_dict.cpython-36.pyc833190644editdlrm
data_files.cpython-36.pyc301530644editdlrm
fingerprint.cpython-36.pyc189790644editdlrm
info.cpython-36.pyc173590644editdlrm
inspect.cpython-36.pyc185830644editdlrm
iterable_dataset.cpython-36.pyc629320644editdlrm
keyhash.cpython-36.pyc33410644editdlrm
load.cpython-36.pyc629220644editdlrm
metric.cpython-36.pyc232170644editdlrm
naming.cpython-36.pyc25710644editdlrm
search.cpython-36.pyc313390644editdlrm
splits.cpython-36.pyc225220644editdlrm
streaming.cpython-36.pyc41190644editdlrm
table.cpython-36.pyc796120644editdlrm
__init__.cpython-36.pyc22820644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/datasets/__pycache__/search.cpython-36.pyc (31339B)
3 <%Egu@sjddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z ddl ZddlmZerddlmZyddlmZWnek rYnXy ddlZWnek rYnXejjddk Zejjd dk ZejeZGd d d eZGd d d e Z Gddde Z!Gddde Z"Gddde Z#GdddZ$Gddde$Z%Gddde$Z&GdddZ'dS)N)PurePath) TYPE_CHECKINGDictList NamedTupleOptionalUnion)logging)Dataset) Elasticsearch elasticsearchfaissc@s eZdZdS) MissingIndexN)__name__ __module__ __qualname__rr9/usr/local/lib/python3.6/site-packages/datasets/search.pyr!src@seZdZUeeeedS) SearchResultsN)rrrrfloatscoresintindicesrrrrr%s rc@s&eZdZUeeeeeedS)BatchedSearchResultsN)rrrrr total_scoresr total_indicesrrrrr*s  rc@seZdZUeeedS)NearestExamplesResultsN)rrrrrrdictZexamplesrrrrr/s rc@s"eZdZUeeeeedS)BatchedNearestExamplesResultsN)rrrrrrrZtotal_examplesrrrrr4s  rc@sfeZdZdZdeedddZdeedddZe e e fdd d Z e e e e fdd d d ZdS) BaseIndexzBase class for indexing )kreturncCstdS)z To implement. This method has to return the scores and the indices of the retrieved examples given a certain query. N)NotImplementedError)selfqueryr"rrrsearch<szBaseIndex.searchcCsFgg}}x0|D](}|j||\}}|j||j|qWt||S)a Find the nearest examples indices to the query. Args: queries (`Union[List[str], np.ndarray]`): The queries as a list of strings if `column` is a text index or as a numpy array if `column` is a vector index. k (`int`): The number of examples to retrieve per query. Ouput: total_scores (`List[List[float]`): The retrieval scores of the retrieved examples per query. total_indices (`List[List[int]]`): The indices of the retrieved examples per query. )r'appendr)r%queriesr"rrr&rrrrr search_batchCs   zBaseIndex.search_batch)filecCstdS)zSerialize the index on diskN)r$)r%r+rrrsaveUszBaseIndex.save)r+r#cCstdS)zDeserialize the index from diskN)r$)clsr+rrrloadYszBaseIndex.loadN)r!)r!)rrr__doc__rrr'rr*rstrrr, classmethodr.rrrrr 9s r c@seZdZdZdeeeeedeeeedddZde e edfeedd d Z dee d d dZ deedddZdS)ElasticSearchIndexa/ Sparse index using Elasticsearch. It is used to index text and run queries based on BM25 similarity. An Elasticsearch server needs to be accessible, and a python client is declared with ``` es_client = Elasticsearch([{'host': 'localhost', 'port': '9200'}]) ``` for example. Nr )hostport es_client es_index_namees_index_configcCsts td|dk r,|dk s$|dk r,td|p2d}|p:d}ddl}ddlm}|dk r\|n||t|dg|_|dk r~|ndtj j t j j |_|dk r|n,d d d d d diiddddd ddiid|_dS)Nz}You must install ElasticSearch to use ElasticSearchIndex. To do so you can run `pip install elasticsearch==7.7.1 for example`zBPlease specify either `es_client` or `(host, port)`, but not both. localhosti#r)r )r3r4Zhuggingface_datasets_r analyzerZ stop_standardstandardZ _english_)typez stopwords)Znumber_of_shardsZanalysisZ propertiestextZBM25)r;r9Z similarity)settingsZmappings)_has_elasticsearch ImportError ValueErrorZelasticsearch.helpersr r r0r5ospathbasenametempfileNamedTemporaryFilenamer6r7)r%r3r4r5r6r7r r rrr__init__is  "  zElasticSearchIndex.__init__r ) documentscolumnc s|j}|j}|jjj||dt}tjd|tj d}d}fdd}ddl } x4| j j |j||dD]\} } |j d || 7}qnW|tkrt jd t|d tt jd |d ddS)z Add documents to the index. If the documents are inside a certain column, you can specify it using the `column` argument. )indexbodyZdocs)unittotaldisablerc3sVdk r0xHtD]\}}||dVqWn"x tD]\}}||dVq:WdS)N)r<_id) enumerate)iZexample)rIrHrrpassage_generators z;ElasticSearchIndex.add_documents..passage_generatorN)clientrJactionsr z>Some documents failed to be added to ElasticSearch. Failures: /zIndexed dz documents)r6r7r5rcreatelenr tqdmis_progress_bar_enabledr ZhelpersZstreaming_bulkupdateloggerwarninginfo) r%rHrI index_nameZ index_configZnumber_of_docsprogressZ successesrResokactionr)rIrHr add_documentss$    z ElasticSearchIndex.add_documentsr!)r&r#cCsP|jj|jd|dgddi|dd}|dd}tdd |Dd d |DS) amFind the nearest examples indices to the query. Args: query (`str`): The query as a string. k (`int`): The number of examples to retrieve. Ouput: scores (`List[List[float]`): The retrieval scores of the retrieved examples. indices (`List[List[int]]`): The indices of the retrieved examples. Z multi_matchr<Z cross_fields)r&fieldsr;)r&size)rJrKhitscSsg|] }|dqS)Z_scorer).0hitrrr sz-ElasticSearchIndex.search..cSsg|]}t|dqS)rO)r)rhrirrrrjs)r5r'r6r)r%r&r"responsergrrrr's  zElasticSearchIndex.search)r"r#c sddl}dgt|dgt|}}|jj|dZfddt|D}x8|jj|D](}||} |j} | j|| <| j|| <q^WWdQRXt ||dS)Nr) max_workerscs"i|]\}}|jj|qSr)submitr')rhrQr&)executorr"r%rr sz3ElasticSearchIndex.search_batch..)rr) concurrent.futuresrXfuturesThreadPoolExecutorrP as_completedresultrrr) r%r)r"rl concurrentrrZfuture_to_indexfuturerJresultsr)rnr"r%rr*s zElasticSearchIndex.search_batch)NNNNN)N)r!)r!r!)rrrr/rr0rrrGrrrdrr'rr*rrrrr2_s, "$r2c@seZdZdZdeeeeefeeeeeddddZ dee j dfeeeeeee d d d Z eddeeeeefdd d dZde j edddZd e j edddZeeefdddZed!eeefeeeeefddddZdS)" FaissIndexa Dense index using Faiss. It is used to index vectors. Faiss is a library for efficient similarity search and clustering of dense vectors. It contains algorithms that search in sets of vectors of any size, up to ones that possibly do not fit in RAM. You can find more information about Faiss here: - For index types and the string factory: https://github.com/facebookresearch/faiss/wiki/The-index-factory - For GPU settings: https://github.com/facebookresearch/faiss/wiki/Faiss-on-the-GPU Nz faiss.Index)devicestring_factory metric_type custom_indexcCsX|dk r|dk rtd|dk r0|dk r0td||_||_||_||_tsTtddS)a$ Create a Dense index using Faiss. You can specify `device` if you want to run it on GPU (`device` must be the GPU index). You can find more information about Faiss here: - For `string factory`: https://github.com/facebookresearch/faiss/wiki/The-index-factory NzFPlease specify either `string_factory` or `custom_index` but not both.zsCannot pass both 'custom_index' and 'device'. Pass 'custom_index' already transferred to the target device instead.a{You must install Faiss to use FaissIndex. To do so you can run `conda install -c pytorch faiss-cpu` or `conda install -c pytorch faiss-gpu`. A community supported package is also available on pypi: `pip install faiss-cpu` or `pip install faiss-gpu`. Note that pip may not have the latest version of FAISS, and thus, some of the latest features and bug fixes may not be available.)r@ryrzr{ faiss_index _has_faissr?)r%ryrzr{r|rrrrGs zFaissIndex.__init__r )vectorsrI batch_size train_size faiss_verbosec Csddl}|jdkr|dkr&t|dnt|d|}|jdk rn|jdkrZ|j||j}q|j||j|j}n$|jdkr|j|}n|j||j}|j||j|_t j dt |j|dk r8||j_ t |jdr|jjdk r||jj_ t |jdr|jjdk r||jj_ t |jdr8|jjdk r8||jj_ |dk r|dkrX|d|n|d||} t j dt| d|jj| n t j d t j d t|d xdtjtdt||tj d D]@} |dkr|| | |n|| | ||} |jj| qWdS) z Add vectors to the index. If the arrays are inside a certain column, you can specify it using the `column` argument. rNzCreated faiss index of type rJ quantizerclustering_indexz"Training the index with the first z vectorszEIgnored the training step of the faiss index as `train_size` is None.zAdding z vectors to the faiss index)rN)rr}rXrzr{Z index_factoryZ IndexFlat_faiss_index_to_deviceryr\r^r;verbosehasattrrJrrZtrainr rYrangerZadd) r%rrIrrrrrfrJZ train_vecsrQZvecsrrr add_vectorss:  $         & &.zFaissIndex.add_vectors)rJryr#cCs|dkr |Sddl}t|trJ|dkr>|j}|j|||}q|j|}n:t|ttfrl|j|t|d}nt dt |dd|S) z Sends a faiss index to a device. A device can either be a positive integer (GPU id), a negative integer (all GPUs), or a list of positive integers (select GPUs to use), or `None` for CPU. Nrr )ZgpuszThe argument type: z is not expected. zZPlease pass in either nothing, a positive int, a negative int, or a list of positive ints.) r isinstancerZStandardGpuResourcesZindex_cpu_to_gpuZindex_cpu_to_all_gpuslisttupleZindex_cpu_to_gpus_list TypeErrorr;)rJryrZ faiss_resrrrr2s   z!FaissIndex._faiss_index_to_devicer!)r&r#cCs~t|jdkr2t|jdks*|jddkr2td|jdd}|jjsTtj|dd}|jj ||\}}t |d|dj t S)awFind the nearest examples indices to the query. Args: query (`np.array`): The query as a numpy array. k (`int`): The number of examples to retrieve. Ouput: scores (`List[List[float]`): The retrieval scores of the retrieved examples. indices (`List[List[int]]`): The indices of the retrieved examples. r rzHShape of query is incorrect, it has to be either a 1D array or 2D (1, N)C)orderr) rXshaper@Zreshapeflags c_contiguousnpasarrayr}r'rastyper)r%r&r"r)rrrrrr'Ts * zFaissIndex.search)r)r#cCsNt|jdkrtd|jjs,tj|dd}|jj||\}}t ||j t S)aFind the nearest examples indices to the queries. Args: queries (`np.array`): The queries as a numpy array. k (`int`): The number of examples to retrieve. Ouput: total_scores (`List[List[float]`): The retrieval scores of the retrieved examples per query. total_indices (`List[List[int]]`): The indices of the retrieved examples per query. rzShape of query must be 2Dr)r) rXrr@rrrrr}r'rrr)r%r)r"rrrrrr*hs zFaissIndex.search_batch)r+cCsLddl}|jdk r2t|jtttfr2|j|j}n|j}|j|t |dS)z Serialize the FaissIndex on diskrN) rryrrrrZindex_gpu_to_cpur}Z write_indexr0)r%r+rrJrrrr,zs zFaissIndex.save)r+ryr#cCs4ddl}||d}|jt|}|j||j|_|S)z$Deserialize the FaissIndex from diskrN)ry)rZ read_indexr0rryr})r-r+ryrr}rJrrrr.s  zFaissIndex.load)NNNN)NrNN)N)r!)r!)N)rrrr/rrrrr0rGrarrayboolr staticmethodrrr'rr*rr,r1r.rrrrrxs"2.1&! rxc @s&eZdZdZddZddZddZeedd d Z ed d d Z e edddZ ee dddZd7eeeeeee efeeeeedeeeed ddZd8ejeeeee efeeeeedeeeed ddZeeeefdddZd9eeeefeeee efd d!d"Zd:eeeeeeeed#eeeed$d%d&Zd;eeeeeeed#eed'd(d)Zed d*d+Zdeeeejfee!d-d3d4Z"d?eee eejfee#d0d5d6Z$dS)@IndexableMixinz+Add indexing features to `datasets.Dataset`cCs i|_dS)N)_indexes)r%rrrrGszIndexableMixin.__init__cCstdS)N)r$)r%rrr__len__szIndexableMixin.__len__cCstdS)N)r$)r%keyrrr __getitem__szIndexableMixin.__getitem__)r_r#cCs ||jkS)N)r)r%r_rrris_index_initializedsz#IndexableMixin.is_index_initialized)r_cCs|j|std|ddS)NzIndex with index_name 'zk' not initialized yet. Please make sure that you call `add_faiss_index` or `add_elasticsearch_index` first.)rr)r%r_rrr_check_index_is_initializeds z*IndexableMixin._check_index_is_initialized)r#cCs t|jS)zCList the colindex_nameumns/identifiers of all the attached indexes.)rr)r%rrr list_indexesszIndexableMixin.list_indexescCs|j||j|S)zList the index_name/identifiers of all the attached indexes. Args: index_name (:obj:`str`): Index name. Returns: :class:`BaseIndex` )rr)r%r_rrr get_indexs zIndexableMixin.get_indexNFz faiss.Index) rIr_ryrzr{r|rrrc CsB|dk r |n|}t||||d} | j||||| d| |j|<dS)aAdd a dense index using Faiss for fast retrieval. The index is created using the vectors of the specified column. You can specify `device` if you want to run it on GPU (`device` must be the GPU index, see more below). You can find more information about Faiss here: - For `string factory`: https://github.com/facebookresearch/faiss/wiki/The-index-factory Args: column (:obj:`str`): The column of the vectors to add to the index. index_name (Optional :obj:`str`): The index_name/identifier of the index. This is the index_name that is used to call `.get_nearest` or `.search`. By defaul it corresponds to `column`. device (Optional :obj:`Union[int, List[int]]`): If positive integer, this is the index of the GPU to use. If negative integer, use all GPUs. If a list of positive integers is passed in, run only on those GPUs. By default it uses the CPU. string_factory (Optional :obj:`str`): This is passed to the index factory of Faiss to create the index. Default index class is IndexFlatIP. metric_type (Optional :obj:`int`): Type of metric. Ex: `faiss.METRIC_INNER_PRODUCT` or `faiss.METRIC_L2`. custom_index (Optional :obj:`faiss.Index`): Custom Faiss index that you already have instantiated and configured for your needs. batch_size (Optional :obj:`int`): Size of the batch to use while adding vectors to the FaissIndex. Default value is 1000. train_size (Optional :obj:`int`): If the index needs a training step, specifies how many vectors will be used to train the index. faiss_verbose (:obj:`bool`, defaults to False): Enable the verbosity of the Faiss index. N)ryrzr{r|)rIrrr)rxrr) r%rIr_ryrzr{r|rrrr}rrradd_faiss_indexs zIndexableMixin.add_faiss_index) external_arraysr_ryrzr{r|rrrc Cs2t||||d} | j|d||| d| |j|<dS)a<Add a dense index using Faiss for fast retrieval. The index is created using the vectors of `external_arrays`. You can specify `device` if you want to run it on GPU (`device` must be the GPU index). You can find more information about Faiss here: - For `string factory`: https://github.com/facebookresearch/faiss/wiki/The-index-factory Args: external_arrays (:obj:`np.array`): If you want to use arrays from outside the lib for the index, you can set `external_arrays`. It will use `external_arrays` to create the Faiss index instead of the arrays in the given `column`. index_name (:obj:`str`): The index_name/identifier of the index. This is the index_name that is used to call `.get_nearest` or `.search`. device (Optional :obj:`Union[int, List[int]]`): If positive integer, this is the index of the GPU to use. If negative integer, use all GPUs. If a list of positive integers is passed in, run only on those GPUs. By default it uses the CPU. string_factory (Optional :obj:`str`): This is passed to the index factory of Faiss to create the index. Default index class is IndexFlatIP. metric_type (Optional :obj:`int`): Type of metric. Ex: `faiss.METRIC_INNER_PRODUCT` or `faiss.METRIC_L2`. custom_index (Optional :obj:`faiss.Index`): Custom Faiss index that you already have instantiated and configured for your needs. batch_size (Optional :obj:`int`): Size of the batch to use while adding vectors to the FaissIndex. Default value is 1000. train_size (Optional :obj:`int`): If the index needs a training step, specifies how many vectors will be used to train the index. faiss_verbose (:obj:`bool`, defaults to False): Enable the verbosity of the Faiss index. )ryrzr{r|N)rIrrr)rxrr) r%rr_ryrzr{r|rrrr}rrr$add_faiss_index_from_external_arrayss z3IndexableMixin.add_faiss_index_from_external_arrays)r_r+cCsR|j|}t|ts.td|dt|d|j|tjd|d|dS)aSave a FaissIndex on disk. Args: index_name (:obj:`str`): The index_name/identifier of the index. This is the index_name that is used to call `.get_nearest` or `.search`. file (:obj:`str`): The path to the serialized faiss index on disk. zIndex 'z' is not a FaissIndex but a ''zSaved FaissIndex z at N)rrrxr@r;r,r\r^)r%r_r+rJrrrsave_faiss_index s    zIndexableMixin.save_faiss_index)r_r+ryc Csltj||d}|jjt|krHtd|d|d|jjdt|d ||j|<tjd|d|d S) aLoad a FaissIndex from disk. If you want to do additional configurations, you can have access to the faiss index object by doing `.get_index(index_name).faiss_index` to make it fit your needs. Args: index_name (:obj:`str`): The index_name/identifier of the index. This is the index_name that is used to call `.get_nearest` or `.search`. file (:obj:`str`): The path to the serialized faiss index on disk. device (Optional :obj:`Union[int, List[int]]`): If positive integer, this is the index of the GPU to use. If negative integer, use all GPUs. If a list of positive integers is passed in, run only on those GPUs. By default it uses the CPU. )ryz1Index size should match Dataset size, but Index 'z' at z has z elements while the dataset has z examples.zLoaded FaissIndex z from N) rxr.r}ZntotalrXr@rr\r^)r%r_r+ryrJrrrload_faiss_indexs ( zIndexableMixin.load_faiss_indexr )rIr_r3r4r5r6r7c Cs>|dk r |n|}t|||||d}|j||d||j|<dS)a3Add a text index using ElasticSearch for fast retrieval. Args: column (:obj:`str`): The column of the documents to add to the index. index_name (Optional :obj:`str`): The index_name/identifier of the index. This is the index name that is used to call `.get_nearest` or `.search`. By defaul it corresponds to `column`. host (Optional :obj:`str`, defaults to localhost): host of where ElasticSearch is running port (Optional :obj:`str`, defaults to 9200): port of where ElasticSearch is running es_client (Optional :obj:`elasticsearch.Elasticsearch`): The elasticsearch client used to create the index if host and port are None. es_index_name (Optional :obj:`str`): The elasticsearch index name used to create the index. es_index_config (Optional :obj:`dict`): The configuration of the elasticsearch index. Default config is: Config:: { "settings": { "number_of_shards": 1, "analysis": {"analyzer": {"stop_standard": {"type": "standard", " stopwords": "_english_"}}}, }, "mappings": { "properties": { "text": { "type": "text", "analyzer": "standard", "similarity": "BM25" }, } }, } N)r3r4r5r6r7)rI)r2rdr) r%rIr_r3r4r5r6r7Zes_indexrrradd_elasticsearch_index0s -z&IndexableMixin.add_elasticsearch_index)r_r6r3r4r5r7cCst|||||d|j|<dS)aLoad an existing text index using ElasticSearch for fast retrieval. Args: index_name (:obj:`str`): The index_name/identifier of the index. This is the index name that is used to call `.get_nearest` or `.search`. es_index_name (:obj:`str`): The name of elasticsearch index to load. host (Optional :obj:`str`, defaults to localhost): host of where ElasticSearch is running port (Optional :obj:`str`, defaults to 9200): port of where ElasticSearch is running es_client (Optional :obj:`elasticsearch.Elasticsearch`): The elasticsearch client used to create the index if host and port are None. es_index_config (Optional :obj:`dict`): The configuration of the elasticsearch index. Default config is:: { "settings": { "number_of_shards": 1, "analysis": {"analyzer": {"stop_standard": {"type": "standard", " stopwords": "_english_"}}}, }, "mappings": { "properties": { "text": { "type": "text", "analyzer": "standard", "similarity": "BM25" }, } }, } )r3r4r5r6r7N)r2r)r%r_r6r3r4r5r7rrrload_elasticsearch_indexds(z'IndexableMixin.load_elasticsearch_indexcCs |j|=dS)zDrop the index with the specified column. Args: index_name (:obj:`str`): The index_name/identifier of the index. N)r)r%r_rrr drop_indexszIndexableMixin.drop_indexr!)r_r&r"r#cCs|j||j|j||S)aBFind the nearest examples indices in the dataset to the query. Args: index_name (:obj:`str`): The name/identifier of the index. query (:obj:`Union[str, np.ndarray]`): The query as a string if `index_name` is a text index or as a numpy array if `index_name` is a vector index. k (:obj:`int`): The number of examples to retrieve. Returns: scores (:obj:`List[List[float]`): The retrieval scores of the retrieved examples. indices (:obj:`List[List[int]]`): The indices of the retrieved examples. )rrr')r%r_r&r"rrrr's zIndexableMixin.search)r_r)r"r#cCs|j||j|j||S)aFind the nearest examples indices in the dataset to the query. Args: index_name (:obj:`str`): The index_name/identifier of the index. queries (:obj:`Union[List[str], np.ndarray]`): The queries as a list of strings if `index_name` is a text index or as a numpy array if `index_name` is a vector index. k (:obj:`int`): The number of examples to retrieve per query. Returns: total_scores (:obj:`List[List[float]`): The retrieval scores of the retrieved examples per query. total_indices (:obj:`List[List[int]]`): The indices of the retrieved examples per query. )rrr*)r%r_r)r"rrrr*s zIndexableMixin.search_batchcCsD|j||j|||\}}dd|D}t|dt|||S)a"Find the nearest examples in the dataset to the query. Args: index_name (:obj:`str`): The index_name/identifier of the index. query (:obj:`Union[str, np.ndarray]`): The query as a string if `index_name` is a text index or as a numpy array if `index_name` is a vector index. k (:obj:`int`): The number of examples to retrieve. Returns: scores (:obj:`List[float]`): The retrieval scores of the retrieved examples. examples (:obj:`dict`): The retrieved examples. cSsg|]}|dkr|qS)rr)rhrQrrrrjsz7IndexableMixin.get_nearest_examples..N)rr'rrX)r%r_r&r"rrZ top_indicesrrrget_nearest_exampless z#IndexableMixin.get_nearest_examplescsLj|j|||\}}ddt||D}fdd|D}t||S)a`Find the nearest examples in the dataset to the query. Args: index_name (:obj:`str`): The index_name/identifier of the index. queries (:obj:`Union[List[str], np.ndarray]`): The queries as a list of strings if `index_name` is a text index or as a numpy array if `index_name` is a vector index. k (:obj:`int`): The number of examples to retrieve per query. Returns: total_scores (`List[List[float]`): The retrieval scores of the retrieved examples per query. total_examples (`List[dict]`): The retrieved examples per query. cSs*g|]"\}}|dtdd|DqS)NcSsg|]}|dkr|qS)rr)rhrQrrrrjszHIndexableMixin.get_nearest_examples_batch...)rX)rhZscores_iZ indices_irrrrjsz=IndexableMixin.get_nearest_examples_batch..csg|]}dd|DqS)cSsg|]}|dkr|qS)rr)rhrQrrrrjszHIndexableMixin.get_nearest_examples_batch...r)rhr)r%rrrjs)rr*zipr)r%r_r)r"rrZ total_samplesr)r%rget_nearest_examples_batchs  z)IndexableMixin.get_nearest_examples_batch)NNNNNrNF)NNNNrNF)N)NNNNNN)NNNN)r!)r!)r!)r!)%rrrr/rGrrr0rrrrrr rrrrrrrrrrrrrrrrr'rr*rrrrrrrrrsTD"B,40*% $r)(importlib.util importlibrArDpathlibrtypingrrrrrrZnumpyrutilsr Z arrow_datasetr r r r?rutil find_specr>r~ get_loggerrr\ Exceptionrrrrrr r2rxrrrrrs:      &tC