
from __future__ import annotations

from collections.abc import Iterable
class 			lowercase__:



 """simple docstring"""




 def __init__(	self  :      Optional[Any]	,							SCREAMING_SNAKE_CASE_  :      Optional[int]	,							SCREAMING_SNAKE_CASE_  :      int	)	->					Optional[Any]:
     lowercase_					  = float(__A	), float(__A	)
 def __eq__(	self  :      Any	,							SCREAMING_SNAKE_CASE_  :      Any	)	->					Any:
     return self.x == other.x and self.y == other.y
 def __ne__(	self  :      Union[str, Any]	,							SCREAMING_SNAKE_CASE_  :      int	)	->					int:
     return not self == other
 def __gt__(	self  :      str	,							SCREAMING_SNAKE_CASE_  :      int	)	->					List[str]:





     if self.x > other.x:
         return True
     elif self.x == other.x:
         return self.y > other.y
     return False
 def __lt__(	self  :      Optional[Any]	,							SCREAMING_SNAKE_CASE_  :      str	)	->					List[str]:
     return not self > other
 def __ge__(	self  :      Optional[Any]	,							SCREAMING_SNAKE_CASE_  :      Any	)	->					Union[str, Any]:





     if self.x > other.x:
         return True
     elif self.x == other.x:
         return self.y >= other.y
     return False
 def __le__(	self  :      Union[str, Any]	,							SCREAMING_SNAKE_CASE_  :      List[Any]	)	->					int:





     if self.x < other.x:
         return True
     elif self.x == other.x:
         return self.y <= other.y
     return False
 def __repr__(	self  :      Tuple	)	->					int:
     return f'''({self.x}, {self.y})'''




 def __hash__(	self  :      Union[str, Any]	)	->					Tuple:
     return hash(self.x	)




def     a						(							snake_case__: List[Any]						,       ):


    '''simple docstring'''
    lowercase_					  = []
    if list_of_tuples:
        for p in list_of_tuples:
            if isinstance(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ ):
                points.append(SCREAMING_SNAKE_CASE_ )
            else:
                try:
                    points.append(Point(p[0]						,       p[1] ) )
                except (IndexError, TypeError):
                    print(
                        F'''Ignoring deformed point {p}. All points'''
                        ''' must have at least 2 coordinates.''' )
    return points




def     a						(							snake_case__: List[str] ):


    '''simple docstring'''

    if not hasattr(SCREAMING_SNAKE_CASE_						,       '''__iter__''' ):
        lowercase_					  = F'''Expecting an iterable object but got an non-iterable type {points}'''
        raise ValueError(SCREAMING_SNAKE_CASE_ )

    if not points:
        lowercase_					  = F'''Expecting a list of points but got {points}'''
        raise ValueError(SCREAMING_SNAKE_CASE_ )

    return _construct_points(SCREAMING_SNAKE_CASE_ )




def     a						(							snake_case__: str						,       snake_case__: Tuple						,       snake_case__: Union[str, Any] ):


    '''simple docstring'''
    lowercase_					  = (a.x * b.y + b.x * c.y + c.x * a.y) - (a.y * b.x + b.y * c.x + c.y * a.x)
    return det




def     a						(							snake_case__: Tuple ):


    '''simple docstring'''
    lowercase_					  = sorted(_validate_input(SCREAMING_SNAKE_CASE_ ) )
    lowercase_					  = len(SCREAMING_SNAKE_CASE_ )
    lowercase_					  = set()

    for i in range(n - 1 ):
        for j in range(i + 1						,       SCREAMING_SNAKE_CASE_ ):
            lowercase_					  = False
            lowercase_					  = True
            for k in range(SCREAMING_SNAKE_CASE_ ):
                if k != i and k != j:
                    lowercase_					  = _det(points[i]						,       points[j]						,       points[k] )

                    if det_k > 0:
                        lowercase_					  = True
                    elif det_k < 0:
                        lowercase_					  = True
                    else:
                        # point[i], point[j], point[k] all lie on a straight line
                        # if point[k] is to the left of point[i] or it's to the
                        # right of point[j], then point[i], point[j] cannot be
                        # part of the convex hull of A
                        if points[k] < points[i] or points[k] > points[j]:
                            lowercase_					  = False
                            break

                if points_left_of_ij and points_right_of_ij:
                    lowercase_					  = False
                    break

            if ij_part_of_convex_hull:
                convex_set.update([points[i], points[j]] )

    return sorted(SCREAMING_SNAKE_CASE_ )




