



'''simple docstring'''





import argparse
import logging
import os
from pathlib import Path
from typing import Any, Dict

import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info

from transformers import (
    AdamW,
    AutoConfig,
    AutoModel,
    AutoModelForPreTraining,
    AutoModelForQuestionAnswering,
    AutoModelForSeqaSeqLM,
    AutoModelForSequenceClassification,
    AutoModelForTokenClassification,
    AutoModelWithLMHead,
    AutoTokenizer,
    PretrainedConfig,
    PreTrainedTokenizer,
)
from transformers.optimization import (
    Adafactor,
    get_cosine_schedule_with_warmup,
    get_cosine_with_hard_restarts_schedule_with_warmup,
    get_linear_schedule_with_warmup,
    get_polynomial_decay_schedule_with_warmup,
)
from transformers.utils.versions import require_version


UpperCamelCase__    :     Tuple			  =   logging.getLogger(__name__)

require_version('pytorch_lightning>=1.0.4')

UpperCamelCase__    :     List[Any]			  =   {
    'base': AutoModel,
    'sequence-classification': AutoModelForSequenceClassification,
    'question-answering': AutoModelForQuestionAnswering,
    'pretraining': AutoModelForPreTraining,
    'token-classification': AutoModelForTokenClassification,
    'language-modeling': AutoModelWithLMHead,
    'summarization': AutoModelForSeqaSeqLM,
    'translation': AutoModelForSeqaSeqLM,
}


# update this and the import above to support new schedulers from transformers.optimization
UpperCamelCase__    :     int			  =   {
    'linear': get_linear_schedule_with_warmup,
    'cosine': get_cosine_schedule_with_warmup,
    'cosine_w_restarts': get_cosine_with_hard_restarts_schedule_with_warmup,
    'polynomial': get_polynomial_decay_schedule_with_warmup,
    # '': get_constant_schedule,             # not supported for now
    # '': get_constant_schedule_with_warmup, # not supported for now
}
UpperCamelCase__    :     str			  =   sorted(arg_to_scheduler.keys())
UpperCamelCase__    :     Union[str, Any]			  =   '{' + ', '.join(arg_to_scheduler_choices) + '}'


