

import unittest

from transformers import FunnelConfig, FunnelTokenizer, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch

       from transformers import (
           MODEL_FOR_PRETRAINING_MAPPING,
           FunnelBaseModel,
           FunnelForMaskedLM,
           FunnelForMultipleChoice,
           FunnelForPreTraining,
           FunnelForQuestionAnswering,
           FunnelForSequenceClassification,
           FunnelForTokenClassification,
           FunnelModel,
       )







class 		__magic_name__     :

   '''simple docstring'''




   def __init__(							self,       lowercase_,       lowercase_=13,       lowercase_=7,       lowercase_=True,       lowercase_=True,       lowercase_=True,       lowercase_=True,       lowercase_=99,       lowercase_=[1, 1, 2],       lowercase_=1,       lowercase_=32,       lowercase_=4,       lowercase_=8,       lowercase_=37,       lowercase_="gelu_new",       lowercase_=0.1,       lowercase_=0.1,       lowercase_=0.0,       lowercase_=512,       lowercase_=3,       lowercase_=0.02,       lowercase_=3,       lowercase_=4,       lowercase_=None,       lowercase_=False,       )				->       List[Any]:






     """simple docstring"""






     a__    =parent
     a__    =batch_size
     a__    =seq_length
     a__    =is_training
     a__    =use_input_mask
     a__    =use_token_type_ids
     a__    =use_labels
     a__    =vocab_size
     a__    =block_sizes
     a__    =num_decoder_layers
     a__    =d_model
     a__    =n_head
     a__    =d_head
     a__    =d_inner
     a__    =hidden_act
     a__    =hidden_dropout
     a__    =attention_dropout
     a__    =activation_dropout
     a__    =max_position_embeddings
     a__    =type_vocab_size
     a__    =2
     a__    =num_labels
     a__    =num_choices
     a__    =scope
     a__    =initializer_std

     # Used in the tests to check the size of the first attention layer
     a__    =n_head
     # Used in the tests to check the size of the first hidden state
     a__    =self.d_model
     # Used in the tests to check the number of output hidden states/attentions
     a__    =sum(self.block_sizes			) + (0 if base else self.num_decoder_layers)
     # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
     # the last hidden state of the first block (which is the first hidden state of the decoder).
     if not base:
       a__    =self.num_hidden_layers + 2



   def 					_UpperCAmelCase					(							self			)				->       Tuple:






     """simple docstring"""






     a__    =ids_tensor([self.batch_size, self.seq_length],       self.vocab_size			)

     a__    =None
     if self.use_input_mask:
       a__    =ids_tensor([self.batch_size, self.seq_length],       vocab_size=2			)

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

     a__    =None
     a__    =None
     a__    =None
     if self.use_labels:
       a__    =ids_tensor([self.batch_size],       self.type_sequence_label_size			)
       a__    =ids_tensor([self.batch_size, self.seq_length],       self.num_labels			)
       a__    =ids_tensor([self.batch_size],       self.num_choices			)
       a__    =ids_tensor([self.batch_size, self.seq_length],       1			)

     a__    =self.get_config()

     return (
         config,
         input_ids,
         token_type_ids,
         input_mask,
         sequence_labels,
         token_labels,
         choice_labels,
         fake_token_labels,
     )



   def 					_UpperCAmelCase					(							self			)				->       Optional[int]:






     """simple docstring"""






     return FunnelConfig(
         vocab_size=self.vocab_size,       block_sizes=self.block_sizes,       num_decoder_layers=self.num_decoder_layers,       d_model=self.d_model,       n_head=self.n_head,       d_head=self.d_head,       d_inner=self.d_inner,       hidden_act=self.hidden_act,       hidden_dropout=self.hidden_dropout,       attention_dropout=self.attention_dropout,       activation_dropout=self.activation_dropout,       max_position_embeddings=self.max_position_embeddings,       type_vocab_size=self.type_vocab_size,       initializer_std=self.initializer_std,       )



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       List[Any]:






     """simple docstring"""






     a__    =FunnelModel(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_			)
     a__    =model(lowercase_,       token_type_ids=lowercase_			)
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, self.seq_length, self.d_model)			)

     a__    =False
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, self.seq_length, self.d_model)			)

     a__    =False
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, self.seq_length, self.d_model)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       str:






     """simple docstring"""






     a__    =FunnelBaseModel(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_			)
     a__    =model(lowercase_,       token_type_ids=lowercase_			)
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, 2, self.d_model)			)

     a__    =False
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, 3, self.d_model)			)

     a__    =False
     a__    =model(lowercase_			)
     self.parent.assertEqual(result.last_hidden_state.shape,       (self.batch_size, 2, self.d_model)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       Tuple:






     """simple docstring"""






     a__    =self.num_labels
     a__    =FunnelForPreTraining(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       labels=lowercase_			)
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.seq_length)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       Tuple:






     """simple docstring"""






     a__    =FunnelForMaskedLM(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       labels=lowercase_			)
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.seq_length, self.vocab_size)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       Optional[Any]:






     """simple docstring"""






     a__    =self.num_labels
     a__    =FunnelForSequenceClassification(lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       labels=lowercase_			)
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.num_labels)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       Dict:






     """simple docstring"""






     a__    =self.num_choices
     a__    =FunnelForMultipleChoice(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =input_ids.unsqueeze(1			).expand(-1,       self.num_choices,       -1			).contiguous()
     a__    =token_type_ids.unsqueeze(1			).expand(-1,       self.num_choices,       -1			).contiguous()
     a__    =input_mask.unsqueeze(1			).expand(-1,       self.num_choices,       -1			).contiguous()
     a__    =model(
         lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       labels=lowercase_,       )
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.num_choices)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       List[str]:






     """simple docstring"""






     a__    =self.num_labels
     a__    =FunnelForTokenClassification(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       labels=lowercase_			)
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.seq_length, self.num_labels)			)



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       lowercase_,       )				->       Dict:






     """simple docstring"""






     a__    =FunnelForQuestionAnswering(config=lowercase_			)
     model.to(lowercase_			)
     model.eval()
     a__    =model(
         lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_,       start_positions=lowercase_,       end_positions=lowercase_,       )
     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)			)



   def 					_UpperCAmelCase					(							self			)				->       Union[str, Any]:






     """simple docstring"""






     a__    =self.prepare_config_and_inputs()
     (
         a__      
     )    =config_and_inputs
     a__    ={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
     return config, inputs_dict







@require_torch
class 		__magic_name__     (				lowerCamelCase__						,			lowerCamelCase__						,			unittest.TestCase				):

   '''simple docstring'''




   lowerCamelCase__					:      Optional[int]        =  False
   lowerCamelCase__					:      Optional[Any]        =  False
   lowerCamelCase__					:      int        =  (
       (
           FunnelModel,
           FunnelForMaskedLM,
           FunnelForPreTraining,
           FunnelForQuestionAnswering,
           FunnelForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   lowerCamelCase__					:      List[Any]        =  (
       {
           "feature-extraction": (FunnelBaseModel, FunnelModel),
           "fill-mask": FunnelForMaskedLM,
           "question-answering": FunnelForQuestionAnswering,
           "text-classification": FunnelForSequenceClassification,
           "token-classification": FunnelForTokenClassification,
           "zero-shot": FunnelForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )



   def 					_UpperCAmelCase					(							self,       lowercase_,       lowercase_,       lowercase_=False			)				->       Union[str, Any]:






     """simple docstring"""






     a__    =super()._prepare_for_class(lowercase_,       lowercase_,       return_labels=lowercase_			)

     if return_labels:
       if model_class in get_values(lowercase_			):
         a__    =torch.zeros(
             (self.model_tester.batch_size, self.model_tester.seq_length),       dtype=torch.long,       device=lowercase_			)
     return inputs_dict



   def 					_UpperCAmelCase					(							self			)				->       Tuple:






     """simple docstring"""






     a__    =FunnelModelTester(self			)
     a__    =ConfigTester(self,       config_class=lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       List[Any]:






     """simple docstring"""






     self.config_tester.run_common_tests()



   def 					_UpperCAmelCase					(							self			)				->       Tuple:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Optional[Any]:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_pretraining(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       int:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       int:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Tuple:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_question_answering(*lowercase_			)



   def 					_UpperCAmelCase					(							self,       lowercase_			)				->       int:






     """simple docstring"""






     if hasattr(lowercase_,       '''weight'''			) and module.weight is not None:
       module.weight.data.fill_(3			)
     if hasattr(lowercase_,       '''bias'''			) and module.bias is not None:
       module.bias.data.fill_(3			)

     for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
       if hasattr(lowercase_,       lowercase_			) and getattr(lowercase_,       lowercase_			) is not None:
         a__    =getattr(lowercase_,       lowercase_			)
         weight.data.fill_(3			)







@require_torch
class 		__magic_name__     (				lowerCamelCase__						,			unittest.TestCase				):

   '''simple docstring'''




   lowerCamelCase__					:      Union[str, Any]        =  False
   lowerCamelCase__					:      Optional[Any]        =  False
   lowerCamelCase__					:      Tuple        =  (
       (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
   )



   def 					_UpperCAmelCase					(							self			)				->       List[str]:






     """simple docstring"""






     a__    =FunnelModelTester(self,       base=lowercase_			)
     a__    =ConfigTester(self,       config_class=lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Union[str, Any]:






     """simple docstring"""






     self.config_tester.run_common_tests()



   def 					_UpperCAmelCase					(							self			)				->       Any:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_base_model(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Any:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Optional[int]:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_multiple_choice(*lowercase_			)



   def 					_UpperCAmelCase					(							self			)				->       Dict:






     """simple docstring"""






     a__    =self.model_tester.prepare_config_and_inputs_for_common()
     a__    =True

     for model_class in self.all_model_classes:
       if model_class.__name__ == "FunnelBaseModel":
         continue
       a__    =model_class(lowercase_			)
       model.to(lowercase_			)
       model.train()
       a__    =self._prepare_for_class(lowercase_,       lowercase_,       return_labels=lowercase_			)
       a__    =model(**lowercase_			).loss
       loss.backward()



   def 					_UpperCAmelCase					(							self,       lowercase_			)				->       Union[str, Any]:






     """simple docstring"""






     if hasattr(lowercase_,       '''weight'''			) and module.weight is not None:
       module.weight.data.fill_(3			)
     if hasattr(lowercase_,       '''bias'''			) and module.bias is not None:
       module.bias.data.fill_(3			)

     for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
       if hasattr(lowercase_,       lowercase_			) and getattr(lowercase_,       lowercase_			) is not None:
         a__    =getattr(lowercase_,       lowercase_			)
         weight.data.fill_(3			)







@require_torch
@require_sentencepiece
@require_tokenizers
class 		__magic_name__     (				unittest.TestCase				):

   '''simple docstring'''




   def 					_UpperCAmelCase					(							self			)				->       int:






     """simple docstring"""






     a__    =13
     a__    =7
     a__    =torch.arange(0,       batch_size * sequence_length			).long().reshape(lowercase_,       lowercase_			)
     a__    =[0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
     a__    =torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]			)

     a__    =FunnelModel.from_pretrained('''sgugger/funnel-random-tiny'''			)
     a__    =model(lowercase_,       token_type_ids=lowercase_			)[0].abs()

     a__    =torch.tensor(2344.8352			)
     a__    =torch.tensor(0.8052			)
     self.assertTrue(torch.allclose(output.sum(),       lowercase_,       atol=1E-4			)			)
     self.assertTrue(torch.allclose(output.mean(),       lowercase_,       atol=1E-4			)			)

     a__    =torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]			)
     a__    =model(lowercase_,       attention_mask=lowercase_,       token_type_ids=lowercase_			)[0].abs()

     a__    =torch.tensor(2343.8425			)
     a__    =torch.tensor(0.8049			)
     self.assertTrue(torch.allclose(output.sum(),       lowercase_,       atol=1E-4			)			)
     self.assertTrue(torch.allclose(output.mean(),       lowercase_,       atol=1E-4			)			)



   @slow
   def 					_UpperCAmelCase					(							self			)				->       Optional[int]:






     """simple docstring"""






     a__    =FunnelTokenizer.from_pretrained('''huggingface/funnel-small'''			)
     a__    =FunnelModel.from_pretrained('''huggingface/funnel-small'''			)
     a__    =tokenizer('''Hello! I am the Funnel Transformer model.''',       return_tensors='''pt'''			)
     a__    =model(**lowercase_			)[0]

     a__    =torch.tensor(235.7246			)
     a__    =torch.tensor(0.0256			)
     self.assertTrue(torch.allclose(output.sum(),       lowercase_,       atol=1E-4			)			)
     self.assertTrue(torch.allclose(output.mean(),       lowercase_,       atol=1E-4			)			)

'''simple docstring'''
import unittest
from functools import partial

import torch

from accelerate import Accelerator, debug_launcher
from accelerate.state import AcceleratorState, GradientState
from accelerate.test_utils import require_cpu, require_huggingface_suite
from accelerate.utils import GradientAccumulationPlugin







def 				__UpperCamelCase (					__UpperCAmelCase  :					List[Any]=2 ,   __UpperCAmelCase  :					Dict=True ,   __UpperCAmelCase  :					str=False			)							->	List[Any]:
  lowercase				:							Tuple									=   Accelerator(step_scheduler_with_optimizer=__UpperCAmelCase ,   split_batches=__UpperCAmelCase			)
  lowercase				:							Optional[int]									=   torch.nn.Linear(2 ,   4			)
  lowercase				:							Dict									=   torch.optim.AdamW(model.parameters() ,   lr=1.0			)
  lowercase				:							List[Any]									=   torch.optim.lr_scheduler.OneCycleLR(__UpperCAmelCase ,   max_lr=0.01 ,   steps_per_epoch=2 ,   epochs=1			)
  lowercase				,      lowercase				,      lowercase				:							Optional[Any]									=   accelerator.prepare(__UpperCAmelCase ,   __UpperCAmelCase ,   __UpperCAmelCase			)

  # Optimizer has stepped
  scheduler.step()
  if step_scheduler_with_optimizer or (num_processes == 1):
    assert (
        scheduler.scheduler.last_epoch == num_processes
    ), f"""Last Epoch ({scheduler.scheduler.last_epoch}) != Num Processes ({num_processes})"""
  else:
    assert (
        scheduler.scheduler.last_epoch != num_processes
    ), f"""Last Epoch ({scheduler.scheduler.last_epoch}) == Num Processes ({num_processes})"""







def 				__UpperCamelCase (					__UpperCAmelCase  :					str=2 ,   __UpperCAmelCase  :					str=True ,   __UpperCAmelCase  :					Tuple=False			)							->	str:
  lowercase				:							List[Any]									=   Accelerator(step_scheduler_with_optimizer=__UpperCAmelCase ,   split_batches=__UpperCAmelCase			)
  lowercase				:							Optional[Any]									=   torch.nn.Linear(2 ,   4			)
  lowercase				:							List[str]									=   torch.optim.AdamW(model.parameters() ,   lr=1.0			)
  lowercase				:							Dict									=   torch.optim.lr_scheduler.LambdaLR(__UpperCAmelCase ,   lr_lambda=lambda __UpperCAmelCase			: 1 - n / 10			)
  lowercase				,      lowercase				,      lowercase				:							int									=   accelerator.prepare(__UpperCAmelCase ,   __UpperCAmelCase ,   __UpperCAmelCase			)

  # Optimizer has stepped
  lowercase				:							Any									=   False
  scheduler.step()
  lowercase				:							Optional[Any]									=   1 - (num_processes if (step_scheduler_with_optimizer and not split_batches) else 1) / 10
  assert (
      scheduler.get_last_lr()[0] == expected_lr
  ), f"""Wrong lr found at first step, expected {expected_lr}, got {scheduler.get_last_lr()[0]}"""

  # Optimizer has not stepped
  lowercase				:							List[Any]									=   True
  scheduler.step()
  if not step_scheduler_with_optimizer:
    lowercase				:							List[Any]									=   1 - 2 / 10
  assert (
      scheduler.get_last_lr()[0] == expected_lr
  ), f"""Wrong lr found at second step, expected {expected_lr}, got {scheduler.get_last_lr()[0]}"""







def 				__UpperCamelCase (					__UpperCAmelCase  :					int = 2			)							->	Dict:
  from transformers import get_linear_schedule_with_warmup

  lowercase				:							Optional[Any]									=   [1, 2, 4]
  for num_steps in steps:
    lowercase				:							Dict									=   GradientAccumulationPlugin(num_steps=__UpperCAmelCase ,   adjust_scheduler=num_steps > 1			)
    lowercase				:							Tuple									=   Accelerator(gradient_accumulation_plugin=__UpperCAmelCase			)
    lowercase				:							str									=   torch.nn.Linear(2 ,   4			)
    lowercase				:							Dict									=   torch.optim.AdamW(model.parameters() ,   lr=10.0			)
    lowercase				:							List[str]									=   get_linear_schedule_with_warmup(optimizer=__UpperCAmelCase ,   num_warmup_steps=0 ,   num_training_steps=20			)

    lowercase				,      lowercase				,      lowercase				:							Dict									=   accelerator.prepare(__UpperCAmelCase ,   __UpperCAmelCase ,   __UpperCAmelCase			)

    for i in range(10 * num_steps			):
      with accelerator.accumulate(__UpperCAmelCase			):
        optimizer.step()
        scheduler.step()

      if i == (10 * num_steps - 2):
        assert (
            scheduler.get_last_lr()[0] != 0
        ), f"""Wrong lr found at second-to-last step, expected non-zero, got {scheduler.get_last_lr()[0]}. num_steps: {num_steps}"""
    assert (
        scheduler.get_last_lr()[0] == 0
    ), f"""Wrong lr found at last step, expected 0, got {scheduler.get_last_lr()[0]}"""
    GradientState._reset_state()






@require_cpu
class _lowerCAmelCase			(	unittest.TestCase					):







      def      lowerCamelCase__      (  self     ):
        debug_launcher(partial(lowercase  ,    num_processes=1     )  ,    num_processes=1     )
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    split_batches=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        debug_launcher(partial(lowercase  ,    num_processes=1     )  ,    num_processes=1     )
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    split_batches=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    step_scheduler_with_optimizer=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    step_scheduler_with_optimizer=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        AcceleratorState._reset_state(lowercase     )
        debug_launcher(lowercase     )
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    split_batches=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        AcceleratorState._reset_state(lowercase     )
        debug_launcher(lowercase     )
        debug_launcher(partial(lowercase  ,    num_processes=1  ,    split_batches=lowercase     )  ,    num_processes=1     )







      def      lowerCamelCase__      (  self     ):
        AcceleratorState._reset_state(lowercase     )
        debug_launcher(partial(lowercase  ,    step_scheduler_with_optimizer=lowercase     )     )







      def      lowerCamelCase__      (  self     ):
        AcceleratorState._reset_state(lowercase     )
        debug_launcher(partial(lowercase  ,    step_scheduler_with_optimizer=lowercase     )     )







      @require_huggingface_suite
      def      lowerCamelCase__      (  self     ):
        AcceleratorState._reset_state(lowercase     )
        debug_launcher(partial(lowercase  ,    num_processes=1     )     )
        debug_launcher(lowercase     )