"""simple docstring"""





import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import (
    BertTokenizer,
    ViltConfig,
    ViltForImageAndTextRetrieval,
    ViltForImagesAndTextClassification,
    ViltForMaskedLM,
    ViltForQuestionAnswering,
    ViltImageProcessor,
    ViltProcessor,
)
from transformers.utils import logging


logging.set_verbosity_info()
snake_case__		:     Dict    				=				logging.get_logger(__name__)


def      _snake_case						(						_snake_case				:			Tuple ,   _snake_case				:			Dict=False ,   _snake_case				:			List[str]=False ,   _snake_case				:			Union[str, Any]=False			):
      lowerCAmelCase					:	str       =   []
      for i in range(config.num_hidden_layers			):
            # encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
            rename_keys.append((f'''transformer.blocks.{i}.norm1.weight''', f'''vilt.encoder.layer.{i}.layernorm_before.weight''')			)
            rename_keys.append((f'''transformer.blocks.{i}.norm1.bias''', f'''vilt.encoder.layer.{i}.layernorm_before.bias''')			)
            rename_keys.append(
                (f'''transformer.blocks.{i}.attn.proj.weight''', f'''vilt.encoder.layer.{i}.attention.output.dense.weight''')			)
            rename_keys.append(
                (f'''transformer.blocks.{i}.attn.proj.bias''', f'''vilt.encoder.layer.{i}.attention.output.dense.bias''')			)
            rename_keys.append((f'''transformer.blocks.{i}.norm2.weight''', f'''vilt.encoder.layer.{i}.layernorm_after.weight''')			)
            rename_keys.append((f'''transformer.blocks.{i}.norm2.bias''', f'''vilt.encoder.layer.{i}.layernorm_after.bias''')			)
            rename_keys.append(
                (f'''transformer.blocks.{i}.mlp.fc1.weight''', f'''vilt.encoder.layer.{i}.intermediate.dense.weight''')			)
            rename_keys.append((f'''transformer.blocks.{i}.mlp.fc1.bias''', f'''vilt.encoder.layer.{i}.intermediate.dense.bias''')			)
            rename_keys.append((f'''transformer.blocks.{i}.mlp.fc2.weight''', f'''vilt.encoder.layer.{i}.output.dense.weight''')			)
            rename_keys.append((f'''transformer.blocks.{i}.mlp.fc2.bias''', f'''vilt.encoder.layer.{i}.output.dense.bias''')			)

      # embeddings
      rename_keys.extend(
          [
              # text embeddings
              ('''text_embeddings.word_embeddings.weight''', '''vilt.embeddings.text_embeddings.word_embeddings.weight'''),
              (
                  '''text_embeddings.position_embeddings.weight''',
                  '''vilt.embeddings.text_embeddings.position_embeddings.weight''',
              ),
              ('''text_embeddings.position_ids''', '''vilt.embeddings.text_embeddings.position_ids'''),
              (
                  '''text_embeddings.token_type_embeddings.weight''',
                  '''vilt.embeddings.text_embeddings.token_type_embeddings.weight''',
              ),
              ('''text_embeddings.LayerNorm.weight''', '''vilt.embeddings.text_embeddings.LayerNorm.weight'''),
              ('''text_embeddings.LayerNorm.bias''', '''vilt.embeddings.text_embeddings.LayerNorm.bias'''),
              # patch embeddings
              ('''transformer.cls_token''', '''vilt.embeddings.cls_token'''),
              ('''transformer.patch_embed.proj.weight''', '''vilt.embeddings.patch_embeddings.projection.weight'''),
              ('''transformer.patch_embed.proj.bias''', '''vilt.embeddings.patch_embeddings.projection.bias'''),
              ('''transformer.pos_embed''', '''vilt.embeddings.position_embeddings'''),
              # token type embeddings
              ('''token_type_embeddings.weight''', '''vilt.embeddings.token_type_embeddings.weight'''),
          ]			)

      # final layernorm + pooler
      rename_keys.extend(
          [
              ('''transformer.norm.weight''', '''vilt.layernorm.weight'''),
              ('''transformer.norm.bias''', '''vilt.layernorm.bias'''),
              ('''pooler.dense.weight''', '''vilt.pooler.dense.weight'''),
              ('''pooler.dense.bias''', '''vilt.pooler.dense.bias'''),
          ]			)

      # classifier head(s)
      if vqa_model:
            # classification head
            rename_keys.extend(
                [
                    ('''vqa_classifier.0.weight''', '''classifier.0.weight'''),
                    ('''vqa_classifier.0.bias''', '''classifier.0.bias'''),
                    ('''vqa_classifier.1.weight''', '''classifier.1.weight'''),
                    ('''vqa_classifier.1.bias''', '''classifier.1.bias'''),
                    ('''vqa_classifier.3.weight''', '''classifier.3.weight'''),
                    ('''vqa_classifier.3.bias''', '''classifier.3.bias'''),
                ]			)
      elif nlvr_model:
            # classification head
            rename_keys.extend(
                [
                    ('''nlvr2_classifier.0.weight''', '''classifier.0.weight'''),
                    ('''nlvr2_classifier.0.bias''', '''classifier.0.bias'''),
                    ('''nlvr2_classifier.1.weight''', '''classifier.1.weight'''),
                    ('''nlvr2_classifier.1.bias''', '''classifier.1.bias'''),
                    ('''nlvr2_classifier.3.weight''', '''classifier.3.weight'''),
                    ('''nlvr2_classifier.3.bias''', '''classifier.3.bias'''),
                ]			)
      else:
            pass

      return rename_keys


