





from typing import Dict, List, Optional, Union

import numpy as np

from transformers.utils import is_vision_available
from transformers.utils.generic import TensorType

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import logging


if is_vision_available():
     import PIL

_snake_case  :    int						    =  logging.get_logger(__name__)

def   a_    ( lowerCAmelCase_      :			List[str]	):
   if isinstance(lowerCAmelCase_,	(list, tuple)	) and isinstance(videos[0],	(list, tuple)	) and is_valid_image(videos[0][0]	):
      return videos

   elif isinstance(lowerCAmelCase_,	(list, tuple)	) and is_valid_image(videos[0]	):
      return [videos]

   elif is_valid_image(lowerCAmelCase_	):
      return [[videos]]

   raise ValueError(F"""Could not make batched video from {videos}"""	)




class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  a_        = ["""pixel_values"""]






  def __init__(				self :		int					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		PILImageResampling = PILImageResampling.BILINEAR					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		Union[int, float] = 1 / 2_5_5					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  **lowerCAmelCase_ :		int					,  )							->						None:
     super().__init__(**lowerCAmelCase_     )
     __lowerCAmelCase								=	size if size is not None else {'shortest_edge': 2_5_6}
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_					,  default_to_square=lowerCAmelCase_     )
     __lowerCAmelCase								=	crop_size if crop_size is not None else {'height': 2_2_4, 'width': 2_2_4}
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_					,  param_name='crop_size'     )

     __lowerCAmelCase								=	do_resize
     __lowerCAmelCase								=	size
     __lowerCAmelCase								=	do_center_crop
     __lowerCAmelCase								=	crop_size
     __lowerCAmelCase								=	resample
     __lowerCAmelCase								=	do_rescale
     __lowerCAmelCase								=	rescale_factor
     __lowerCAmelCase								=	offset
     __lowerCAmelCase								=	do_normalize
     __lowerCAmelCase								=	image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
     __lowerCAmelCase								=	image_std if image_std is not None else IMAGENET_STANDARD_STD






  def 				lowercase		(				self :		str					,  lowerCAmelCase_ :		np.ndarray					,  lowerCAmelCase_ :		Dict[str, int]					,  lowerCAmelCase_ :		PILImageResampling = PILImageResampling.BILINEAR					,  lowerCAmelCase_ :		Optional[Union[str, ChannelDimension]] = None					,  **lowerCAmelCase_ :		List[str]					,  )							->						np.ndarray:
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_					,  default_to_square=lowerCAmelCase_     )
     if "shortest_edge" in size:
        __lowerCAmelCase								=	get_resize_output_image_size(lowerCAmelCase_					,  size['shortest_edge']					,  default_to_square=lowerCAmelCase_     )
     elif "height" in size and "width" in size:
        __lowerCAmelCase								=	(size['height'], size['width'])
     else:
        raise ValueError(f"""Size must have 'height' and 'width' or 'shortest_edge' as keys. Got {size.keys()}"""     )
     return resize(lowerCAmelCase_					,  size=lowerCAmelCase_					,  resample=lowerCAmelCase_					,  data_format=lowerCAmelCase_					,  **lowerCAmelCase_     )






  def 				lowercase		(				self :		Union[str, Any]					,  lowerCAmelCase_ :		np.ndarray					,  lowerCAmelCase_ :		Dict[str, int]					,  lowerCAmelCase_ :		Optional[Union[str, ChannelDimension]] = None					,  **lowerCAmelCase_ :		Dict					,  )							->						np.ndarray:
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_     )
     if "height" not in size or "width" not in size:
        raise ValueError(f"""Size must have 'height' and 'width' as keys. Got {size.keys()}"""     )
     return center_crop(lowerCAmelCase_					,  size=(size['height'], size['width'])					,  data_format=lowerCAmelCase_					,  **lowerCAmelCase_     )






  def 				lowercase		(				self :		Optional[Any]					,  lowerCAmelCase_ :		np.ndarray					,  lowerCAmelCase_ :		Union[int, float]					,  lowerCAmelCase_ :		bool = True					,  lowerCAmelCase_ :		Optional[Union[str, ChannelDimension]] = None					,  **lowerCAmelCase_ :		Tuple					,  )							->						Dict:
     __lowerCAmelCase								=	image.astype(np.floataa     )
     if offset:
        __lowerCAmelCase								=	image - (scale / 2)
     return rescale(lowerCAmelCase_					,  scale=lowerCAmelCase_					,  data_format=lowerCAmelCase_					,  **lowerCAmelCase_     )






  def 				lowercase		(				self :		Any					,  lowerCAmelCase_ :		np.ndarray					,  lowerCAmelCase_ :		Union[float, List[float]]					,  lowerCAmelCase_ :		Union[float, List[float]]					,  lowerCAmelCase_ :		Optional[Union[str, ChannelDimension]] = None					,  **lowerCAmelCase_ :		List[Any]					,  )							->						np.ndarray:
     return normalize(lowerCAmelCase_					,  mean=lowerCAmelCase_					,  std=lowerCAmelCase_					,  data_format=lowerCAmelCase_					,  **lowerCAmelCase_     )






  def 				lowercase		(				self :		int					,  lowerCAmelCase_ :		ImageInput					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		PILImageResampling = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		float = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  lowerCAmelCase_ :		Optional[ChannelDimension] = ChannelDimension.FIRST					,  )							->						np.ndarray:
     if do_resize and size is None or resample is None:
        raise ValueError('Size and resample must be specified if do_resize is True.'     )

     if do_center_crop and crop_size is None:
        raise ValueError('Crop size must be specified if do_center_crop is True.'     )

     if do_rescale and rescale_factor is None:
        raise ValueError('Rescale factor must be specified if do_rescale is True.'     )

     if do_normalize and (image_mean is None or image_std is None):
        raise ValueError('Image mean and std must be specified if do_normalize is True.'     )

     if offset and not do_rescale:
        raise ValueError('For offset, do_rescale must also be set to True.'     )

     # All transformations expect numpy arrays.
     __lowerCAmelCase								=	to_numpy_array(lowerCAmelCase_     )

     if do_resize:
        __lowerCAmelCase								=	self.resize(image=lowerCAmelCase_					,  size=lowerCAmelCase_					,  resample=lowerCAmelCase_     )

     if do_center_crop:
        __lowerCAmelCase								=	self.center_crop(lowerCAmelCase_					,  size=lowerCAmelCase_     )

     if do_rescale:
        __lowerCAmelCase								=	self.rescale(image=lowerCAmelCase_					,  scale=lowerCAmelCase_					,  offset=lowerCAmelCase_     )

     if do_normalize:
        __lowerCAmelCase								=	self.normalize(image=lowerCAmelCase_					,  mean=lowerCAmelCase_					,  std=lowerCAmelCase_     )

     __lowerCAmelCase								=	to_channel_dimension_format(lowerCAmelCase_					,  lowerCAmelCase_     )
     return image






  def 				lowercase		(				self :		Optional[int]					,  lowerCAmelCase_ :		ImageInput					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		PILImageResampling = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Dict[str, int] = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		float = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		bool = None					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  lowerCAmelCase_ :		Optional[Union[float, List[float]]] = None					,  lowerCAmelCase_ :		Optional[Union[str, TensorType]] = None					,  lowerCAmelCase_ :		ChannelDimension = ChannelDimension.FIRST					,  **lowerCAmelCase_ :		Any					,  )							->						PIL.Image.Image:
     __lowerCAmelCase								=	do_resize if do_resize is not None else self.do_resize
     __lowerCAmelCase								=	resample if resample is not None else self.resample
     __lowerCAmelCase								=	do_center_crop if do_center_crop is not None else self.do_center_crop
     __lowerCAmelCase								=	do_rescale if do_rescale is not None else self.do_rescale
     __lowerCAmelCase								=	rescale_factor if rescale_factor is not None else self.rescale_factor
     __lowerCAmelCase								=	offset if offset is not None else self.offset
     __lowerCAmelCase								=	do_normalize if do_normalize is not None else self.do_normalize
     __lowerCAmelCase								=	image_mean if image_mean is not None else self.image_mean
     __lowerCAmelCase								=	image_std if image_std is not None else self.image_std

     __lowerCAmelCase								=	size if size is not None else self.size
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_					,  default_to_square=lowerCAmelCase_     )
     __lowerCAmelCase								=	crop_size if crop_size is not None else self.crop_size
     __lowerCAmelCase								=	get_size_dict(lowerCAmelCase_					,  param_name='crop_size'     )

     if not valid_images(lowerCAmelCase_     ):
        raise ValueError(
            'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
            'torch.Tensor, tf.Tensor or jax.ndarray.'     )

     __lowerCAmelCase								=	make_batched(lowerCAmelCase_     )

     __lowerCAmelCase								=	[
         [
             self._preprocess_image(
                 image=lowerCAmelCase_					,  do_resize=lowerCAmelCase_					,  size=lowerCAmelCase_					,  resample=lowerCAmelCase_					,  do_center_crop=lowerCAmelCase_					,  crop_size=lowerCAmelCase_					,  do_rescale=lowerCAmelCase_					,  rescale_factor=lowerCAmelCase_					,  offset=lowerCAmelCase_					,  do_normalize=lowerCAmelCase_					,  image_mean=lowerCAmelCase_					,  image_std=lowerCAmelCase_					,  data_format=lowerCAmelCase_					,  )
             for img in video
         ]
         for video in videos
     ]

     __lowerCAmelCase								=	{'pixel_values': videos}
     return BatchFeature(data=lowerCAmelCase_					,  tensor_type=lowerCAmelCase_     )