class 							_lowerCAmelCase	(  pl.LightningModule							):


 """simple docstring"""

 def __init__(      self					,    _lowerCamelCase					,    _lowerCamelCase=None					,    _lowerCamelCase="base"					,    _lowerCamelCase=None					,    _lowerCamelCase=None					,    _lowerCamelCase=None					,    **_lowerCamelCase					,    )    ->    str:
    super().__init__()
    # TODO: move to self.save_hyperparameters()
    # self.save_hyperparameters()
    # can also expand arguments into trainer signature for easier reading

    self.save_hyperparameters(_lowerCamelCase  )
    A_  :		Tuple						=					0
    A_  :		str						=					Path(self.hparams.output_dir  )
    A_  :		Any						=					self.hparams.cache_dir if self.hparams.cache_dir else None
    if config is None:
       A_  :		Optional[Any]						=					AutoConfig.from_pretrained(
           self.hparams.config_name if self.hparams.config_name else self.hparams.model_name_or_path					,    **({"""num_labels""": num_labels} if num_labels is not None else {})					,    cache_dir=_lowerCamelCase					,    **_lowerCamelCase					,    )
    else:
       A_  :		PretrainedConfig						=					config

    A_  :		Dict						=					("""encoder_layerdrop""", """decoder_layerdrop""", """dropout""", """attention_dropout""")
    for p in extra_model_params:
       if getattr(self.hparams					,    _lowerCamelCase					,    _lowerCamelCase  ):
          assert hasattr(self.config					,    _lowerCamelCase  ), F"model config doesn't have a `{p}` attribute"
          setattr(self.config					,    _lowerCamelCase					,    getattr(self.hparams					,    _lowerCamelCase  )  )

    if tokenizer is None:
       A_  :		Union[str, Any]						=					AutoTokenizer.from_pretrained(
           self.hparams.tokenizer_name if self.hparams.tokenizer_name else self.hparams.model_name_or_path					,    cache_dir=_lowerCamelCase					,    )
    else:
       A_  :		PreTrainedTokenizer						=					tokenizer
    A_  :		Union[str, Any]						=					MODEL_MODES[mode]
    if model is None:
       A_  :		Tuple						=					self.model_type.from_pretrained(
           self.hparams.model_name_or_path					,    from_tf=bool(""".ckpt""" in self.hparams.model_name_or_path  )					,    config=self.config					,    cache_dir=_lowerCamelCase					,    )
    else:
       A_  :		Any						=					model







 def       UpperCAmelCase_       (      self					,    *_lowerCamelCase					,    **_lowerCamelCase  )    ->    str:
    A_  :		Optional[int]						=					self.model_type.from_pretrained(*_lowerCamelCase					,    **_lowerCamelCase  )







 def       UpperCAmelCase_       (      self  )    ->    int:
    A_  :		Dict						=					arg_to_scheduler[self.hparams.lr_scheduler]
    A_  :		Optional[int]						=					get_schedule_func(
        self.opt					,    num_warmup_steps=self.hparams.warmup_steps					,    num_training_steps=self.total_steps()  )
    A_  :		Union[str, Any]						=					{"""scheduler""": scheduler, """interval""": """step""", """frequency""": 1}
    return scheduler







 def       UpperCAmelCase_       (      self  )    ->    Any:
    A_  :		int						=					self.model
    A_  :		List[Any]						=					["""bias""", """LayerNorm.weight"""]
    A_  :		str						=					[
        {
            """params""": [p for n, p in model.named_parameters() if not any(nd in n for nd in no_decay  )],
            """weight_decay""": self.hparams.weight_decay,
        },
        {
            """params""": [p for n, p in model.named_parameters() if any(nd in n for nd in no_decay  )],
            """weight_decay""": 0.0,
        },
    ]
    if self.hparams.adafactor:
       A_  :		str						=					Adafactor(
           _lowerCamelCase					,    lr=self.hparams.learning_rate					,    scale_parameter=_lowerCamelCase					,    relative_step=_lowerCamelCase  )

    else:
       A_  :		List[Any]						=					AdamW(
           _lowerCamelCase					,    lr=self.hparams.learning_rate					,    eps=self.hparams.adam_epsilon  )
    A_  :		List[Any]						=					optimizer

    A_  :		Tuple						=					self.get_lr_scheduler()

    return [optimizer], [scheduler]







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase  )    ->    Union[str, Any]:
    return self.validation_step(_lowerCamelCase					,    _lowerCamelCase  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    Any:
    return self.validation_end(_lowerCamelCase  )







 def       UpperCAmelCase_       (      self  )    ->    int:
    A_  :		int						=					max(1					,    self.hparams.gpus  )  # TODO: consider num_tpu_cores
    A_  :		str						=					self.hparams.train_batch_size * self.hparams.accumulate_grad_batches * num_devices
    return (self.dataset_size / effective_batch_size) * self.hparams.max_epochs







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    List[str]:
    if mode == "test":
       A_  :		Optional[int]						=					len(self.test_dataloader().dataset  )
    else:
       A_  :		str						=					self.get_dataloader("""train"""					,    self.hparams.train_batch_size					,    shuffle=_lowerCamelCase  )
       A_  :		Tuple						=					len(self.train_dataloader().dataset  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase					,    _lowerCamelCase = False  )    ->    Tuple:
    raise NotImplementedError("""You must implement this for your task"""  )







 def       UpperCAmelCase_       (      self  )    ->    Optional[Any]:
    return self.train_loader







 def       UpperCAmelCase_       (      self  )    ->    Union[str, Any]:
    return self.get_dataloader("""dev"""					,    self.hparams.eval_batch_size					,    shuffle=_lowerCamelCase  )







 def       UpperCAmelCase_       (      self  )    ->    List[str]:
    return self.get_dataloader("""test"""					,    self.hparams.eval_batch_size					,    shuffle=_lowerCamelCase  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    List[Any]:
    return os.path.join(
        self.hparams.data_dir					,    """cached_{}_{}_{}""".format(
            _lowerCamelCase					,    list(filter(_lowerCamelCase					,    self.hparams.model_name_or_path.split("""/"""  )  )  ).pop()					,    str(self.hparams.max_seq_length  )					,    )					,    )







 @pl.utilities.rank_zero_only
 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    None:
    A_  :		Any						=					self.output_dir.joinpath("""best_tfmr"""  )
    A_  :		int						=					self.step_count
    self.model.save_pretrained(_lowerCamelCase  )
    self.tokenizer.save_pretrained(_lowerCamelCase  )







 @staticmethod
 def       UpperCAmelCase_       (      _lowerCamelCase					,    _lowerCamelCase  )    ->    List[str]:
    parser.add_argument(
        """--model_name_or_path"""					,    default=_lowerCamelCase					,    type=_lowerCamelCase					,    required=_lowerCamelCase					,    help="""Path to pretrained model or model identifier from huggingface.co/models"""					,    )
    parser.add_argument(
        """--config_name"""					,    default=""""""					,    type=_lowerCamelCase					,    help="""Pretrained config name or path if not the same as model_name"""  )
    parser.add_argument(
        """--tokenizer_name"""					,    default=_lowerCamelCase					,    type=_lowerCamelCase					,    help="""Pretrained tokenizer name or path if not the same as model_name"""					,    )
    parser.add_argument(
        """--cache_dir"""					,    default=""""""					,    type=_lowerCamelCase					,    help="""Where do you want to store the pre-trained models downloaded from huggingface.co"""					,    )
    parser.add_argument(
        """--encoder_layerdrop"""					,    type=_lowerCamelCase					,    help="""Encoder layer dropout probability (Optional). Goes into model.config"""					,    )
    parser.add_argument(
        """--decoder_layerdrop"""					,    type=_lowerCamelCase					,    help="""Decoder layer dropout probability (Optional). Goes into model.config"""					,    )
    parser.add_argument(
        """--dropout"""					,    type=_lowerCamelCase					,    help="""Dropout probability (Optional). Goes into model.config"""					,    )
    parser.add_argument(
        """--attention_dropout"""					,    type=_lowerCamelCase					,    help="""Attention dropout probability (Optional). Goes into model.config"""					,    )
    parser.add_argument("""--learning_rate"""					,    default=5e-5					,    type=_lowerCamelCase					,    help="""The initial learning rate for Adam."""  )
    parser.add_argument(
        """--lr_scheduler"""					,    default="""linear"""					,    choices=_lowerCamelCase					,    metavar=_lowerCamelCase					,    type=_lowerCamelCase					,    help="""Learning rate scheduler"""					,    )
    parser.add_argument("""--weight_decay"""					,    default=0.0					,    type=_lowerCamelCase					,    help="""Weight decay if we apply some."""  )
    parser.add_argument("""--adam_epsilon"""					,    default=1e-8					,    type=_lowerCamelCase					,    help="""Epsilon for Adam optimizer."""  )
    parser.add_argument("""--warmup_steps"""					,    default=0					,    type=_lowerCamelCase					,    help="""Linear warmup over warmup_steps."""  )
    parser.add_argument("""--num_workers"""					,    default=4					,    type=_lowerCamelCase					,    help="""kwarg passed to DataLoader"""  )
    parser.add_argument("""--num_train_epochs"""					,    dest="""max_epochs"""					,    default=3					,    type=_lowerCamelCase  )
    parser.add_argument("""--train_batch_size"""					,    default=32					,    type=_lowerCamelCase  )
    parser.add_argument("""--eval_batch_size"""					,    default=32					,    type=_lowerCamelCase  )
    parser.add_argument("""--adafactor"""					,    action="""store_true"""  )


class 							_lowerCAmelCase	(  pl.Callback							):


 """simple docstring"""

 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase  )    ->    int:
    A_  :		List[Any]						=					trainer.lr_schedulers[0]["""scheduler"""]
    A_  :		Any						=					{F"lr_group_{i}": lr for i, lr in enumerate(lr_scheduler.get_lr()  )}
    pl_module.logger.log_metrics(_lowerCamelCase  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase  )    ->    List[str]:
    rank_zero_info("""***** Validation results *****"""  )
    A_  :		List[str]						=					trainer.callback_metrics
    # Log results
    for key in sorted(_lowerCamelCase  ):
       if key not in ["log", "progress_bar"]:
          rank_zero_info("""{} = {}\n""".format(_lowerCamelCase					,    str(metrics[key]  )  )  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase  )    ->    List[str]:
    rank_zero_info("""***** Test results *****"""  )
    A_  :		Tuple						=					trainer.callback_metrics
    # Log and save results to file
    A_  :		Optional[Any]						=					os.path.join(pl_module.hparams.output_dir					,    """test_results.txt"""  )
    with open(_lowerCamelCase					,    """w"""  ) as writer:
       for key in sorted(_lowerCamelCase  ):
          if key not in ["log", "progress_bar"]:
             rank_zero_info("""{} = {}\n""".format(_lowerCamelCase					,    str(metrics[key]  )  )  )
             writer.write("""{} = {}\n""".format(_lowerCamelCase					,    str(metrics[key]  )  )  )



def     UpperCAmelCase     (    a_      ,		a_		)   ->       None:



   """simple docstring"""






   parser.add_argument(
       """--output_dir"""      ,		default=a_      ,		type=a_      ,		required=a_      ,		help="""The output directory where the model predictions and checkpoints will be written."""      ,		)
   parser.add_argument(
       """--fp16"""      ,		action="""store_true"""      ,		help="""Whether to use 16-bit (mixed) precision (through NVIDIA apex) instead of 32-bit"""      ,		)

   parser.add_argument(
       """--fp16_opt_level"""      ,		type=a_      ,		default="""O2"""      ,		help=(
           """For fp16: Apex AMP optimization level selected in ['O0', 'O1', 'O2', and 'O3']."""
           """See details at https://nvidia.github.io/apex/amp.html"""
       )      ,		)
   parser.add_argument("""--n_tpu_cores"""      ,		dest="""tpu_cores"""      ,		type=a_		)
   parser.add_argument("""--max_grad_norm"""      ,		dest="""gradient_clip_val"""      ,		default=1.0      ,		type=a_      ,		help="""Max gradient norm"""		)
   parser.add_argument("""--do_train"""      ,		action="""store_true"""      ,		help="""Whether to run training."""		)
   parser.add_argument("""--do_predict"""      ,		action="""store_true"""      ,		help="""Whether to run predictions on the test set."""		)
   parser.add_argument(
       """--gradient_accumulation_steps"""      ,		dest="""accumulate_grad_batches"""      ,		type=a_      ,		default=1      ,		help="""Number of updates steps to accumulate before performing a backward/update pass."""      ,		)
   parser.add_argument("""--seed"""      ,		type=a_      ,		default=4_2      ,		help="""random seed for initialization"""		)
   parser.add_argument(
       """--data_dir"""      ,		default=a_      ,		type=a_      ,		required=a_      ,		help="""The input data dir. Should contain the training files for the CoNLL-2003 NER task."""      ,		)







def     UpperCAmelCase     (    a_      ,		a_      ,		a_=None      ,		a_=True      ,		a_=[]      ,		a_=None      ,		a_=None      ,		**a_      ,		)   ->       Tuple:



   """simple docstring"""






   pl.seed_everything(args.seed		)

   # init model
   A_  :		Tuple						=					Path(model.hparams.output_dir		)
   odir.mkdir(exist_ok=a_		)

   # add custom checkpoints
   if checkpoint_callback is None:
      A_  :		List[Any]						=					pl.callbacks.ModelCheckpoint(
          filepath=args.output_dir      ,		prefix="""checkpoint"""      ,		monitor="""val_loss"""      ,		mode="""min"""      ,		save_top_k=1		)
   if early_stopping_callback:
      extra_callbacks.append(a_		)
   if logging_callback is None:
      A_  :		Optional[Any]						=					LoggingCallback()

   A_  :		Any						=					{}

   # TODO: remove with PyTorch 1.6 since pl uses native amp
   if args.fpaa:
      A_  :		List[str]						=					1_6
      A_  :		List[str]						=					args.fpaa_opt_level

   if args.gpus > 1:
      A_  :		Optional[int]						=					"""ddp"""

   A_  :		Tuple						=					args.accumulate_grad_batches
   A_  :		Tuple						=					extra_train_kwargs.get("""accelerator"""      ,		a_		)
   A_  :		Optional[int]						=					extra_train_kwargs.get("""profiler"""      ,		a_		)

   A_  :		Optional[Any]						=					pl.Trainer.from_argparse_args(
       a_      ,		weights_summary=a_      ,		callbacks=[logging_callback] + extra_callbacks      ,		logger=a_      ,		checkpoint_callback=a_      ,		**a_      ,		)

   if args.do_train:
      trainer.fit(a_		)

   return trainer





'''simple docstring'''





import enum
import inspect
from typing import Iterable, List, Optional, Tuple, Union


class 							_lowerCAmelCase	(  enum.Enum							):


 """simple docstring"""

 lowerCamelCase									=     '''timm'''
 lowerCamelCase									=     '''transformers'''



def     UpperCAmelCase     (    a_      ,		a_      ,		a_		)   ->       Optional[Any]:



   """simple docstring"""






   if stage_names is None:
      raise ValueError("""Stage_names must be set for transformers backbones"""		)

   if out_features is not None:
      if not isinstance(a_      ,		(list,)		):
         raise ValueError(F"out_features must be a list {type(a_		)}"		)
      if any(feat not in stage_names for feat in out_features		):
         raise ValueError(F"out_features must be a subset of stage_names: {stage_names} got {out_features}"		)

   if out_indices is not None:
      if not isinstance(a_      ,		(list, tuple)		):
         raise ValueError(F"out_indices must be a list or tuple, got {type(a_		)}"		)
      if any(idx >= len(a_		) for idx in out_indices		):
         raise ValueError("""out_indices must be valid indices for stage_names {stage_names}, got {out_indices}"""		)

   if out_features is not None and out_indices is not None:
      if len(a_		) != len(a_		):
         raise ValueError("""out_features and out_indices should have the same length if both are set"""		)
      if out_features != [stage_names[idx] for idx in out_indices]:
         raise ValueError("""out_features and out_indices should correspond to the same stages if both are set"""		)



def     UpperCAmelCase     (    a_      ,		a_      ,		a_      ,		)   ->       Dict:



   """simple docstring"""






   if out_indices is None and out_features is None:
      A_  :		Optional[Any]						=					[len(a_		) - 1]
      A_  :		Optional[int]						=					[stage_names[-1]]
   elif out_indices is None and out_features is not None:
      A_  :		Optional[Any]						=					[stage_names.index(a_		) for layer in out_features]
   elif out_features is None and out_indices is not None:
      A_  :		int						=					[stage_names[idx] for idx in out_indices]
   return out_features, out_indices



def     UpperCAmelCase     (    a_      ,		a_      ,		a_      ,		)   ->       Tuple[List[str], List[int]]:



   """simple docstring"""






   verify_out_features_out_indices(out_features=a_      ,		out_indices=a_      ,		stage_names=a_		)
   A_						,  A_  :		List[Any]						=					_align_output_features_output_indices(
       out_features=a_      ,		out_indices=a_      ,		stage_names=a_		)
   # Verify that the aligned out_features and out_indices are valid
   verify_out_features_out_indices(out_features=a_      ,		out_indices=a_      ,		stage_names=a_		)
   return output_features, output_indices


class 							_lowerCAmelCase	:


 """simple docstring"""

 lowerCamelCase									=     None







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    None:
    if getattr(self					,    """_backbone"""					,    _lowerCamelCase  ) is None:
       raise ValueError("""self._backbone must be set before calling _init_timm_backbone"""  )

    # These will diagree with the defaults for the transformers models e.g. for resnet50
    # the transformer model has out_features = ['stem', 'stage1', 'stage2', 'stage3', 'stage4']
    # the timm model has out_features = ['act', 'layer1', 'layer2', 'layer3', 'layer4']
    A_  :		str						=					[stage["""module"""] for stage in self._backbone.feature_info.info]
    A_  :		Any						=					[stage["""num_chs"""] for stage in self._backbone.feature_info.info]
    A_  :		Tuple						=					self._backbone.feature_info.out_indices
    A_  :		str						=					self._backbone.feature_info.module_name()

    # We verify the out indices and out features are valid
    verify_out_features_out_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=self.stage_names  )
    A_						,  A_  :		List[Any]						=					out_features, out_indices







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    None:
    A_  :		List[Any]						=					getattr(_lowerCamelCase					,    """stage_names"""  )
    A_  :		int						=					getattr(_lowerCamelCase					,    """out_features"""					,    _lowerCamelCase  )
    A_  :		Optional[int]						=					getattr(_lowerCamelCase					,    """out_indices"""					,    _lowerCamelCase  )

    A_  :		Union[str, Any]						=					stage_names
    A_						,  A_  :		List[str]						=					get_aligned_output_features_output_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=_lowerCamelCase  )
    # Number of channels for each stage. This is set in the transformer backbone model init
    A_  :		int						=					None







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    None:
    A_  :		Optional[Any]						=					config

    A_  :		Optional[Any]						=					getattr(_lowerCamelCase					,    """use_timm_backbone"""					,    _lowerCamelCase  )
    A_  :		Optional[int]						=					BackboneType.TIMM if self.use_timm_backbone else BackboneType.TRANSFORMERS

    if self.backbone_type == BackboneType.TIMM:
       self._init_timm_backbone(_lowerCamelCase  )
    elif self.backbone_type == BackboneType.TRANSFORMERS:
       self._init_transformers_backbone(_lowerCamelCase  )
    else:
       raise ValueError(F"backbone_type {self.backbone_type} not supported."  )







 @property
 def       UpperCAmelCase_       (      self  )    ->    List[str]:
    return self._out_features







 @out_features.setter
 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    Any:
    A_						,  A_  :		Union[str, Any]						=					get_aligned_output_features_output_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=self.stage_names  )







 @property
 def       UpperCAmelCase_       (      self  )    ->    Any:
    return self._out_indices







 @out_indices.setter
 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    Union[str, Any]:
    A_						,  A_  :		List[str]						=					get_aligned_output_features_output_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=self.stage_names  )







 @property
 def       UpperCAmelCase_       (      self  )    ->    Dict:
    # the current backbones will output the number of channels for each stage
    # even if that stage is not in the out_features list.
    return {stage: self.num_features[i] for i, stage in enumerate(self.stage_names  )}







 @property
 def       UpperCAmelCase_       (      self  )    ->    Any:
    return [self.out_feature_channels[name] for name in self.out_features]







 def       UpperCAmelCase_       (      self					,    *_lowerCamelCase					,    **_lowerCamelCase  )    ->    List[Any]:
    A_  :		Optional[int]						=					dict(inspect.signature(self.forward  ).parameters  )
    A_  :		str						=					{k: v for k, v in kwargs.items() if k in signature}
    return self(*_lowerCamelCase					,    **_lowerCamelCase  )







 def       UpperCAmelCase_       (      self					,    _lowerCamelCase					,    _lowerCamelCase = None					,    _lowerCamelCase = None					,    _lowerCamelCase = None					,    )    ->    List[Any]:
    raise NotImplementedError("""This method should be implemented by the derived class."""  )







 def       UpperCAmelCase_       (      self  )    ->    List[str]:
    A_  :		Optional[int]						=					super().to_dict()
    A_  :		Union[str, Any]						=					output.pop("""_out_features"""  )
    A_  :		int						=					output.pop("""_out_indices"""  )
    return output


class 							_lowerCAmelCase	:


 """simple docstring"""

 @property
 def       UpperCAmelCase_       (      self  )    ->    Union[str, Any]:
    return self._out_features







 @out_features.setter
 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    List[str]:
    A_						,  A_  :		List[str]						=					get_aligned_output_features_output_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=self.stage_names  )







 @property
 def       UpperCAmelCase_       (      self  )    ->    List[Any]:
    return self._out_indices







 @out_indices.setter
 def       UpperCAmelCase_       (      self					,    _lowerCamelCase  )    ->    str:
    A_						,  A_  :		Union[str, Any]						=					get_aligned_output_features_output_indices(
        out_features=_lowerCamelCase					,    out_indices=_lowerCamelCase					,    stage_names=self.stage_names  )







 def       UpperCAmelCase_       (      self  )    ->    List[str]:
    A_  :		Optional[int]						=					super().to_dict()
    A_  :		Tuple						=					output.pop("""_out_features"""  )
    A_  :		Optional[Any]						=					output.pop("""_out_indices"""  )
    return output