def      _snake_case						(						_snake_case				:			Any ,   _snake_case				:			Optional[Any]			):







      for i in range(config.num_hidden_layers			):
            lowerCAmelCase					:	str       =   'vilt.'
            # read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
            lowerCAmelCase					:	Optional[int]       =   state_dict.pop(f'''transformer.blocks.{i}.attn.qkv.weight'''			)
            lowerCAmelCase					:	str       =   state_dict.pop(f'''transformer.blocks.{i}.attn.qkv.bias'''			)
            # next, add query, keys and values (in that order) to the state dict
            lowerCAmelCase					:	List[str]       =   in_proj_weight[
                : config.hidden_size, :
            ]
            lowerCAmelCase					:	List[str]       =   in_proj_bias[: config.hidden_size]
            lowerCAmelCase					:	Optional[int]       =   in_proj_weight[
                config.hidden_size : config.hidden_size * 2, :
            ]
            lowerCAmelCase					:	Union[str, Any]       =   in_proj_bias[
                config.hidden_size : config.hidden_size * 2
            ]
            lowerCAmelCase					:	Optional[Any]       =   in_proj_weight[
                -config.hidden_size :, :
            ]
            lowerCAmelCase					:	str       =   in_proj_bias[-config.hidden_size :]


def      _snake_case						(						_snake_case				:			Optional[Any]			):
      lowerCAmelCase					:	Dict       =   ['head.weight', 'head.bias']
      for k in ignore_keys:
            state_dict.pop(lowerCAmelCase__ ,   lowerCAmelCase__			)


def      _snake_case						(						_snake_case				:			Any ,   _snake_case				:			List[Any] ,   _snake_case				:			int			):
      lowerCAmelCase					:	Optional[int]       =   dct.pop(lowerCAmelCase__			)
      lowerCAmelCase					:	Tuple       =   val