import os
import tempfile
from functools import partial
from unittest import TestCase
from unittest.mock import patch

import numpy as np
import pytest

from datasets.arrow_dataset import Dataset
from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex

from .utils import require_elasticsearch, require_faiss


_snake_case  :    Dict						    =  pytest.mark.integration



@require_faiss
class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  def 				lowercase		(				self :		List[Any]     )							->						Optional[Any]:
     __lowerCAmelCase								=	Dataset.from_dict({'filename': ['my_name-train' + '_' + str(lowerCAmelCase_     ) for x in np.arange(3_0     ).tolist()]}     )
     return dset






  def 				lowercase		(				self :		List[str]     )							->						Tuple:
     import faiss

     __lowerCAmelCase								=	self._create_dummy_dataset()
     __lowerCAmelCase								=	dset.map(
         lambda lowerCAmelCase_					,  lowerCAmelCase_     : {"vecs": i * np.ones(5					,  dtype=np.floataa     )}					,  with_indices=lowerCAmelCase_					,  keep_in_memory=lowerCAmelCase_     )
     __lowerCAmelCase								=	dset.add_faiss_index('vecs'					,  batch_size=1_0_0					,  metric_type=faiss.METRIC_INNER_PRODUCT     )
     __lowerCAmelCase	,	__lowerCAmelCase								=	dset.get_nearest_examples('vecs'					,  np.ones(5					,  dtype=np.floataa     )     )
     self.assertEqual(examples['filename'][0]					,  'my_name-train_29'     )
     dset.drop_index('vecs'     )






  def 				lowercase		(				self :		Optional[Any]     )							->						str:
     import faiss

     __lowerCAmelCase								=	self._create_dummy_dataset()
     dset.add_faiss_index_from_external_arrays(
         external_arrays=np.ones((3_0, 5)     ) * np.arange(3_0     ).reshape(-1					,  1     )					,  index_name='vecs'					,  batch_size=1_0_0					,  metric_type=faiss.METRIC_INNER_PRODUCT					,  )
     __lowerCAmelCase	,	__lowerCAmelCase								=	dset.get_nearest_examples('vecs'					,  np.ones(5					,  dtype=np.floataa     )     )
     self.assertEqual(examples['filename'][0]					,  'my_name-train_29'     )






  def 				lowercase		(				self :		int     )							->						Optional[Any]:
     import faiss

     __lowerCAmelCase								=	self._create_dummy_dataset()
     dset.add_faiss_index_from_external_arrays(
         external_arrays=np.ones((3_0, 5)     ) * np.arange(3_0     ).reshape(-1					,  1     )					,  index_name='vecs'					,  metric_type=faiss.METRIC_INNER_PRODUCT					,  )

     # Setting delete=False and unlinking manually is not pretty... but it is required on Windows to
     # ensure somewhat stable behaviour. If we don't, we get PermissionErrors. This is an age-old issue.
     # see https://bugs.python.org/issue14243 and
     # https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file/23212515
     with tempfile.NamedTemporaryFile(delete=lowerCAmelCase_     ) as tmp_file:
        dset.save_faiss_index('vecs'					,  tmp_file.name     )
        dset.load_faiss_index('vecs2'					,  tmp_file.name     )
     os.unlink(tmp_file.name     )

     __lowerCAmelCase	,	__lowerCAmelCase								=	dset.get_nearest_examples('vecs2'					,  np.ones(5					,  dtype=np.floataa     )     )
     self.assertEqual(examples['filename'][0]					,  'my_name-train_29'     )






  def 				lowercase		(				self :		Union[str, Any]     )							->						List[Any]:
     __lowerCAmelCase								=	self._create_dummy_dataset()
     dset.add_faiss_index_from_external_arrays(
         external_arrays=np.ones((3_0, 5)     ) * np.arange(3_0     ).reshape(-1					,  1     )					,  index_name='vecs'     )
     dset.drop_index('vecs'     )
     self.assertRaises(lowerCAmelCase_					,  partial(dset.get_nearest_examples					,  'vecs2'					,  np.ones(5					,  dtype=np.floataa     )     )     )






  def 				lowercase		(				self :		Union[str, Any]     )							->						Tuple:
     from elasticsearch import Elasticsearch

     __lowerCAmelCase								=	self._create_dummy_dataset()
     with patch('elasticsearch.Elasticsearch.search'     ) as mocked_search, patch(
         'elasticsearch.client.IndicesClient.create'     ) as mocked_index_create, patch('elasticsearch.helpers.streaming_bulk'     ) as mocked_bulk:
        __lowerCAmelCase								=	{'acknowledged': True}
        mocked_bulk.return_value([(True, None)] * 3_0     )
        __lowerCAmelCase								=	{'hits': {'hits': [{'_score': 1, '_id': 2_9}]}}
        __lowerCAmelCase								=	Elasticsearch()

        dset.add_elasticsearch_index('filename'					,  es_client=lowerCAmelCase_     )
        __lowerCAmelCase	,	__lowerCAmelCase								=	dset.get_nearest_examples('filename'					,  'my_name-train_29'     )
        self.assertEqual(examples['filename'][0]					,  'my_name-train_29'     )





