

'''simple docstring'''



import collections
import inspect
import unittest
from typing import Dict, List, Tuple

from transformers import MaskFormerSwinConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device
from transformers.utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch
   from torch import nn

   from transformers import MaskFormerSwinBackbone
   from transformers.models.maskformer import MaskFormerSwinModel

class       SCREAMING_SNAKE_CASE       :






      '''simple docstring'''






      def __init__(       self			:		str  ,       snake_case			:		str  ,       snake_case			:		Optional[Any]=13  ,       snake_case			:		Dict=32  ,       snake_case			:		Any=2  ,       snake_case			:		List[str]=3  ,       snake_case			:		Union[str, Any]=16  ,       snake_case			:		Tuple=[1, 2, 1]  ,       snake_case			:		Dict=[2, 2, 4]  ,       snake_case			:		str=2  ,       snake_case			:		Optional[Any]=2.0  ,       snake_case			:		List[str]=True  ,       snake_case			:		str=0.0  ,       snake_case			:		Dict=0.0  ,       snake_case			:		Union[str, Any]=0.1  ,       snake_case			:		Union[str, Any]="gelu"  ,       snake_case			:		str=False  ,       snake_case			:		Union[str, Any]=True  ,       snake_case			:		List[str]=0.02  ,       snake_case			:		Tuple=1e-5  ,       snake_case			:		Optional[int]=True  ,       snake_case			:		Dict=None  ,       snake_case			:		List[str]=True  ,       snake_case			:		str=10  ,       snake_case			:		List[str]=8  ,       snake_case			:		Dict=["stage1", "stage2", "stage3"]  ,       snake_case			:		int=[1, 2, 3]  ,       ):



          """simple docstring"""





          _snake_case			:			Optional[Any]				       =		parent
          _snake_case			:			List[Any]				       =		batch_size
          _snake_case			:			List[Any]				       =		image_size
          _snake_case			:			int				       =		patch_size
          _snake_case			:			Dict				       =		num_channels
          _snake_case			:			List[Any]				       =		embed_dim
          _snake_case			:			List[Any]				       =		depths
          _snake_case			:			Optional[int]				       =		num_heads
          _snake_case			:			Optional[int]				       =		window_size
          _snake_case			:			List[Any]				       =		mlp_ratio
          _snake_case			:			Tuple				       =		qkv_bias
          _snake_case			:			List[str]				       =		hidden_dropout_prob
          _snake_case			:			int				       =		attention_probs_dropout_prob
          _snake_case			:			Any				       =		drop_path_rate
          _snake_case			:			Optional[int]				       =		hidden_act
          _snake_case			:			Tuple				       =		use_absolute_embeddings
          _snake_case			:			Dict				       =		patch_norm
          _snake_case			:			List[Any]				       =		layer_norm_eps
          _snake_case			:			Dict				       =		initializer_range
          _snake_case			:			Optional[Any]				       =		is_training
          _snake_case			:			Any				       =		scope
          _snake_case			:			List[str]				       =		use_labels
          _snake_case			:			List[str]				       =		type_sequence_label_size
          _snake_case			:			Dict				       =		encoder_stride
          _snake_case			:			Union[str, Any]				       =		out_features
          _snake_case			:			int				       =		out_indices




      def 						__UpperCAmelCase      (       self			:		Union[str, Any] ):



          """simple docstring"""





          _snake_case			:			Optional[int]				       =		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )

          _snake_case			:			List[Any]				       =		None
          if self.use_labels:
              _snake_case			:			Dict				       =		ids_tensor([self.batch_size]  ,       self.type_sequence_label_size )

          _snake_case			:			List[Any]				       =		self.get_config()

          return config, pixel_values, labels




      def 						__UpperCAmelCase      (       self			:		Union[str, Any] ):



          """simple docstring"""





          return MaskFormerSwinConfig(
              image_size=self.image_size  ,       patch_size=self.patch_size  ,       num_channels=self.num_channels  ,       embed_dim=self.embed_dim  ,       depths=self.depths  ,       num_heads=self.num_heads  ,       window_size=self.window_size  ,       mlp_ratio=self.mlp_ratio  ,       qkv_bias=self.qkv_bias  ,       hidden_dropout_prob=self.hidden_dropout_prob  ,       attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,       drop_path_rate=self.drop_path_rate  ,       hidden_act=self.hidden_act  ,       use_absolute_embeddings=self.use_absolute_embeddings  ,       path_norm=self.patch_norm  ,       layer_norm_eps=self.layer_norm_eps  ,       initializer_range=self.initializer_range  ,       encoder_stride=self.encoder_stride  ,       out_features=self.out_features  ,       out_indices=self.out_indices  ,       )




      def 						__UpperCAmelCase      (       self			:		Union[str, Any]  ,       snake_case			:		List[str]  ,       snake_case			:		int  ,       snake_case			:		Optional[int] ):



          """simple docstring"""





          _snake_case			:			Dict				       =		MaskFormerSwinModel(config=_A )
          model.to(_A )
          model.eval()
          _snake_case			:			Any				       =		model(_A )

          _snake_case			:			Optional[int]				       =		((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths ) - 1))
          _snake_case			:			Tuple				       =		int(config.embed_dim * 2 ** (len(config.depths ) - 1) )

          self.parent.assertEqual(result.last_hidden_state.shape  ,       (self.batch_size, expected_seq_len, expected_dim) )




      def 						__UpperCAmelCase      (       self			:		int  ,       snake_case			:		int  ,       snake_case			:		Any  ,       snake_case			:		Tuple ):



          """simple docstring"""





          _snake_case			:			List[str]				       =		MaskFormerSwinBackbone(config=_A )
          model.to(_A )
          model.eval()
          _snake_case			:			Any				       =		model(_A )

          # verify feature maps
          self.parent.assertEqual(len(result.feature_maps )  ,       len(config.out_features ) )
          self.parent.assertListEqual(list(result.feature_maps[0].shape )  ,       [13, 16, 16, 16] )

          # verify channels
          self.parent.assertEqual(len(model.channels )  ,       len(config.out_features ) )
          self.parent.assertListEqual(model.channels  ,       [16, 32, 64] )

          # verify ValueError
          with self.parent.assertRaises(_A ):
              _snake_case			:			Tuple				       =		['''stem''']
              _snake_case			:			str				       =		MaskFormerSwinBackbone(config=_A )




      def 						__UpperCAmelCase      (       self			:		int ):



          """simple docstring"""





          _snake_case			:			Optional[int]				       =		self.prepare_config_and_inputs()
          _snake_case			:			List[str]				       =		config_and_inputs
          _snake_case			:			List[Any]				       =		{'''pixel_values''': pixel_values}
          return config, inputs_dict