@torch.no_grad()
def      _snake_case						(						_snake_case				:			Optional[Any] ,   _snake_case				:			List[Any]			):
      lowerCAmelCase					:	Tuple       =   ViltConfig(image_size=384 ,   patch_size=32 ,   tie_word_embeddings=lowerCAmelCase__			)
      lowerCAmelCase					:	str       =   False
      lowerCAmelCase					:	Optional[Any]       =   False
      lowerCAmelCase					:	Any       =   False
      lowerCAmelCase					:	Dict       =   False
      if "vqa" in checkpoint_url:
            lowerCAmelCase					:	str       =   True
            lowerCAmelCase					:	Optional[Any]       =   3129
            lowerCAmelCase					:	str       =   'huggingface/label-files'
            lowerCAmelCase					:	Any       =   'vqa2-id2label.json'
            lowerCAmelCase					:	List[Any]       =   json.load(open(hf_hub_download(lowerCAmelCase__ ,   lowerCAmelCase__ ,   repo_type='''dataset'''			) ,   '''r'''			)			)
            lowerCAmelCase					:	Dict       =   {int(lowerCAmelCase__			): v for k, v in idalabel.items()}
            lowerCAmelCase					:	Any       =   idalabel
            lowerCAmelCase					:	List[str]       =   {v: k for k, v in idalabel.items()}
            lowerCAmelCase					:	Optional[Any]       =   ViltForQuestionAnswering(lowerCAmelCase__			)
      elif "nlvr" in checkpoint_url:
            lowerCAmelCase					:	str       =   True
            lowerCAmelCase					:	Any       =   2
            lowerCAmelCase					:	Optional[int]       =   {0: 'False', 1: 'True'}
            lowerCAmelCase					:	Tuple       =   {v: k for k, v in config.idalabel.items()}
            lowerCAmelCase					:	Dict       =   3
            lowerCAmelCase					:	str       =   ViltForImagesAndTextClassification(lowerCAmelCase__			)
      elif "irtr" in checkpoint_url:
            lowerCAmelCase					:	str       =   True
            lowerCAmelCase					:	List[Any]       =   ViltForImageAndTextRetrieval(lowerCAmelCase__			)
      elif "mlm_itm" in checkpoint_url:
            lowerCAmelCase					:	List[Any]       =   True
            lowerCAmelCase					:	Optional[int]       =   ViltForMaskedLM(lowerCAmelCase__			)
      else:
            raise ValueError('''Unknown model type'''			)

      # load state_dict of original model, remove and rename some keys
      lowerCAmelCase					:	Optional[Any]       =   torch.hub.load_state_dict_from_url(lowerCAmelCase__ ,   map_location='''cpu'''			)['state_dict']
      lowerCAmelCase					:	Optional[int]       =   create_rename_keys(lowerCAmelCase__ ,   lowerCAmelCase__ ,   lowerCAmelCase__ ,   lowerCAmelCase__			)
      for src, dest in rename_keys:
            rename_key(lowerCAmelCase__ ,   lowerCAmelCase__ ,   lowerCAmelCase__			)
      read_in_q_k_v(lowerCAmelCase__ ,   lowerCAmelCase__			)
      if mlm_model or irtr_model:
            lowerCAmelCase					:	str       =   ['itm_score.fc.weight', 'itm_score.fc.bias']
            for k in ignore_keys:
                  state_dict.pop(lowerCAmelCase__ ,   lowerCAmelCase__			)

    # load state dict into HuggingFace model
      model.eval()
      if mlm_model:
            lowerCAmelCase					:	Union[str, Any]       =   model.load_state_dict(lowerCAmelCase__ ,   strict=lowerCAmelCase__			)
            assert missing_keys == ["mlm_score.decoder.bias"]
      else:
            model.load_state_dict(lowerCAmelCase__			)

      # Define processor
      lowerCAmelCase					:	Tuple       =   ViltImageProcessor(size=384			)
      lowerCAmelCase					:	Optional[int]       =   BertTokenizer.from_pretrained('''bert-base-uncased'''			)
      lowerCAmelCase					:	int       =   ViltProcessor(lowerCAmelCase__ ,   lowerCAmelCase__			)

      # Forward pass on example inputs (image + text)
      if nlvr_model:
            lowerCAmelCase					:	str       =   Image.open(requests.get('''https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg''' ,   stream=lowerCAmelCase__			).raw			)
            lowerCAmelCase					:	Union[str, Any]       =   Image.open(requests.get('''https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg''' ,   stream=lowerCAmelCase__			).raw			)
            lowerCAmelCase					:	int       =   (
                'The left image contains twice the number of dogs as the right image, and at least two dogs in total are'
                ' standing.'
            )
            lowerCAmelCase					:	Optional[int]       =   processor(lowerCAmelCase__ ,   lowerCAmelCase__ ,   return_tensors='''pt'''			)
            lowerCAmelCase					:	Optional[Any]       =   processor(lowerCAmelCase__ ,   lowerCAmelCase__ ,   return_tensors='''pt'''			)
            lowerCAmelCase					:	Any       =   model(
                input_ids=encoding_a.input_ids ,   pixel_values=encoding_a.pixel_values ,   pixel_values_a=encoding_a.pixel_values ,   )
      else:
            lowerCAmelCase					:	List[Any]       =   Image.open(requests.get('''http://images.cocodataset.org/val2017/000000039769.jpg''' ,   stream=lowerCAmelCase__			).raw			)
            if mlm_model:
                  lowerCAmelCase					:	List[Any]       =   'a bunch of [MASK] laying on a [MASK].'
            else:
                  lowerCAmelCase					:	str       =   'How many cats are there?'
            lowerCAmelCase					:	Optional[Any]       =   processor(lowerCAmelCase__ ,   lowerCAmelCase__ ,   return_tensors='''pt'''			)
            lowerCAmelCase					:	Union[str, Any]       =   model(**lowerCAmelCase__			)

      # Verify outputs
      if mlm_model:
            lowerCAmelCase					:	List[Any]       =   torch.Size([1, 11, 30522]			)
            lowerCAmelCase					:	Union[str, Any]       =   torch.tensor([-12.5061, -12.5123, -12.5174]			)
            assert outputs.logits.shape == expected_shape
            assert torch.allclose(outputs.logits[0, 0, :3] ,   lowerCAmelCase__ ,   atol=1E-4			)

            # verify masked token prediction equals "cats"
            lowerCAmelCase					:	Any       =   outputs.logits[0, 4, :].argmax(-1			).item()
            assert tokenizer.decode([predicted_id]			) == "cats"
      elif vqa_model:
            lowerCAmelCase					:	Dict       =   torch.Size([1, 3129]			)
            lowerCAmelCase					:	List[Any]       =   torch.tensor([-15.9495, -18.1472, -10.3041]			)
            assert torch.allclose(outputs.logits[0, :3] ,   lowerCAmelCase__ ,   atol=1E-4			)
            assert outputs.logits.shape == expected_shape
            assert torch.allclose(outputs.logits[0, 0, :3] ,   lowerCAmelCase__ ,   atol=1E-4			)

            # verify vqa prediction equals "2"
            lowerCAmelCase					:	Dict       =   outputs.logits.argmax(-1			).item()
            assert model.config.idalabel[predicted_idx] == "2"
      elif nlvr_model:
            lowerCAmelCase					:	str       =   torch.Size([1, 2]			)
            lowerCAmelCase					:	Union[str, Any]       =   torch.tensor([-2.8721, 2.1291]			)
            assert torch.allclose(outputs.logits[0, :3] ,   lowerCAmelCase__ ,   atol=1E-4			)
            assert outputs.logits.shape == expected_shape

      Path(lowerCAmelCase__			).mkdir(exist_ok=lowerCAmelCase__			)
      print(f'''Saving model and processor to {pytorch_dump_folder_path}'''			)
      model.save_pretrained(lowerCAmelCase__			)
      processor.save_pretrained(lowerCAmelCase__			)