@require_faiss
class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  def 				lowercase		(				self :		str     )							->						int:
     import faiss

     __lowerCAmelCase								=	FaissIndex(metric_type=faiss.METRIC_INNER_PRODUCT     )

     # add vectors
     index.add_vectors(np.eye(5					,  dtype=np.floataa     )     )
     self.assertIsNotNone(index.faiss_index     )
     self.assertEqual(index.faiss_index.ntotal					,  5     )
     index.add_vectors(np.zeros((5, 5)					,  dtype=np.floataa     )     )
     self.assertEqual(index.faiss_index.ntotal					,  1_0     )

     # single query
     __lowerCAmelCase								=	np.zeros(5					,  dtype=np.floataa     )
     __lowerCAmelCase								=	1
     __lowerCAmelCase	,	__lowerCAmelCase								=	index.search(lowerCAmelCase_     )
     self.assertRaises(lowerCAmelCase_					,  index.search					,  query.reshape(-1					,  1     )     )
     self.assertGreater(scores[0]					,  0     )
     self.assertEqual(indices[0]					,  1     )

     # batched queries
     __lowerCAmelCase								=	np.eye(5					,  dtype=np.floataa     )[::-1]
     __lowerCAmelCase	,	__lowerCAmelCase								=	index.search_batch(lowerCAmelCase_     )
     self.assertRaises(lowerCAmelCase_					,  index.search_batch					,  queries[0]     )
     __lowerCAmelCase								=	[scores[0] for scores in total_scores]
     __lowerCAmelCase								=	[indices[0] for indices in total_indices]
     self.assertGreater(np.min(lowerCAmelCase_     )					,  0     )
     self.assertListEqual([4, 3, 2, 1, 0]					,  lowerCAmelCase_     )






  def 				lowercase		(				self :		List[Any]     )							->						List[str]:
     import faiss

     __lowerCAmelCase								=	FaissIndex(string_factory='Flat'     )
     index.add_vectors(np.eye(5					,  dtype=np.floataa     )     )
     self.assertIsInstance(index.faiss_index					,  faiss.IndexFlat     )
     __lowerCAmelCase								=	FaissIndex(string_factory='LSH'     )
     index.add_vectors(np.eye(5					,  dtype=np.floataa     )     )
     self.assertIsInstance(index.faiss_index					,  faiss.IndexLSH     )
     with self.assertRaises(lowerCAmelCase_     ):
        __lowerCAmelCase								=	FaissIndex(string_factory='Flat'					,  custom_index=faiss.IndexFlat(5     )     )






  def 				lowercase		(				self :		Union[str, Any]     )							->						Dict:
     import faiss

     __lowerCAmelCase								=	faiss.IndexFlat(5     )
     __lowerCAmelCase								=	FaissIndex(custom_index=lowerCAmelCase_     )
     index.add_vectors(np.eye(5					,  dtype=np.floataa     )     )
     self.assertIsInstance(index.faiss_index					,  faiss.IndexFlat     )






  def 				lowercase		(				self :		str     )							->						Any:
     import faiss

     __lowerCAmelCase								=	FaissIndex(metric_type=faiss.METRIC_INNER_PRODUCT     )
     index.add_vectors(np.eye(5					,  dtype=np.floataa     )     )

     # Setting delete=False and unlinking manually is not pretty... but it is required on Windows to
     # ensure somewhat stable behaviour. If we don't, we get PermissionErrors. This is an age-old issue.
     # see https://bugs.python.org/issue14243 and
     # https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file/23212515
     with tempfile.NamedTemporaryFile(delete=lowerCAmelCase_     ) as tmp_file:
        index.save(tmp_file.name     )
        __lowerCAmelCase								=	FaissIndex.load(tmp_file.name     )
     os.unlink(tmp_file.name     )

     __lowerCAmelCase								=	np.zeros(5					,  dtype=np.floataa     )
     __lowerCAmelCase								=	1
     __lowerCAmelCase	,	__lowerCAmelCase								=	index.search(lowerCAmelCase_     )
     self.assertGreater(scores[0]					,  0     )
     self.assertEqual(indices[0]					,  1     )