@require_torch
class       SCREAMING_SNAKE_CASE       (				lowercase_   ,lowercase_   ,unittest.TestCase       ):






      '''simple docstring'''






      SCREAMING_SNAKE_CASE__			:					Optional[int]     =					(
          (
              MaskFormerSwinModel,
              MaskFormerSwinBackbone,
          )
          if is_torch_available()
          else ()
      )
      SCREAMING_SNAKE_CASE__			:					List[Any]     =					{'''feature-extraction''': MaskFormerSwinModel} if is_torch_available() else {}
      SCREAMING_SNAKE_CASE__			:					List[Any]     =					False
      SCREAMING_SNAKE_CASE__			:					List[Any]     =					False
      SCREAMING_SNAKE_CASE__			:					int     =					False
      SCREAMING_SNAKE_CASE__			:					List[Any]     =					False
      SCREAMING_SNAKE_CASE__			:					Dict     =					False




      def 						__UpperCAmelCase      (       self			:		List[str] ):



          """simple docstring"""





          _snake_case			:			int				       =		MaskFormerSwinModelTester(self )
          _snake_case			:			Dict				       =		ConfigTester(self  ,       config_class=_A  ,       embed_dim=37 )




      @require_torch_multi_gpu
      @unittest.skip(
          reason=(
              '`MaskFormerSwinModel` outputs `hidden_states_spatial_dimensions` which doesn\'t work well with'
              ' `nn.DataParallel`'
          ) )
      def 						__UpperCAmelCase      (       self			:		List[str] ):



          """simple docstring"""





          pass




      def 						__UpperCAmelCase      (       self			:		Optional[Any] ):



          """simple docstring"""





          self.create_and_test_config_common_properties()
          self.config_tester.create_and_test_config_to_json_string()
          self.config_tester.create_and_test_config_to_json_file()
          self.config_tester.create_and_test_config_from_and_save_pretrained()
          self.config_tester.create_and_test_config_with_num_labels()
          self.config_tester.check_config_can_be_init_without_params()
          self.config_tester.check_config_arguments_init()




      def 						__UpperCAmelCase      (       self			:		Tuple ):



          """simple docstring"""





          return




      def 						__UpperCAmelCase      (       self			:		int ):



          """simple docstring"""





          _snake_case			:			Any				       =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*_A )




      def 						__UpperCAmelCase      (       self			:		Optional[int] ):



          """simple docstring"""





          _snake_case			:			List[str]				       =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_backbone(*_A )




      @unittest.skip('Swin does not use inputs_embeds' )
      def 						__UpperCAmelCase      (       self			:		Dict ):



          """simple docstring"""





          pass




      @unittest.skip('Swin does not support feedforward chunking' )
      def 						__UpperCAmelCase      (       self			:		int ):



          """simple docstring"""





          pass




      def 						__UpperCAmelCase      (       self			:		Tuple ):



          """simple docstring"""





          _snake_case			:			List[str]				       =		self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
              _snake_case			:			str				       =		model_class(_A )
              self.assertIsInstance(model.get_input_embeddings()  ,       (nn.Module) )
              _snake_case			:			Tuple				       =		model.get_output_embeddings()
              self.assertTrue(x is None or isinstance(_A  ,       nn.Linear ) )




      def 						__UpperCAmelCase      (       self			:		Tuple ):



          """simple docstring"""





          _snake_case			:			Tuple				       =		self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
              _snake_case			:			Optional[Any]				       =		model_class(_A )
              _snake_case			:			Dict				       =		inspect.signature(model.forward )
              # signature.parameters is an OrderedDict => so arg_names order is deterministic
              _snake_case			:			List[Any]				       =		[*signature.parameters.keys()]

              _snake_case			:			Union[str, Any]				       =		['''pixel_values''']
              self.assertListEqual(arg_names[:1]  ,       _A )




      @unittest.skip(reason='MaskFormerSwin is only used as backbone and doesn\'t support output_attentions' )
      def 						__UpperCAmelCase      (       self			:		Any ):



          """simple docstring"""





          pass




      @unittest.skip(reason='MaskFormerSwin is only used as an internal backbone' )
      def 						__UpperCAmelCase      (       self			:		int ):



          """simple docstring"""





          pass




      def 						__UpperCAmelCase      (       self			:		Dict  ,       snake_case			:		Any  ,       snake_case			:		Dict  ,       snake_case			:		Optional[Any]  ,       snake_case			:		Union[str, Any] ):



          """simple docstring"""





          _snake_case			:			Optional[Any]				       =		model_class(_A )
          model.to(_A )
          model.eval()

          with torch.no_grad():
              _snake_case			:			List[Any]				       =		model(**self._prepare_for_class(_A  ,       _A ) )

          _snake_case			:			Optional[int]				       =		outputs.hidden_states

          _snake_case			:			str				       =		getattr(
              self.model_tester  ,       'expected_num_hidden_layers'  ,       len(self.model_tester.depths ) + 1 )
          self.assertEqual(len(_A )  ,       _A )

          # Swin has a different seq_length
          _snake_case			:			List[str]				       =		(
              config.patch_size
              if isinstance(config.patch_size  ,       collections.abc.Iterable )
              else (config.patch_size, config.patch_size)
          )

          _snake_case			:			List[Any]				       =		(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

          self.assertListEqual(
              list(hidden_states[0].shape[-2:] )  ,       [num_patches, self.model_tester.embed_dim]  ,       )




      def 						__UpperCAmelCase      (       self			:		Optional[int] ):



          """simple docstring"""





          _snake_case			:			Optional[int]				       =		self.model_tester.prepare_config_and_inputs_for_common()

          _snake_case			:			Optional[Any]				       =		(
              self.model_tester.image_size
              if isinstance(self.model_tester.image_size  ,       collections.abc.Iterable )
              else (self.model_tester.image_size, self.model_tester.image_size)
          )

          for model_class in self.all_model_classes:
              _snake_case			:			List[Any]				       =		True
              self.check_hidden_states_output(_A  ,       _A  ,       _A  ,       _A )

              # check that output_hidden_states also work using config
              del inputs_dict["output_hidden_states"]
              _snake_case			:			List[Any]				       =		True

              self.check_hidden_states_output(_A  ,       _A  ,       _A  ,       _A )




      def 						__UpperCAmelCase      (       self			:		Optional[Any] ):



          """simple docstring"""





          _snake_case			:			Dict				       =		self.model_tester.prepare_config_and_inputs_for_common()
          _snake_case			:			Tuple				       =		3

          _snake_case			:			List[str]				       =		(
              self.model_tester.image_size
              if isinstance(self.model_tester.image_size  ,       collections.abc.Iterable )
              else (self.model_tester.image_size, self.model_tester.image_size)
          )
          _snake_case			:			Any				       =		(
              config.patch_size
              if isinstance(config.patch_size  ,       collections.abc.Iterable )
              else (config.patch_size, config.patch_size)
          )

          _snake_case			:			str				       =		image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
          _snake_case			:			str				       =		image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

          for model_class in self.all_model_classes:
              _snake_case			:			int				       =		True
              self.check_hidden_states_output(_A  ,       _A  ,       _A  ,       (padded_height, padded_width) )

              # check that output_hidden_states also work using config
              del inputs_dict["output_hidden_states"]
              _snake_case			:			int				       =		True
              self.check_hidden_states_output(_A  ,       _A  ,       _A  ,       (padded_height, padded_width) )




      @unittest.skip(reason='MaskFormerSwin doesn\'t have pretrained checkpoints' )
      def 						__UpperCAmelCase      (       self			:		Tuple ):



          """simple docstring"""





          pass




      @unittest.skip(reason='This will be fixed once MaskFormerSwin is replaced by native Swin' )
      def 						__UpperCAmelCase      (       self			:		List[str] ):



          """simple docstring"""





          pass




      @unittest.skip(reason='This will be fixed once MaskFormerSwin is replaced by native Swin' )
      def 						__UpperCAmelCase      (       self			:		Dict ):



          """simple docstring"""





          pass




      def 						__UpperCAmelCase      (       self			:		Optional[int] ):



          """simple docstring"""





          _snake_case			:			int				       =		self.model_tester.prepare_config_and_inputs_for_common()

          def set_nan_tensor_to_zero(snake_case			:		List[Any] ):
              _snake_case			:			str				       =		0
              return t

          def check_equivalence(snake_case			:		Dict  ,       snake_case			:		List[str]  ,       snake_case			:		int  ,       snake_case			:		List[Any]={} ):
              with torch.no_grad():
                  _snake_case			:			Any				       =		model(**_A  ,       return_dict=_A  ,       **_A )
                  _snake_case			:			List[Any]				       =		model(**_A  ,       return_dict=_A  ,       **_A ).to_tuple()

                  def recursive_check(snake_case			:		List[Any]  ,       snake_case			:		Tuple ):
                      if isinstance(_A  ,       (List, Tuple) ):
                          for tuple_iterable_value, dict_iterable_value in zip(_A  ,       _A ):
                              recursive_check(_A  ,       _A )
                      elif isinstance(_A  ,       _A ):
                          for tuple_iterable_value, dict_iterable_value in zip(
                              tuple_object.values()  ,       dict_object.values() ):
                              recursive_check(_A  ,       _A )
                      elif tuple_object is None:
                          return
                      else:
                          self.assertTrue(
                              torch.allclose(
                                  set_nan_tensor_to_zero(_A )  ,       set_nan_tensor_to_zero(_A )  ,       atol=1e-5 )  ,       msg=(
                                  'Tuple and dict output are not equal. Difference:'
                                  F""" {torch.max(torch.abs(tuple_object - dict_object ) )}. Tuple has `nan`:"""
                                  F""" {torch.isnan(_A ).any()} and `inf`: {torch.isinf(_A )}. Dict has"""
                                  F""" `nan`: {torch.isnan(_A ).any()} and `inf`: {torch.isinf(_A )}."""
                              )  ,       )

                  recursive_check(_A  ,       _A )

          for model_class in self.all_model_classes:
              _snake_case			:			Tuple				       =		model_class(_A )
              model.to(_A )
              model.eval()

              _snake_case			:			Tuple				       =		self._prepare_for_class(_A  ,       _A )
              _snake_case			:			Optional[Any]				       =		self._prepare_for_class(_A  ,       _A )
              check_equivalence(_A  ,       _A  ,       _A )

              _snake_case			:			str				       =		self._prepare_for_class(_A  ,       _A  ,       return_labels=_A )
              _snake_case			:			Optional[Any]				       =		self._prepare_for_class(_A  ,       _A  ,       return_labels=_A )
              check_equivalence(_A  ,       _A  ,       _A )

              _snake_case			:			List[str]				       =		self._prepare_for_class(_A  ,       _A )
              _snake_case			:			str				       =		self._prepare_for_class(_A  ,       _A )
              check_equivalence(_A  ,       _A  ,       _A  ,       {'output_hidden_states': True} )

              _snake_case			:			List[str]				       =		self._prepare_for_class(_A  ,       _A  ,       return_labels=_A )
              _snake_case			:			Tuple				       =		self._prepare_for_class(_A  ,       _A  ,       return_labels=_A )
              check_equivalence(_A  ,       _A  ,       _A  ,       {'output_hidden_states': True} )



@require_torch
class       SCREAMING_SNAKE_CASE       (				unittest.TestCase   ,lowercase_       ):






      '''simple docstring'''






      SCREAMING_SNAKE_CASE__			:					Optional[Any]     =					(MaskFormerSwinBackbone,) if is_torch_available() else ()
      SCREAMING_SNAKE_CASE__			:					Optional[int]     =					MaskFormerSwinConfig




      def 						__UpperCAmelCase      (       self			:		Optional[int] ):



          """simple docstring"""





          _snake_case			:			str				       =		MaskFormerSwinModelTester(self )




      def 						__UpperCAmelCase      (       self			:		int ):



          """simple docstring"""





          _snake_case			:			List[Any]				       =		self.model_tester.prepare_config_and_inputs_for_common()
          _snake_case			:			Union[str, Any]				       =		inputs_dict['''pixel_values'''].shape[0]

          for backbone_class in self.all_model_classes:
              _snake_case			:			List[str]				       =		backbone_class(_A )
              backbone.to(_A )
              backbone.eval()

              _snake_case			:			List[Any]				       =		backbone(**_A )

              # Test default outputs and verify feature maps
              self.assertIsInstance(outputs.feature_maps  ,       _A )
              self.assertTrue(len(outputs.feature_maps ) == len(backbone.channels ) )
              for feature_map, n_channels in zip(outputs.feature_maps  ,       backbone.channels ):
                  self.assertTrue(feature_map.shape[:2]  ,       (batch_size, n_channels) )
              self.assertIsNone(outputs.hidden_states )
              self.assertIsNone(outputs.attentions )

              # Test output_hidden_states=True
              _snake_case			:			Dict				       =		backbone(**_A  ,       output_hidden_states=_A )
              self.assertIsNotNone(outputs.hidden_states )
              self.assertTrue(len(outputs.hidden_states )  ,       len(backbone.stage_names ) )
              # We skip the stem layer
              for hidden_states, n_channels in zip(outputs.hidden_states[1:]  ,       backbone.channels ):
                  for hidden_state in hidden_states:
                      # Hidden states are in the format (batch_size, (height * width), n_channels)
                      _snake_case			:			Union[str, Any]				       =		hidden_state.shape
                      self.assertTrue((h_batch_size, h_n_channels)  ,       (batch_size, n_channels) )

            # Test output_attentions=True
              if self.has_attentions:
                  _snake_case			:			Union[str, Any]				       =		backbone(**_A  ,       output_attentions=_A )
                  self.assertIsNotNone(outputs.attentions )











'''simple docstring'''





import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
						import torch

						from transformers.generation import DisjunctiveConstraint


@require_torch
class  snake_case__      (					unittest.TestCase):




					def 		A      (  self  :		Union[str, Any]      )    ->							List[str]:
								# For consistency across different places the DisjunctiveConstraint is called,
								# dc.token_ids is a list of integers. It is also initialized only by integers.

								UpperCAmelCase_      :       Union[str, Any]          =       [[1, 2, 4], [1, 2, 3, 4]]
								UpperCAmelCase_      :       Dict          =       DisjunctiveConstraint(_A      )
								self.assertTrue(isinstance(dc.token_ids				, _A      )      )

								with self.assertRaises(_A      ):
											DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]      )      )

								with self.assertRaises(_A      ):
											DisjunctiveConstraint([torch.LongTensor([1, 2, 4]      ), torch.LongTensor([1, 2, 3, 4, 5]      )]      )




					def 		A      (  self  :		Optional[int]      )    ->							List[Any]:
								# We can't have constraints that are complete subsets of another. This leads to a preverse
								# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
								# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
								# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
								# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
								UpperCAmelCase_      :       Optional[Any]          =       [[1, 2], [1, 2, 3, 4]]

								with self.assertRaises(_A      ):
											DisjunctiveConstraint(_A      )  # fails here




					def 		A      (  self  :		List[str]      )    ->							int:
								UpperCAmelCase_      :       Dict          =       [[1, 2, 3], [1, 2, 4]]

								UpperCAmelCase_      :       List[Any]          =       DisjunctiveConstraint(_A      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       List[str]          =       dc.update(1      )
								UpperCAmelCase_      :       int          =       stepped is True and completed is False and reset is False
								self.assertTrue(_A      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Tuple          =       dc.update(2      )
								UpperCAmelCase_      :       Optional[int]          =       stepped is True and completed is False and reset is False
								self.assertTrue(_A      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Any          =       dc.update(3      )
								UpperCAmelCase_      :       List[Any]          =       stepped is True and completed is True and reset is False
								self.assertTrue(_A      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.current_seq == [1, 2, 3]      )





					def 		A      (  self  :		List[Any]      )    ->							Any:
								UpperCAmelCase_      :       int          =       [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

								UpperCAmelCase_      :       str          =       DisjunctiveConstraint(_A      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Tuple          =       dc.update(1      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       str          =       dc.update(2      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       str          =       dc.update(4      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2, 4]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Any          =       dc.update(5      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.current_seq == [1, 2, 4, 5]      )

								dc.reset()

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       List[str]          =       dc.update(1      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.remaining() == 3      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Optional[int]          =       dc.update(2      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.remaining() == 2      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       int          =       dc.update(5      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.remaining() == 0      )
								self.assertTrue(dc.current_seq == [1, 2, 5]      )