if __name__ == "__main__":
 snake_case__		:     int    				=				argparse.ArgumentParser()
 # Required parameters
 parser.add_argument(
     '''--checkpoint_url''',
     default='''https://github.com/dandelin/ViLT/releases/download/200k/vilt_200k_mlm_itm.ckpt''',
     type=str,
     help='''URL of the checkpoint you\'d like to convert.''',
 )
 parser.add_argument(
     '''--pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model directory.'''
 )

 snake_case__		:     Any    				=				parser.parse_args()
 convert_vilt_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)






"""simple docstring"""





import os
import tempfile
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
 import torch
 from torch import nn

 from transformers import (
     Adafactor,
     AdamW,
     get_constant_schedule,
     get_constant_schedule_with_warmup,
     get_cosine_schedule_with_warmup,
     get_cosine_with_hard_restarts_schedule_with_warmup,
     get_inverse_sqrt_schedule,
     get_linear_schedule_with_warmup,
     get_polynomial_decay_schedule_with_warmup,
 )


def      _snake_case						(						_snake_case				:			Tuple ,   _snake_case				:			Union[str, Any]=10			):
      lowerCAmelCase					:	Dict       =   []
      for _ in range(_snake_case			):
            lrs.append(scheduler.get_lr()[0]			)
            scheduler.step()
      return lrs