def     a						(							snake_case__: str ):


    '''simple docstring'''
    lowercase_					  = sorted(_validate_input(SCREAMING_SNAKE_CASE_ ) )
    lowercase_					  = len(SCREAMING_SNAKE_CASE_ )

    # divide all the points into an upper hull and a lower hull
    # the left most point and the right most point are definitely
    # members of the convex hull by definition.
    # use these two anchors to divide all the points into two hulls,
    # an upper hull and a lower hull.

    # all points to the left (above) the line joining the extreme points belong to the
    # upper hull
    # all points to the right (below) the line joining the extreme points below to the
    # lower hull
    # ignore all points on the line joining the extreme points since they cannot be
    # part of the convex hull

    lowercase_					  = points[0]
    lowercase_					  = points[n - 1]

    lowercase_					  = {left_most_point, right_most_point}
    lowercase_					  = []
    lowercase_					  = []

    for i in range(1						,       n - 1 ):
        lowercase_					  = _det(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       points[i] )

        if det > 0:
            upper_hull.append(points[i] )
        elif det < 0:
            lower_hull.append(points[i] )

    _construct_hull(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ )
    _construct_hull(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ )

    return sorted(SCREAMING_SNAKE_CASE_ )




def     a						(							snake_case__: Union[str, Any]						,       snake_case__: str						,       snake_case__: Any						,       snake_case__: List[Any] ):


    '''simple docstring'''

    if points:
        lowercase_					  = None
        lowercase_					  = float('''-inf''' )
        lowercase_					  = []

        for p in points:
            lowercase_					  = _det(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ )

            if det > 0:
                candidate_points.append(SCREAMING_SNAKE_CASE_ )

                if det > extreme_point_distance:
                    lowercase_					  = det
                    lowercase_					  = p

        if extreme_point:
            _construct_hull(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ )
            convex_set.add(SCREAMING_SNAKE_CASE_ )
            _construct_hull(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ )




def     a						(							snake_case__: Optional[int] ):


    '''simple docstring'''
    lowercase_					  = sorted(_validate_input(SCREAMING_SNAKE_CASE_ ) )
    lowercase_					  = len(SCREAMING_SNAKE_CASE_ )

    lowercase_					  = points[:2]
    for i in range(2						,       SCREAMING_SNAKE_CASE_ ):
        lowercase_					  = _det(convex_hull[1]						,       convex_hull[0]						,       points[i] )
        if det > 0:
            convex_hull.insert(0						,       points[i] )
            break
        elif det < 0:
            convex_hull.append(points[i] )
            break
        else:
            lowercase_					  = points[i]
    i += 1

    for j in range(SCREAMING_SNAKE_CASE_						,       SCREAMING_SNAKE_CASE_ ):
        if (
            _det(convex_hull[0]						,       convex_hull[-1]						,       points[j] ) > 0
            and _det(convex_hull[-1]						,       convex_hull[0]						,       points[1] ) < 0
        ):
            # The point lies within the convex hull
            continue

        convex_hull.insert(0						,       points[j] )
        convex_hull.append(points[j] )
        while _det(convex_hull[0]						,       convex_hull[1]						,       convex_hull[2] ) >= 0:
            del convex_hull[1]
        while _det(convex_hull[-1]						,       convex_hull[-2]						,       convex_hull[-3] ) <= 0:
            del convex_hull[-2]

        # `convex_hull` is contains the convex hull in circular order
    return sorted(convex_hull[1:] if len(SCREAMING_SNAKE_CASE_ ) > 3 else convex_hull )




def     a						(							):


    '''simple docstring'''
    lowercase_					  = [
        (0, 3),
        (2, 2),
        (1, 1),
        (2, 1),
        (3, 0),
        (0, 0),
        (3, 3),
        (2, -1),
        (2, -4),
        (1, -3),
    ]
    # the convex set of points is
    # [(0, 0), (0, 3), (1, -3), (2, -4), (3, 0), (3, 3)]
    lowercase_					  = convex_hull_bf(SCREAMING_SNAKE_CASE_ )

    lowercase_					  = convex_hull_recursive(SCREAMING_SNAKE_CASE_ )
    assert results_bf == results_recursive

    lowercase_					  = convex_hull_melkman(SCREAMING_SNAKE_CASE_ )
    assert results_bf == results_melkman

    print(SCREAMING_SNAKE_CASE_ )


if __name__ == "__main__":
      main()






import unittest

import numpy as np

from transformers import ElectraConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
						from transformers.models.electra.modeling_flax_electra import (
						    FlaxElectraForCausalLM,
						    FlaxElectraForMaskedLM,
						    FlaxElectraForMultipleChoice,
						    FlaxElectraForPreTraining,
						    FlaxElectraForQuestionAnswering,
						    FlaxElectraForSequenceClassification,
						    FlaxElectraForTokenClassification,
						    FlaxElectraModel,
						)
