


"""simple docstring"""




import argparse
import gc
import os
import sys
from pathlib import Path
from typing import List  # noqa: F401

import pytorch_lightning as pl
import torch
from finetune import SummarizationModule, TranslationModule
from finetune import main as ft_main
from make_student import create_student_by_copying_alternating_layers, get_layers_to_supervise
from torch import nn

from transformers import AutoModelForSeqaSeqLM, MBartTokenizer, TaForConditionalGeneration
from transformers.models.bart.modeling_bart import shift_tokens_right
from utils import calculate_bleu, check_output_dir, freeze_params, label_smoothed_nll_loss, use_task_specific_params


# need the parent dir module
sys.path.insert(2, str(Path(__file__).resolve().parents[1]))
from lightning_base import generic_train  # noqa







class       _lowercase			(							_a):


       """simple docstring"""




       A__ 						=      ["loss", "ce_loss", "mlm_loss", "hid_loss_enc", "hid_loss_dec"]





       def __init__(       self							:      List[Any] ,				__lowerCamelCase							:      Dict	):


             '''simple docstring'''



             assert Path(hparams.data_dir	).exists()
             lowerCamelCase__		:    List[Any]   =  Path(hparams.output_dir	)
             self.output_dir.mkdir(exist_ok=__lowerCamelCase	)

             lowerCamelCase__		:    List[Any]   =  self.output_dir.joinpath("student"	)

             lowerCamelCase__		:    Tuple   =  str(__lowerCamelCase	)  # Tell lightning we are training the student
             lowerCamelCase__		:    Optional[int]   =  AutoModelForSeqaSeqLM.from_pretrained(hparams.teacher	).eval()
             use_task_specific_params(__lowerCamelCase ,				hparams.task	)  # We copy good generation parameters to student by default
             if hparams.student is not None:
                   lowerCamelCase__		:    Union[str, Any]   =  AutoModelForSeqaSeqLM.from_pretrained(hparams.student	)
                   use_task_specific_params(__lowerCamelCase ,				hparams.task	)
                   lowerCamelCase__   ,       lowerCamelCase__		:    int   =  None, None
             else:
                   lowerCamelCase__   ,       lowerCamelCase__   ,       lowerCamelCase__		:    List[str]   =  create_student_by_copying_alternating_layers(
                       __lowerCamelCase ,				e=hparams.student_encoder_layers ,				d=hparams.student_decoder_layers ,				save_path=__lowerCamelCase	)

             if hparams.length_penalty != -1:
                   lowerCamelCase__		:    Dict   =  hparams.length_penalty
             lowerCamelCase__		:    Optional[Any]   =  hparams.teacher  # Use teacher's tokenizer
             super().__init__(__lowerCamelCase ,				model=__lowerCamelCase ,				config=student.config	)
             assert student.config.model_type == teacher.config.model_type, (
                 f"teacher, student model types should be the same, got {student.config.model_type} !="
                 f" {teacher.config.model_type}"
             )

             if student.config.model_type == "t5":
                   lowerCamelCase__		:    int   =  len(student.get_encoder().block	)
                   lowerCamelCase__		:    Optional[Any]   =  len(student.get_decoder().block	)
                   lowerCamelCase__		:    Optional[Any]   =  len(teacher.get_encoder().block	)
                   lowerCamelCase__		:    Optional[Any]   =  len(teacher.get_decoder().block	)
             else:
                   lowerCamelCase__		:    str   =  student.config.encoder_layers
                   lowerCamelCase__		:    List[Any]   =  student.config.decoder_layers
                   lowerCamelCase__		:    Union[str, Any]   =  teacher.config.encoder_layers
                   lowerCamelCase__		:    Dict   =  teacher.config.decoder_layers

             lowerCamelCase__		:    Tuple   =  not (hparams.student is None or hparams.teacher == hparams.student)
             lowerCamelCase__		:    List[str]   =  (not self.different_base_models) and hparams.alpha_hid > 0
             lowerCamelCase__		:    Tuple   =  self.different_base_models or (student_encoder_layers != teacher_encoder_layers)
             # self.different_encoder determines whether we need to run the teacher encoder
             lowerCamelCase__		:    str   =  teacher
             freeze_params(self.teacher	)

             if not self.different_encoder:  # To save RAM, delete teacher encoder and freeze student encoder.
                   try:
                         del self.teacher.model.encoder
                   except AttributeError:  # T5
                         del self.teacher.encoder

             if e_layer_ids is None:
                   lowerCamelCase__		:    int   =  list(range(__lowerCamelCase	)	)
             if d_layer_ids is None:
                   lowerCamelCase__		:    Dict   =  list(range(__lowerCamelCase	)	)

             lowerCamelCase__   ,       lowerCamelCase__		:    List[str]   =  e_layer_ids, d_layer_ids  # type: List[int], List[int]

             if self.do_calc_hidden_loss:  # Intermediate supervision: Decide which layers to supervise
                   if hparams.supervise_forward:
                         lowerCamelCase__		:    Optional[Any]   =  get_layers_to_supervise(
                             n_student=len(self.e_layer_ids	) ,				n_teacher=__lowerCamelCase	)
                         lowerCamelCase__		:    str   =  get_layers_to_supervise(
                             n_student=len(self.d_layer_ids	) ,				n_teacher=__lowerCamelCase	)
                   else:  # student layer should emulate hidden states of the teacher layer it was copied from
                         lowerCamelCase__		:    Any   =  self.e_layer_ids
                         lowerCamelCase__		:    Optional[int]   =  self.d_layer_ids
             else:
                   lowerCamelCase__		:    Optional[Any]   =  None
                   lowerCamelCase__		:    Union[str, Any]   =  None

             lowerCamelCase__		:    int   =  nn.KLDivLoss(reduction="batchmean"	)
             lowerCamelCase__		:    int   =  2.0
             lowerCamelCase__		:    Tuple   =  hparams.alpha_mlm
             lowerCamelCase__		:    Optional[Any]   =  hparams.alpha_ce
             lowerCamelCase__		:    Union[str, Any]   =  hparams.alpha_hid
             gc.collect()
             torch.cuda.empty_cache()





       def 						lowerCAmelCase					(       self							:      Tuple ,				__lowerCamelCase							:      str ,				__lowerCamelCase							:      str ,				__lowerCamelCase							:      List[Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Tuple   =  mask[:, :, None].expand_as(__lowerCamelCase	)
             lowerCamelCase__		:    str   =  s_logits.size(-1	)
             lowerCamelCase__		:    Tuple   =  torch.masked_select(__lowerCamelCase ,				__lowerCamelCase	)  # (bs * seq_length * voc_size) modulo the 1s in mask
             lowerCamelCase__		:    List[Any]   =  torch.masked_select(__lowerCamelCase ,				__lowerCamelCase	)  # (bs * seq_length * voc_size) modulo the 1s in mask
             lowerCamelCase__		:    Dict   =  s_logits_slct.view(-1 ,				__lowerCamelCase	)  # (bs * seq_length, voc_size) modulo the 1s in mask
             lowerCamelCase__		:    List[Any]   =  t_logits_slct.view(-1 ,				__lowerCamelCase	)  # (bs * seq_length, voc_size) modulo the 1s in mask
             assert t_logits_slct.size() == s_logits_slct.size()
             lowerCamelCase__		:    Dict   =  (
                 self.ce_loss_fct(
                     nn.functional.log_softmax(s_logits_slct / self.temperature ,				dim=-1	) ,				nn.functional.softmax(t_logits_slct / self.temperature ,				dim=-1	) ,				)
                 * (self.temperature) ** 2
             )
             return loss_ce





       @staticmethod
       def 						lowerCAmelCase					(       __lowerCamelCase							:      Tuple ,				__lowerCamelCase							:      Union[str, Any]	):


             '''simple docstring'''



             SummarizationModule.add_model_specific_args(__lowerCamelCase ,				__lowerCamelCase	)
             add_distill_args(__lowerCamelCase	)
             return parser





       def 						lowerCAmelCase					(       self							:      Tuple ,				__lowerCamelCase							:      dict	):


             '''simple docstring'''



             lowerCamelCase__		:    Optional[int]   =  self.tokenizer.pad_token_id
             lowerCamelCase__   ,       lowerCamelCase__   ,       lowerCamelCase__		:    Tuple   =  batch["input_ids"], batch["attention_mask"], batch["labels"]
             if isinstance(self.model ,				__lowerCamelCase	):
                   lowerCamelCase__		:    Optional[Any]   =  self.model._shift_right(__lowerCamelCase	)
             else:
                   lowerCamelCase__		:    Dict   =  shift_tokens_right(__lowerCamelCase ,				__lowerCamelCase	)

             # noinspection PyCallingNonCallable
             lowerCamelCase__		:    List[Any]   =  self(
                 __lowerCamelCase ,				attention_mask=__lowerCamelCase ,				decoder_input_ids=__lowerCamelCase ,				output_hidden_states=self.do_calc_hidden_loss ,				output_attentions=__lowerCamelCase ,				use_cache=__lowerCamelCase ,				)
             lowerCamelCase__		:    Tuple   =  student_outputs["logits"]

             # Same cross entropy vs. label smoothing logic as finetune.py
             assert lm_logits.shape[-1] == self.model.config.vocab_size
             if self.hparams.label_smoothing == 0:
                   # Same behavior as modeling_bart.py, besides ignoring pad_token_id
                   lowerCamelCase__		:    List[Any]   =  nn.CrossEntropyLoss(ignore_index=__lowerCamelCase	)
                   lowerCamelCase__		:    Any   =  loss_fct(lm_logits.view(-1 ,				lm_logits.shape[-1]	) ,				labels.view(-1	)	)
             else:
                   lowerCamelCase__		:    Union[str, Any]   =  nn.functional.log_softmax(__lowerCamelCase ,				dim=-1	)
                   lowerCamelCase__   ,       lowerCamelCase__		:    Optional[int]   =  label_smoothed_nll_loss(
                       __lowerCamelCase ,				__lowerCamelCase ,				self.hparams.label_smoothing ,				ignore_index=__lowerCamelCase	)

             def zero_tensor():
                   return torch.tensor(0.0	).type_as(__lowerCamelCase	)

             lowerCamelCase__		:    Union[str, Any]   =  student_outputs[
                 "encoder_last_hidden_state"
             ]  # use this unless self.different_base_models
             lowerCamelCase__   ,       lowerCamelCase__		:    List[str]   =  zero_tensor(), zero_tensor()
             if self.different_encoder:  # compute encoder hidden state loss
                   lowerCamelCase__		:    Optional[int]   =  self.teacher.get_encoder()(
                       __lowerCamelCase ,				attention_mask=__lowerCamelCase ,				output_hidden_states=self.do_calc_hidden_loss ,				)
                   if self.different_base_models:
                         lowerCamelCase__		:    List[str]   =  all_teacher_encoder_outputs["last_hidden_state"]
                   elif self.do_calc_hidden_loss:
                         lowerCamelCase__		:    List[str]   =  self.calc_hidden_loss(
                             __lowerCamelCase ,				student_outputs["encoder_hidden_states"] ,				all_teacher_encoder_outputs["hidden_states"] ,				self.e_matches ,				normalize_hidden=self.hparams.normalize_hidden ,				)

             lowerCamelCase__		:    Tuple   =  self.teacher(
                 __lowerCamelCase ,				attention_mask=__lowerCamelCase ,				encoder_outputs=(teacher_enc_outputs,) ,				decoder_input_ids=__lowerCamelCase ,				output_hidden_states=self.do_calc_hidden_loss ,				use_cache=__lowerCamelCase ,				)
             lowerCamelCase__		:    Union[str, Any]   =  decoder_input_ids.ne(__lowerCamelCase	)
             lowerCamelCase__		:    Optional[Any]   =  self.calc_ce_loss(__lowerCamelCase ,				__lowerCamelCase ,				teacher_outputs["logits"]	)
             if self.do_calc_hidden_loss:  # Intermediate supervision of decoder hidden states
                   lowerCamelCase__		:    List[Any]   =  self.calc_hidden_loss(
                       __lowerCamelCase ,				student_outputs["decoder_hidden_states"] ,				teacher_outputs["decoder_hidden_states"] ,				self.d_matches ,				normalize_hidden=self.hparams.normalize_hidden ,				)

             lowerCamelCase__		:    Optional[int]   =  (
                 self.alpha_ce * loss_ce
                 + self.alpha_mlm * student_lm_loss
                 + self.hparams.alpha_hid * (hid_loss_enc + hid_loss_dec)
             )
             return blended_loss, loss_ce, student_lm_loss, hid_loss_enc, hid_loss_dec





       @staticmethod
       def 						lowerCAmelCase					(       __lowerCamelCase							:      Dict ,				__lowerCamelCase							:      int ,				__lowerCamelCase							:      List[str] ,				__lowerCamelCase							:      List[Any] ,				__lowerCamelCase							:      Optional[Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    str   =  "expected list or tuple for hidden_states, got tensor of shape: "
             assert not isinstance(__lowerCamelCase ,				torch.Tensor	), f"{msg}{hidden_states.shape}"
             assert not isinstance(__lowerCamelCase ,				torch.Tensor	), f"{msg}{hidden_states_T.shape}"
             lowerCamelCase__		:    Tuple   =  attention_mask.to(hidden_states[0]	)
             lowerCamelCase__		:    str   =  mask.sum() * hidden_states[0].size(-1	)
             lowerCamelCase__		:    List[Any]   =  torch.stack([hidden_states[i] for i in range(len(__lowerCamelCase	)	)]	)
             lowerCamelCase__		:    Tuple   =  torch.stack([hidden_states_T[j] for j in matches]	)
             assert student_states.shape == teacher_states.shape, f"{student_states.shape} != {teacher_states.shape}"
             if normalize_hidden:
                   lowerCamelCase__		:    Optional[Any]   =  nn.functional.layer_norm(__lowerCamelCase ,				student_states.shape[1:]	)
                   lowerCamelCase__		:    Optional[int]   =  nn.functional.layer_norm(__lowerCamelCase ,				teacher_states.shape[1:]	)
             lowerCamelCase__		:    Optional[Any]   =  nn.functional.mse_loss(__lowerCamelCase ,				__lowerCamelCase ,				reduction="none"	)
             lowerCamelCase__		:    Tuple   =  (mse * mask.unsqueeze(0	).unsqueeze(-1	)).sum() / valid_count
             return masked_mse



def 				lowercase_		(		_A      :   List[Any]						):

      """simple docstring"""




      parser.add_argument("--teacher"   , type=snake_case__						)
      parser.add_argument("--alpha_ce"   , default=0.8   , type=snake_case__						)
      parser.add_argument("--alpha_mlm"   , default=0.2   , type=snake_case__						)
      parser.add_argument("--alpha_hid"   , default=0.0   , type=snake_case__   , required=snake_case__						)
      parser.add_argument("--student"   , type=snake_case__   , required=snake_case__						)
      parser.add_argument("--student_decoder_layers"   , default=12   , type=snake_case__   , required=snake_case__						)
      parser.add_argument("--student_encoder_layers"   , default=12   , type=snake_case__   , required=snake_case__						)
      parser.add_argument("--no_teacher"   , action="store_true"   , default=snake_case__						)
      parser.add_argument("--length_penalty"   , type=snake_case__   , default=-1						)
      parser.add_argument("--supervise_forward"   , action="store_true"   , default=snake_case__						)
      parser.add_argument("--normalize_hidden"   , action="store_true"   , default=snake_case__						)







class       _lowercase			(							_a):


       """simple docstring"""




       A__ 						=      "translation"
       A__ 						=      ["bleu"]
       A__ 						=      "bleu"





       def __init__(       self							:      Dict ,				__lowerCamelCase							:      Tuple ,				**__lowerCamelCase							:      Optional[Any]	):


             '''simple docstring'''



             super().__init__(__lowerCamelCase ,				**__lowerCamelCase	)
             assert hparams.src_lang is not None
             assert hparams.tgt_lang is not None
             lowerCamelCase__		:    Tuple   =  hparams.src_lang
             lowerCamelCase__		:    Optional[int]   =  hparams.tgt_lang
             if self.model.config.decoder_start_token_id is None and isinstance(self.tokenizer ,				__lowerCamelCase	):
                   lowerCamelCase__		:    List[str]   =  self.tokenizer.lang_code_to_id[hparams.tgt_lang]





       def 						lowerCAmelCase					(       self							:      List[str] ,				__lowerCamelCase							:      int ,				__lowerCamelCase							:      Tuple	):


             '''simple docstring'''



             return calculate_bleu(__lowerCamelCase ,				__lowerCamelCase	)





       @staticmethod
       def 						lowerCAmelCase					(       __lowerCamelCase							:      List[Any] ,				__lowerCamelCase							:      Optional[int]	):


             '''simple docstring'''



             TranslationModule.add_model_specific_args(__lowerCamelCase ,				__lowerCamelCase	)
             add_distill_args(__lowerCamelCase	)
             return parser



def 				lowercase_		(		_A      :   List[Any]						):

      """simple docstring"""




      if args.no_teacher:
            lowerCamelCase__		:    List[Any]   =  TranslationModule if "translation" in args.task else SummarizationModule
      else:  # DISTILL WITH TEACHER
            lowerCamelCase__		:    str   =  TranslationDistiller if "translation" in args.task else SummarizationDistiller
      lowerCamelCase__		:    Dict   =  module_cls.__name__
      print(F"using module {args.setup_cls}"						)
      lowerCamelCase__		:    str   =  module_cls(snake_case__						)
      return model

def 				lowercase_		(		_A      :   Union[str, Any]						):

      """simple docstring"""




      Path(args.output_dir						).mkdir(exist_ok=snake_case__						)
      check_output_dir(snake_case__   , expected_items=3						)

      lowerCamelCase__		:    Tuple   =  create_module(snake_case__						)
      return ft_main(snake_case__   , model=snake_case__						)


if __name__ == "__main__":
    A				:   str		= argparse.ArgumentParser()
    A				:   int		= pl.Trainer.add_argparse_args(parser)
    A				:   Union[str, Any]		= SummarizationDistiller.add_model_specific_args(parser, os.getcwd())
    A				:   int		= parser.parse_args()

    distill_main(args)






from ...configuration_utils import PretrainedConfig
from ...utils import is_detectrona_available, logging


A				:   int		= logging.get_logger(__name__)

A				:   Any		= {
    "layoutlmv2-base-uncased": "https://huggingface.co/microsoft/layoutlmv2-base-uncased/resolve/main/config.json",
    "layoutlmv2-large-uncased": "https://huggingface.co/microsoft/layoutlmv2-large-uncased/resolve/main/config.json",
    # See all LayoutLMv2 models at https://huggingface.co/models?filter=layoutlmv2
}

# soft dependency
if is_detectrona_available():
    import detectrona







class       _lowercase			(							lowercase__):


       """simple docstring"""




       A__ 						=      "layoutlmv2"





       def __init__(       self							:      Union[str, Any] ,				__lowerCamelCase							:      int=30522 ,				__lowerCamelCase							:      List[Any]=768 ,				__lowerCamelCase							:      Any=12 ,				__lowerCamelCase							:      List[Any]=12 ,				__lowerCamelCase							:      Optional[Any]=3072 ,				__lowerCamelCase							:      List[Any]="gelu" ,				__lowerCamelCase							:      Any=0.1 ,				__lowerCamelCase							:      Union[str, Any]=0.1 ,				__lowerCamelCase							:      int=512 ,				__lowerCamelCase							:      str=2 ,				__lowerCamelCase							:      Any=0.0_2 ,				__lowerCamelCase							:      List[Any]=1E-1_2 ,				__lowerCamelCase							:      List[str]=0 ,				__lowerCamelCase							:      Union[str, Any]=1024 ,				__lowerCamelCase							:      Tuple=128 ,				__lowerCamelCase							:      Tuple=32 ,				__lowerCamelCase							:      Union[str, Any]=True ,				__lowerCamelCase							:      List[Any]=256 ,				__lowerCamelCase							:      Dict=64 ,				__lowerCamelCase							:      List[Any]=True ,				__lowerCamelCase							:      Union[str, Any]=[7, 7, 256] ,				__lowerCamelCase							:      str=128 ,				__lowerCamelCase							:      Dict=128 ,				__lowerCamelCase							:      Dict=True ,				__lowerCamelCase							:      int=True ,				__lowerCamelCase							:      str=False ,				__lowerCamelCase							:      Tuple=None ,				**__lowerCamelCase							:      str ,				):


             '''simple docstring'''



             super().__init__(
                 vocab_size=__lowerCamelCase ,				hidden_size=__lowerCamelCase ,				num_hidden_layers=__lowerCamelCase ,				num_attention_heads=__lowerCamelCase ,				intermediate_size=__lowerCamelCase ,				hidden_act=__lowerCamelCase ,				hidden_dropout_prob=__lowerCamelCase ,				attention_probs_dropout_prob=__lowerCamelCase ,				max_position_embeddings=__lowerCamelCase ,				type_vocab_size=__lowerCamelCase ,				initializer_range=__lowerCamelCase ,				layer_norm_eps=__lowerCamelCase ,				pad_token_id=__lowerCamelCase ,				**__lowerCamelCase ,				)
             lowerCamelCase__		:    Dict   =  max_ad_position_embeddings
             lowerCamelCase__		:    int   =  max_rel_pos
             lowerCamelCase__		:    List[Any]   =  rel_pos_bins
             lowerCamelCase__		:    str   =  fast_qkv
             lowerCamelCase__		:    Optional[Any]   =  max_rel_ad_pos
             lowerCamelCase__		:    List[Any]   =  rel_ad_pos_bins
             lowerCamelCase__		:    Optional[Any]   =  convert_sync_batchnorm
             lowerCamelCase__		:    Any   =  image_feature_pool_shape
             lowerCamelCase__		:    List[Any]   =  coordinate_size
             lowerCamelCase__		:    Any   =  shape_size
             lowerCamelCase__		:    List[str]   =  has_relative_attention_bias
             lowerCamelCase__		:    Optional[int]   =  has_spatial_attention_bias
             lowerCamelCase__		:    Optional[Any]   =  has_visual_segment_embedding
             lowerCamelCase__		:    List[str]   =  (
                 detectrona_config_args if detectrona_config_args is not None else self.get_default_detectrona_config()
             )





       @classmethod
       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             return {
                 "MODEL.MASK_ON": True,
                 "MODEL.PIXEL_STD": [5_7.3_7_5, 5_7.1_2_0, 5_8.3_9_5],
                 "MODEL.BACKBONE.NAME": "build_resnet_fpn_backbone",
                 "MODEL.FPN.IN_FEATURES": ["res2", "res3", "res4", "res5"],
                 "MODEL.ANCHOR_GENERATOR.SIZES": [[32], [64], [128], [256], [512]],
                 "MODEL.RPN.IN_FEATURES": ["p2", "p3", "p4", "p5", "p6"],
                 "MODEL.RPN.PRE_NMS_TOPK_TRAIN": 2000,
                 "MODEL.RPN.PRE_NMS_TOPK_TEST": 1000,
                 "MODEL.RPN.POST_NMS_TOPK_TRAIN": 1000,
                 "MODEL.POST_NMS_TOPK_TEST": 1000,
                 "MODEL.ROI_HEADS.NAME": "StandardROIHeads",
                 "MODEL.ROI_HEADS.NUM_CLASSES": 5,
                 "MODEL.ROI_HEADS.IN_FEATURES": ["p2", "p3", "p4", "p5"],
                 "MODEL.ROI_BOX_HEAD.NAME": "FastRCNNConvFCHead",
                 "MODEL.ROI_BOX_HEAD.NUM_FC": 2,
                 "MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION": 14,
                 "MODEL.ROI_MASK_HEAD.NAME": "MaskRCNNConvUpsampleHead",
                 "MODEL.ROI_MASK_HEAD.NUM_CONV": 4,
                 "MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION": 7,
                 "MODEL.RESNETS.DEPTH": 101,
                 "MODEL.RESNETS.SIZES": [[32], [64], [128], [256], [512]],
                 "MODEL.RESNETS.ASPECT_RATIOS": [[0.5, 1.0, 2.0]],
                 "MODEL.RESNETS.OUT_FEATURES": ["res2", "res3", "res4", "res5"],
                 "MODEL.RESNETS.NUM_GROUPS": 32,
                 "MODEL.RESNETS.WIDTH_PER_GROUP": 8,
                 "MODEL.RESNETS.STRIDE_IN_1X1": False,
             }





       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Optional[int]   =  detectrona.config.get_cfg()
             for k, v in self.detectrona_config_args.items():
                   lowerCamelCase__		:    List[Any]   =  k.split("."	)
                   lowerCamelCase__		:    int   =  detectrona_config
                   for attribute in attributes[:-1]:
                         lowerCamelCase__		:    Any   =  getattr(__lowerCamelCase ,				__lowerCamelCase	)
                   setattr(__lowerCamelCase ,				attributes[-1] ,				__lowerCamelCase	)

             return detectrona_config