def      _snake_case						(						_snake_case				:			Optional[int] ,   _snake_case				:			int=10			):
      lowerCAmelCase					:	Optional[int]       =   []
      for step in range(_snake_case			):
            lrs.append(scheduler.get_lr()[0]			)
            scheduler.step()
            if step == num_steps // 2:
                  with tempfile.TemporaryDirectory() as tmpdirname:
                        lowerCAmelCase					:	List[str]       =   os.path.join(_snake_case ,   '''schedule.bin'''			)
                        torch.save(scheduler.state_dict() ,   _snake_case			)

                        lowerCAmelCase					:	List[Any]       =   torch.load(_snake_case			)
                        scheduler.load_state_dict(_snake_case			)
      return lrs



@require_torch
class 		snake_case_(       unittest.TestCase			):






     def      lowerCamelCase__     (	self  :					Optional[int]					,				UpperCamelCase_  :					Optional[int]					,				UpperCamelCase_  :					str					,				UpperCamelCase_  :					Any				):
           self.assertEqual(len(UpperCamelCase_				)					,				len(UpperCamelCase_				)				)
           for a, b in zip(UpperCamelCase_					,				UpperCamelCase_				):
                 self.assertAlmostEqual(UpperCamelCase_					,				UpperCamelCase_					,				delta=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Tuple				):
           lowerCAmelCase					:	Any       =   torch.tensor([0.1, -0.2, -0.1]					,				requires_grad=UpperCamelCase_				)
           lowerCAmelCase					:	List[str]       =   torch.tensor([0.4, 0.2, -0.5]				)
           lowerCAmelCase					:	List[Any]       =   nn.MSELoss()
           # No warmup, constant schedule, no gradient clipping
           lowerCAmelCase					:	Union[str, Any]       =   AdamW(params=[w]					,				lr=2E-1					,				weight_decay=0.0				)
           for _ in range(1_0_0				):
                 lowerCAmelCase					:	Union[str, Any]       =   criterion(UpperCamelCase_					,				UpperCamelCase_				)
                 loss.backward()
                 optimizer.step()
                 w.grad.detach_()  # No zero_grad() function on simple tensors. we do it ourselves.
                 w.grad.zero_()
           self.assertListAlmostEqual(w.tolist()					,				[0.4, 0.2, -0.5]					,				tol=1E-2				)






     def      lowerCamelCase__     (	self  :					Union[str, Any]				):
           lowerCAmelCase					:	Tuple       =   torch.tensor([0.1, -0.2, -0.1]					,				requires_grad=UpperCamelCase_				)
           lowerCAmelCase					:	Union[str, Any]       =   torch.tensor([0.4, 0.2, -0.5]				)
           lowerCAmelCase					:	Optional[int]       =   nn.MSELoss()
           # No warmup, constant schedule, no gradient clipping
           lowerCAmelCase					:	Any       =   Adafactor(
               params=[w]					,				lr=1E-2					,				eps=(1E-30, 1E-3)					,				clip_threshold=1.0					,				decay_rate=-0.8					,				betaa=UpperCamelCase_					,				weight_decay=0.0					,				relative_step=UpperCamelCase_					,				scale_parameter=UpperCamelCase_					,				warmup_init=UpperCamelCase_					,				)
           for _ in range(1_0_0_0				):
                 lowerCAmelCase					:	List[Any]       =   criterion(UpperCamelCase_					,				UpperCamelCase_				)
                 loss.backward()
                 optimizer.step()
                 w.grad.detach_()  # No zero_grad() function on simple tensors. we do it ourselves.
                 w.grad.zero_()
           self.assertListAlmostEqual(w.tolist()					,				[0.4, 0.2, -0.5]					,				tol=1E-2				)