class 			lowercase__(    unittest.TestCase							):



	"""simple docstring"""




	def __init__(	self  :      str	,							SCREAMING_SNAKE_CASE_  :      str	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=1_3	,							SCREAMING_SNAKE_CASE_  :      int=7	,							SCREAMING_SNAKE_CASE_  :      Tuple=True	,							SCREAMING_SNAKE_CASE_  :      List[Any]=True	,							SCREAMING_SNAKE_CASE_  :      List[Any]=True	,							SCREAMING_SNAKE_CASE_  :      Dict=True	,							SCREAMING_SNAKE_CASE_  :      Optional[Any]=9_9	,							SCREAMING_SNAKE_CASE_  :      Any=2_4	,							SCREAMING_SNAKE_CASE_  :      int=3_2	,							SCREAMING_SNAKE_CASE_  :      Any=5	,							SCREAMING_SNAKE_CASE_  :      List[str]=4	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=3_7	,							SCREAMING_SNAKE_CASE_  :      Optional[int]="gelu"	,							SCREAMING_SNAKE_CASE_  :      Any=0.1	,							SCREAMING_SNAKE_CASE_  :      List[Any]=0.1	,							SCREAMING_SNAKE_CASE_  :      Dict=5_1_2	,							SCREAMING_SNAKE_CASE_  :      Optional[int]=1_6	,							SCREAMING_SNAKE_CASE_  :      List[Any]=2	,							SCREAMING_SNAKE_CASE_  :      List[str]=0.02	,							SCREAMING_SNAKE_CASE_  :      List[str]=4	,							)	->					Optional[int]:
					lowercase_					  = parent
					lowercase_					  = batch_size
					lowercase_					  = seq_length
					lowercase_					  = is_training
					lowercase_					  = use_attention_mask
					lowercase_					  = use_token_type_ids
					lowercase_					  = use_labels
					lowercase_					  = vocab_size
					lowercase_					  = hidden_size
					lowercase_					  = embedding_size
					lowercase_					  = num_hidden_layers
					lowercase_					  = num_attention_heads
					lowercase_					  = intermediate_size
					lowercase_					  = hidden_act
					lowercase_					  = hidden_dropout_prob
					lowercase_					  = attention_probs_dropout_prob
					lowercase_					  = max_position_embeddings
					lowercase_					  = type_vocab_size
					lowercase_					  = type_sequence_label_size
					lowercase_					  = initializer_range
					lowercase_					  = num_choices
	def 						_lowercase  (	self  :      Optional[int]	)	->					Tuple:
					lowercase_					  = ids_tensor([self.batch_size, self.seq_length]	,							self.vocab_size	)

					lowercase_					  = None
					if self.use_attention_mask:
									lowercase_					  = random_attention_mask([self.batch_size, self.seq_length]	)

					lowercase_					  = None
					if self.use_token_type_ids:
									lowercase_					  = ids_tensor([self.batch_size, self.seq_length]	,							self.type_vocab_size	)

					lowercase_					  = ElectraConfig(
					    vocab_size=self.vocab_size	,							hidden_size=self.hidden_size	,							embedding_size=self.embedding_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	,							initializer_range=self.initializer_range	,							)

					return config, input_ids, token_type_ids, attention_mask




	def 						_lowercase  (	self  :      Any	)	->					str:
					lowercase_					  = self.prepare_config_and_inputs()
					lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_					  = config_and_inputs
					lowercase_					  = {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
					return config, inputs_dict

@require_flax
class 			lowercase__(    UpperCAmelCase			,						unittest.TestCase							):



	"""simple docstring"""




	a      :List[str]   					=     True

	a      :List[Any]   					=     (
	    (
	        FlaxElectraModel,
	        FlaxElectraForCausalLM,
	        FlaxElectraForMaskedLM,
	        FlaxElectraForPreTraining,
	        FlaxElectraForTokenClassification,
	        FlaxElectraForQuestionAnswering,
	        FlaxElectraForMultipleChoice,
	        FlaxElectraForSequenceClassification,
	    )
	    if is_flax_available()
	    else ()
	)
	def 						_lowercase  (	self  :      List[str]	)	->					Optional[Any]:
					lowercase_					  = FlaxElectraModelTester(self	)




	@slow
	def 						_lowercase  (	self  :      List[str]	)	->					int:
					for model_class_name in self.all_model_classes:
									if model_class_name == FlaxElectraForMaskedLM:
													lowercase_					  = model_class_name.from_pretrained('''google/electra-small-generator'''	)
									else:
													lowercase_					  = model_class_name.from_pretrained('''google/electra-small-discriminator'''	)
									lowercase_					  = model(np.ones((1, 1)	)	)
									self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)