@require_faiss
def   a_    ( lowerCAmelCase_      :			Union[str, Any]	):
   import faiss

   __lowerCAmelCase								=	FaissIndex(metric_type=faiss.METRIC_INNER_PRODUCT	)
   index.add_vectors(np.eye(5,	dtype=np.floataa	)	)

   __lowerCAmelCase								=	'index.faiss'
   __lowerCAmelCase								=	F"""mock://{index_name}"""
   index.save(lowerCAmelCase_,	storage_options=mockfs.storage_options	)
   __lowerCAmelCase								=	FaissIndex.load(lowerCAmelCase_,	storage_options=mockfs.storage_options	)

   __lowerCAmelCase								=	np.zeros(5,	dtype=np.floataa	)
   __lowerCAmelCase								=	1
   __lowerCAmelCase	,	__lowerCAmelCase								=	index.search(lowerCAmelCase_	)
   assert scores[0] > 0
   assert indices[0] == 1




@require_elasticsearch
class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  def 				lowercase		(				self :		Any     )							->						int:
     from elasticsearch import Elasticsearch

     with patch('elasticsearch.Elasticsearch.search'     ) as mocked_search, patch(
         'elasticsearch.client.IndicesClient.create'     ) as mocked_index_create, patch('elasticsearch.helpers.streaming_bulk'     ) as mocked_bulk:
        __lowerCAmelCase								=	Elasticsearch()
        __lowerCAmelCase								=	{'acknowledged': True}
        __lowerCAmelCase								=	ElasticSearchIndex(es_client=lowerCAmelCase_     )
        mocked_bulk.return_value([(True, None)] * 3     )
        index.add_documents(['foo', 'bar', 'foobar']     )

        # single query
        __lowerCAmelCase								=	'foo'
        __lowerCAmelCase								=	{'hits': {'hits': [{'_score': 1, '_id': 0}]}}
        __lowerCAmelCase	,	__lowerCAmelCase								=	index.search(lowerCAmelCase_     )
        self.assertEqual(scores[0]					,  1     )
        self.assertEqual(indices[0]					,  0     )

        # single query with timeout
        __lowerCAmelCase								=	'foo'
        __lowerCAmelCase								=	{'hits': {'hits': [{'_score': 1, '_id': 0}]}}
        __lowerCAmelCase	,	__lowerCAmelCase								=	index.search(lowerCAmelCase_					,  request_timeout=3_0     )
        self.assertEqual(scores[0]					,  1     )
        self.assertEqual(indices[0]					,  0     )

        # batched queries
        __lowerCAmelCase								=	['foo', 'bar', 'foobar']
        __lowerCAmelCase								=	{'hits': {'hits': [{'_score': 1, '_id': 1}]}}
        __lowerCAmelCase	,	__lowerCAmelCase								=	index.search_batch(lowerCAmelCase_     )
        __lowerCAmelCase								=	[scores[0] for scores in total_scores]
        __lowerCAmelCase								=	[indices[0] for indices in total_indices]
        self.assertGreater(np.min(lowerCAmelCase_     )					,  0     )
        self.assertListEqual([1, 1, 1]					,  lowerCAmelCase_     )

        # batched queries with timeout
        __lowerCAmelCase								=	['foo', 'bar', 'foobar']
        __lowerCAmelCase								=	{'hits': {'hits': [{'_score': 1, '_id': 1}]}}
        __lowerCAmelCase	,	__lowerCAmelCase								=	index.search_batch(lowerCAmelCase_					,  request_timeout=3_0     )
        __lowerCAmelCase								=	[scores[0] for scores in total_scores]
        __lowerCAmelCase								=	[indices[0] for indices in total_indices]
        self.assertGreater(np.min(lowerCAmelCase_     )					,  0     )
        self.assertListEqual([1, 1, 1]					,  lowerCAmelCase_     )