@require_torch
class 		snake_case_(       unittest.TestCase			):
     __UpperCamelCase  =					nn.Linear(50							,					50			) if is_torch_available() else None
     __UpperCamelCase  =					AdamW(m.parameters()							,					lr=10.0			) if is_torch_available() else None
     __UpperCamelCase  =					10






     def      lowerCamelCase__     (	self  :					Union[str, Any]					,				UpperCamelCase_  :					str					,				UpperCamelCase_  :					str					,				UpperCamelCase_  :					Optional[Any]					,				UpperCamelCase_  :					Union[str, Any]=None				):
           self.assertEqual(len(UpperCamelCase_				)					,				len(UpperCamelCase_				)				)
           for a, b in zip(UpperCamelCase_					,				UpperCamelCase_				):
                 self.assertAlmostEqual(UpperCamelCase_					,				UpperCamelCase_					,				delta=UpperCamelCase_					,				msg=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Union[str, Any]				):
           lowerCAmelCase					:	Tuple       =   {'''num_warmup_steps''': 2, '''num_training_steps''': 1_0}
           # schedulers doct format
           # function: (sched_args_dict, expected_learning_rates)
           lowerCAmelCase					:	Optional[Any]       =   {
               get_constant_schedule: ({}, [10.0] * self.num_steps),
               get_constant_schedule_with_warmup: (
                   {'''num_warmup_steps''': 4},
                   [0.0, 2.5, 5.0, 7.5, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
               ),
               get_linear_schedule_with_warmup: (
                   {**common_kwargs},
                   [0.0, 5.0, 10.0, 8.75, 7.5, 6.25, 5.0, 3.75, 2.5, 1.25],
               ),
               get_cosine_schedule_with_warmup: (
                   {**common_kwargs},
                   [0.0, 5.0, 10.0, 9.61, 8.53, 6.91, 5.0, 3.08, 1.46, 0.38],
               ),
               get_cosine_with_hard_restarts_schedule_with_warmup: (
                   {**common_kwargs, '''num_cycles''': 2},
                   [0.0, 5.0, 10.0, 8.53, 5.0, 1.46, 10.0, 8.53, 5.0, 1.46],
               ),
               get_polynomial_decay_schedule_with_warmup: (
                   {**common_kwargs, '''power''': 2.0, '''lr_end''': 1E-7},
                   [0.0, 5.0, 10.0, 7.656, 5.625, 3.906, 2.5, 1.406, 0.625, 0.156],
               ),
               get_inverse_sqrt_schedule: (
                   {'''num_warmup_steps''': 2},
                   [0.0, 5.0, 10.0, 8.165, 7.071, 6.325, 5.774, 5.345, 5.0, 4.714],
               ),
           }

           for scheduler_func, data in scheds.items():
                 lowerCAmelCase,      lowerCAmelCase					:	Union[str, Any]       =   data

                 lowerCAmelCase					:	List[Any]       =   scheduler_func(self.optimizer					,				**UpperCamelCase_				)
                 self.assertEqual(len([scheduler.get_lr()[0]]				)					,				1				)
                 lowerCAmelCase					:	str       =   unwrap_schedule(UpperCamelCase_					,				self.num_steps				)
                 self.assertListAlmostEqual(
                     UpperCamelCase_					,				UpperCamelCase_					,				tol=1E-2					,				msg=F'''failed for {scheduler_func} in normal scheduler'''					,				)

                 lowerCAmelCase					:	Optional[int]       =   scheduler_func(self.optimizer					,				**UpperCamelCase_				)
                 if scheduler_func.__name__ != "get_constant_schedule":
                       LambdaScheduleWrapper.wrap_scheduler(UpperCamelCase_				)  # wrap to test picklability of the schedule
                 lowerCAmelCase					:	List[Any]       =   unwrap_and_save_reload_schedule(UpperCamelCase_					,				self.num_steps				)
                 self.assertListEqual(UpperCamelCase_					,				UpperCamelCase_					,				msg=F'''failed for {scheduler_func} in save and reload'''				)



class 		snake_case_:






     def __init__(	self  :					List[Any]					,				UpperCamelCase_  :					Any				):
           lowerCAmelCase					:	Tuple       =   fn






     def __call__(	self  :					Union[str, Any]					,				*UpperCamelCase_  :					Optional[Any]					,				**UpperCamelCase_  :					List[Any]				):
           return self.fn(*UpperCamelCase_					,				**UpperCamelCase_				)






     @classmethod
     def      lowerCamelCase__     (	self  :					Any					,				UpperCamelCase_  :					Optional[int]				):
           lowerCAmelCase					:	Union[str, Any]       =   list(map(self					,				scheduler.lr_lambdas				)				)


