


'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
      import numpy
      import tensorflow as tf

      from transformers import (
          TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
          BertConfig,
          DPRConfig,
          TFDPRContextEncoder,
          TFDPRQuestionEncoder,
          TFDPRReader,
      )





class    UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_=13			,     SCREAMING_SNAKE_CASE_=7			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=True			,     SCREAMING_SNAKE_CASE_=99			,     SCREAMING_SNAKE_CASE_=32			,     SCREAMING_SNAKE_CASE_=2			,     SCREAMING_SNAKE_CASE_=4			,     SCREAMING_SNAKE_CASE_=37			,     SCREAMING_SNAKE_CASE_="gelu"			,     SCREAMING_SNAKE_CASE_=0.1			,     SCREAMING_SNAKE_CASE_=0.1			,     SCREAMING_SNAKE_CASE_=5_12			,     SCREAMING_SNAKE_CASE_=16			,     SCREAMING_SNAKE_CASE_=2			,     SCREAMING_SNAKE_CASE_=0.0_2			,     SCREAMING_SNAKE_CASE_=3			,     SCREAMING_SNAKE_CASE_=4			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=0			,     )				->     Dict:
         __lowerCamelCase   :	Any								=		parent
         __lowerCamelCase   :	Dict								=		batch_size
         __lowerCamelCase   :	Optional[Any]								=		seq_length
         __lowerCamelCase   :	Tuple								=		is_training
         __lowerCamelCase   :	Optional[int]								=		use_input_mask
         __lowerCamelCase   :	Tuple								=		use_token_type_ids
         __lowerCamelCase   :	Tuple								=		use_labels
         __lowerCamelCase   :	Dict								=		vocab_size
         __lowerCamelCase   :	Union[str, Any]								=		hidden_size
         __lowerCamelCase   :	Optional[int]								=		num_hidden_layers
         __lowerCamelCase   :	List[Any]								=		num_attention_heads
         __lowerCamelCase   :	List[str]								=		intermediate_size
         __lowerCamelCase   :	Optional[int]								=		hidden_act
         __lowerCamelCase   :	Union[str, Any]								=		hidden_dropout_prob
         __lowerCamelCase   :	Optional[int]								=		attention_probs_dropout_prob
         __lowerCamelCase   :	Optional[int]								=		max_position_embeddings
         __lowerCamelCase   :	Union[str, Any]								=		type_vocab_size
         __lowerCamelCase   :	Optional[int]								=		type_sequence_label_size
         __lowerCamelCase   :	Tuple								=		initializer_range
         __lowerCamelCase   :	Any								=		num_labels
         __lowerCamelCase   :	List[str]								=		num_choices
         __lowerCamelCase   :	str								=		scope
         __lowerCamelCase   :	List[Any]								=		projection_dim







    def       lowercase_				(							self	)				->     Dict:
         __lowerCamelCase   :	List[str]								=		ids_tensor([self.batch_size, self.seq_length]			,     self.vocab_size	)

         __lowerCamelCase   :	Optional[int]								=		None
         if self.use_input_mask:
              # follow test_modeling_tf_ctrl.py
              __lowerCamelCase   :	List[str]								=		random_attention_mask([self.batch_size, self.seq_length]	)

         __lowerCamelCase   :	Optional[Any]								=		None
         if self.use_token_type_ids:
              __lowerCamelCase   :	List[str]								=		ids_tensor([self.batch_size, self.seq_length]			,     self.type_vocab_size	)

         __lowerCamelCase   :	Union[str, Any]								=		None
         __lowerCamelCase   :	Dict								=		None
         __lowerCamelCase   :	str								=		None
         if self.use_labels:
              __lowerCamelCase   :	int								=		ids_tensor([self.batch_size]			,     self.type_sequence_label_size	)
              __lowerCamelCase   :	Union[str, Any]								=		ids_tensor([self.batch_size, self.seq_length]			,     self.num_labels	)
              __lowerCamelCase   :	Dict								=		ids_tensor([self.batch_size]			,     self.num_choices	)

         __lowerCamelCase   :	Dict								=		BertConfig(
             vocab_size=self.vocab_size			,     hidden_size=self.hidden_size			,     num_hidden_layers=self.num_hidden_layers			,     num_attention_heads=self.num_attention_heads			,     intermediate_size=self.intermediate_size			,     hidden_act=self.hidden_act			,     hidden_dropout_prob=self.hidden_dropout_prob			,     attention_probs_dropout_prob=self.attention_probs_dropout_prob			,     max_position_embeddings=self.max_position_embeddings			,     type_vocab_size=self.type_vocab_size			,     is_decoder=SCREAMING_SNAKE_CASE_			,     initializer_range=self.initializer_range			,     )
         __lowerCamelCase   :	List[str]								=		DPRConfig(projection_dim=self.projection_dim			,     **config.to_dict()	)

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Tuple:
         __lowerCamelCase   :	Union[str, Any]								=		TFDPRContextEncoder(config=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	str								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Optional[int]								=		model(SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Dict								=		model(SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.pooler_output.shape			,     (self.batch_size, self.projection_dim or self.hidden_size)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     List[str]:
         __lowerCamelCase   :	int								=		TFDPRQuestionEncoder(config=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	List[str]								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	List[Any]								=		model(SCREAMING_SNAKE_CASE_			,     token_type_ids=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	int								=		model(SCREAMING_SNAKE_CASE_	)
         self.parent.assertEqual(result.pooler_output.shape			,     (self.batch_size, self.projection_dim or self.hidden_size)	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     str:
         __lowerCamelCase   :	Optional[int]								=		TFDPRReader(config=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Dict								=		model(SCREAMING_SNAKE_CASE_			,     attention_mask=SCREAMING_SNAKE_CASE_	)

         self.parent.assertEqual(result.start_logits.shape			,     (self.batch_size, self.seq_length)	)
         self.parent.assertEqual(result.end_logits.shape			,     (self.batch_size, self.seq_length)	)
         self.parent.assertEqual(result.relevance_logits.shape			,     (self.batch_size,)	)







    def       lowercase_				(							self	)				->     Tuple:
         __lowerCamelCase   :	int								=		self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       (
             __lowerCamelCase
         )				,       
         )   :	Tuple								=		config_and_inputs
         __lowerCamelCase   :	int								=		{'input_ids': input_ids}
         return config, inputs_dict







@require_tf
class    UpperCAmelCase_  (_UpperCAmelCase					,		_UpperCAmelCase					,		unittest.TestCase  ):





    """simple docstring"""






    lowerCamelCase  :					Optional[int]							     =			(
        (
            TFDPRContextEncoder,
            TFDPRQuestionEncoder,
            TFDPRReader,
        )
        if is_tf_available()
        else ()
    )
    lowerCamelCase  :					Tuple							     =			{'feature-extraction': TFDPRQuestionEncoder} if is_tf_available() else {}

    lowerCamelCase  :					str							     =			False
    lowerCamelCase  :					str							     =			False
    lowerCamelCase  :					Optional[Any]							     =			False
    lowerCamelCase  :					Any							     =			False
    lowerCamelCase  :					str							     =			False







    def       lowercase_				(							self	)				->     Tuple:
         __lowerCamelCase   :	Tuple								=		TFDPRModelTester(self	)
         __lowerCamelCase   :	Union[str, Any]								=		ConfigTester(self			,     config_class=SCREAMING_SNAKE_CASE_			,     hidden_size=37	)







    def       lowercase_				(							self	)				->     str:
         self.config_tester.run_common_tests()







    def       lowercase_				(							self	)				->     Optional[Any]:
         __lowerCamelCase   :	Any								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_context_encoder(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     Optional[int]:
         __lowerCamelCase   :	List[Any]								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_question_encoder(*SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     List[str]:
         __lowerCamelCase   :	List[Any]								=		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_reader(*SCREAMING_SNAKE_CASE_	)







    @slow
    def       lowercase_				(							self	)				->     int:
         for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase   :	Optional[Any]								=		TFDPRContextEncoder.from_pretrained(SCREAMING_SNAKE_CASE_	)
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)

         for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase   :	List[str]								=		TFDPRContextEncoder.from_pretrained(SCREAMING_SNAKE_CASE_	)
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)

         for model_name in TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase   :	Union[str, Any]								=		TFDPRQuestionEncoder.from_pretrained(SCREAMING_SNAKE_CASE_	)
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)

         for model_name in TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase   :	List[str]								=		TFDPRReader.from_pretrained(SCREAMING_SNAKE_CASE_	)
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)







@require_tf
class    UpperCAmelCase_  (unittest.TestCase  ):





    """simple docstring"""






    @slow
    def       lowercase_				(							self	)				->     Any:
         __lowerCamelCase   :	List[Any]								=		TFDPRQuestionEncoder.from_pretrained('facebook/dpr-question_encoder-single-nq-base'	)

         __lowerCamelCase   :	Union[str, Any]								=		tf.constant(
             [[1_01, 75_92, 10_10, 20_03, 20_26, 38_99, 1_01_40, 10_29, 1_02]]	)  # [CLS] hello, is my dog cute? [SEP]
         __lowerCamelCase   :	List[str]								=		model(SCREAMING_SNAKE_CASE_	)[0]  # embedding shape = (1, 768)
         # compare the actual values for a slice.
         __lowerCamelCase   :	Optional[int]								=		tf.constant(
             [
                 [
                     0.0_3_2_3_6_2_5_3,
                     0.1_2_7_5_3_3_3_5,
                     0.1_6_8_1_8_5_0_9,
                     0.0_0_2_7_9_7_8_6,
                     0.3_8_9_6_9_3_3,
                     0.2_4_2_6_4_9_4_5,
                     0.2_1_7_8_9_7_1,
                     -0.0_2_3_3_5_2_2_7,
                     -0.0_8_4_8_1_9_5_9,
                     -0.1_4_3_2_4_1_1_7,
                 ]
             ]	)
         self.assertTrue(numpy.allclose(output[:, :10].numpy()			,     expected_slice.numpy()			,     atol=1E-4	)	)










'''simple docstring'''



from copy import deepcopy
from typing import Optional, Union

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import TensorType, is_tf_available, is_torch_available


if is_torch_available():
      import torch

if is_tf_available():
      import tensorflow as tf





class    UpperCAmelCase_  (_UpperCAmelCase  ):





    """simple docstring"""






    lowerCamelCase  :					Dict							     =			['image_processor']
    lowerCamelCase  :					str							     =			'SamImageProcessor'







    def __init__(							self			,     SCREAMING_SNAKE_CASE_	)				->     List[str]:
         super().__init__(SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Any								=		self.image_processor
         __lowerCamelCase   :	str								=		-10
         __lowerCamelCase   :	List[str]								=		self.image_processor.size['longest_edge']







    def __call__(							self			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_ = None			,     **SCREAMING_SNAKE_CASE_			,     )				->     BatchEncoding:
         __lowerCamelCase   :	Union[str, Any]								=		self.image_processor(
             SCREAMING_SNAKE_CASE_			,     return_tensors=SCREAMING_SNAKE_CASE_			,     **SCREAMING_SNAKE_CASE_			,     )

         # pop arguments that are not used in the foward but used nevertheless
         __lowerCamelCase   :	List[Any]								=		encoding_image_processor['original_sizes']

         if hasattr(SCREAMING_SNAKE_CASE_			,     'numpy'	):  # Checks if Torch or TF tensor
              __lowerCamelCase   :	Dict								=		original_sizes.numpy()

         __lowerCamelCase				,       __lowerCamelCase				,       __lowerCamelCase   :	str								=		self._check_and_preprocess_points(
             input_points=SCREAMING_SNAKE_CASE_			,     input_labels=SCREAMING_SNAKE_CASE_			,     input_boxes=SCREAMING_SNAKE_CASE_			,     )

         __lowerCamelCase   :	Tuple								=		self._normalize_and_convert(
             SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     input_points=SCREAMING_SNAKE_CASE_			,     input_labels=SCREAMING_SNAKE_CASE_			,     input_boxes=SCREAMING_SNAKE_CASE_			,     return_tensors=SCREAMING_SNAKE_CASE_			,     )

         return encoding_image_processor







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_="pt"			,     )				->     Optional[int]:
         if input_points is not None:
              if len(SCREAMING_SNAKE_CASE_	) != len(SCREAMING_SNAKE_CASE_	):
                   __lowerCamelCase   :	Union[str, Any]								=		[
                       self._normalize_coordinates(self.target_size			,     SCREAMING_SNAKE_CASE_			,     original_sizes[0]	) for point in input_points
                   ]
              else:
                   __lowerCamelCase   :	List[Any]								=		[
                       self._normalize_coordinates(self.target_size			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
                       for point, original_size in zip(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
                   ]
              # check that all arrays have the same shape
              if not all(point.shape == input_points[0].shape for point in input_points	):
                   if input_labels is not None:
                        __lowerCamelCase				,       __lowerCamelCase   :	Tuple								=		self._pad_points_and_labels(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)

              __lowerCamelCase   :	Optional[int]								=		np.array(SCREAMING_SNAKE_CASE_	)

         if input_labels is not None:
              __lowerCamelCase   :	Optional[int]								=		np.array(SCREAMING_SNAKE_CASE_	)

         if input_boxes is not None:
              if len(SCREAMING_SNAKE_CASE_	) != len(SCREAMING_SNAKE_CASE_	):
                   __lowerCamelCase   :	Union[str, Any]								=		[
                       self._normalize_coordinates(self.target_size			,     SCREAMING_SNAKE_CASE_			,     original_sizes[0]			,     is_bounding_box=SCREAMING_SNAKE_CASE_	)
                       for box in input_boxes
                   ]
              else:
                   __lowerCamelCase   :	Optional[int]								=		[
                       self._normalize_coordinates(self.target_size			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     is_bounding_box=SCREAMING_SNAKE_CASE_	)
                       for box, original_size in zip(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
                   ]
              __lowerCamelCase   :	Optional[int]								=		np.array(SCREAMING_SNAKE_CASE_	)

         if input_boxes is not None:
              if return_tensors == "pt":
                   __lowerCamelCase   :	Any								=		torch.from_numpy(SCREAMING_SNAKE_CASE_	)
                   # boxes batch size of 1 by default
                   __lowerCamelCase   :	Union[str, Any]								=		input_boxes.unsqueeze(1	) if len(input_boxes.shape	) != 3 else input_boxes
              elif return_tensors == "tf":
                   __lowerCamelCase   :	List[str]								=		tf.convert_to_tensor(SCREAMING_SNAKE_CASE_	)
                   # boxes batch size of 1 by default
                   __lowerCamelCase   :	str								=		tf.expand_dims(SCREAMING_SNAKE_CASE_			,     1	) if len(input_boxes.shape	) != 3 else input_boxes
              encoding_image_processor.update({'input_boxes': input_boxes}	)
         if input_points is not None:
              if return_tensors == "pt":
                   __lowerCamelCase   :	int								=		torch.from_numpy(SCREAMING_SNAKE_CASE_	)
                   # point batch size of 1 by default
                   __lowerCamelCase   :	Dict								=		input_points.unsqueeze(1	) if len(input_points.shape	) != 4 else input_points
              elif return_tensors == "tf":
                   __lowerCamelCase   :	Dict								=		tf.convert_to_tensor(SCREAMING_SNAKE_CASE_	)
                   # point batch size of 1 by default
                   __lowerCamelCase   :	Tuple								=		tf.expand_dims(SCREAMING_SNAKE_CASE_			,     1	) if len(input_points.shape	) != 4 else input_points
              encoding_image_processor.update({'input_points': input_points}	)
         if input_labels is not None:
              if return_tensors == "pt":
                   __lowerCamelCase   :	List[Any]								=		torch.from_numpy(SCREAMING_SNAKE_CASE_	)
                   # point batch size of 1 by default
                   __lowerCamelCase   :	Dict								=		input_labels.unsqueeze(1	) if len(input_labels.shape	) != 3 else input_labels
              elif return_tensors == "tf":
                   __lowerCamelCase   :	str								=		tf.convert_to_tensor(SCREAMING_SNAKE_CASE_	)
                   # point batch size of 1 by default
                   __lowerCamelCase   :	Dict								=		tf.expand_dims(SCREAMING_SNAKE_CASE_			,     1	) if len(input_labels.shape	) != 3 else input_labels
              encoding_image_processor.update({'input_labels': input_labels}	)

         return encoding_image_processor







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     Tuple:
         __lowerCamelCase   :	List[str]								=		max([point.shape[0] for point in input_points]	)
         __lowerCamelCase   :	Union[str, Any]								=		[]
         for i, point in enumerate(SCREAMING_SNAKE_CASE_	):
              if point.shape[0] != expected_nb_points:
                   __lowerCamelCase   :	Optional[int]								=		np.concatenate(
                       [point, np.zeros((expected_nb_points - point.shape[0], 2)	) + self.point_pad_value]			,     axis=0	)
                   __lowerCamelCase   :	List[Any]								=		np.append(input_labels[i]			,     [self.point_pad_value]	)
              processed_input_points.append(SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	List[Any]								=		processed_input_points
         return input_points, input_labels







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_=False	)				->     np.ndarray:
         __lowerCamelCase				,       __lowerCamelCase   :	Tuple								=		original_size
         __lowerCamelCase				,       __lowerCamelCase   :	Optional[Any]								=		self.image_processor._get_preprocess_shape(SCREAMING_SNAKE_CASE_			,     longest_edge=SCREAMING_SNAKE_CASE_	)
         __lowerCamelCase   :	Dict								=		deepcopy(SCREAMING_SNAKE_CASE_	).astype(SCREAMING_SNAKE_CASE_	)

         if is_bounding_box:
              __lowerCamelCase   :	Optional[int]								=		coords.reshape(-1			,     2			,     2	)

         __lowerCamelCase   :	List[Any]								=		coords[..., 0] * (new_w / old_w)
         __lowerCamelCase   :	Dict								=		coords[..., 1] * (new_h / old_h)

         if is_bounding_box:
              __lowerCamelCase   :	Tuple								=		coords.reshape(-1			,     4	)

         return coords







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     SCREAMING_SNAKE_CASE_=None			,     )				->     Optional[Any]:
         if input_points is not None:
              if hasattr(SCREAMING_SNAKE_CASE_			,     'numpy'	):  # Checks for TF or Torch tensor
                   __lowerCamelCase   :	List[str]								=		input_points.numpy().tolist()

              if not isinstance(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	) or not isinstance(input_points[0]			,     SCREAMING_SNAKE_CASE_	):
                   raise ValueError('Input points must be a list of list of floating points.'	)
              __lowerCamelCase   :	str								=		[np.array(SCREAMING_SNAKE_CASE_	) for input_point in input_points]
         else:
              __lowerCamelCase   :	Optional[Any]								=		None

         if input_labels is not None:
              if hasattr(SCREAMING_SNAKE_CASE_			,     'numpy'	):
                   __lowerCamelCase   :	Union[str, Any]								=		input_labels.numpy().tolist()

              if not isinstance(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	) or not isinstance(input_labels[0]			,     SCREAMING_SNAKE_CASE_	):
                   raise ValueError('Input labels must be a list of list integers.'	)
              __lowerCamelCase   :	Any								=		[np.array(SCREAMING_SNAKE_CASE_	) for label in input_labels]
         else:
              __lowerCamelCase   :	Dict								=		None

         if input_boxes is not None:
              if hasattr(SCREAMING_SNAKE_CASE_			,     'numpy'	):
                   __lowerCamelCase   :	int								=		input_boxes.numpy().tolist()

              if (
                  not isinstance(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
                  or not isinstance(input_boxes[0]			,     SCREAMING_SNAKE_CASE_	)
                  or not isinstance(input_boxes[0][0]			,     SCREAMING_SNAKE_CASE_	)
              ):
                   raise ValueError('Input boxes must be a list of list of list of floating points.'	)
              __lowerCamelCase   :	List[Any]								=		[np.array(SCREAMING_SNAKE_CASE_	).astype(np.floataa	) for box in input_boxes]
         else:
              __lowerCamelCase   :	Tuple								=		None

         return input_points, input_labels, input_boxes







    @property
    def       lowercase_				(							self	)				->     Dict:
         __lowerCamelCase   :	Any								=		self.image_processor.model_input_names
         return list(dict.fromkeys(SCREAMING_SNAKE_CASE_	)	)







    def       lowercase_				(							self			,     *SCREAMING_SNAKE_CASE_			,     **SCREAMING_SNAKE_CASE_	)				->     Optional[Any]:
         return self.image_processor.post_process_masks(*SCREAMING_SNAKE_CASE_			,     **SCREAMING_SNAKE_CASE_	)






