class_docstr: Megatron encoder-decoder base class
class_docstr_tok: ["Megatron","encoder-decoder","base","class"]
docstr: A helper method that converts arguments into positional arguments (by name)
  
  args - a list of arguments to pass to self.enc_dec_model (tensors from batch)
  args_name - a list of argument name (to be matched against allowed kwargs)
  kwargs - a dict {arg name: arg value} (used for non-tensor values)
docstr_tok: ["A","helper","method","that","converts","arguments","into","positional","arguments","(","by","name",")","args","-","a","list","of","arguments","to","pass","to","self.enc_dec_model","(","tensors","from","batch",")","args_name","-","a","list","of","argument","name","(","to","be","matched","against","allowed","kwargs",")","kwargs","-","a","dict","{","arg","name",":","arg","value","}","(","used","for","non-tensor","values",")"]
code: def _build_forward_args_from_kwargs(self, args_name, args, **kwargs):
      """
      A helper method that converts arguments into positional arguments (by name)
  
      args - a list of arguments to pass to self.enc_dec_model (tensors from batch)
      args_name - a list of argument name (to be matched against allowed kwargs)
      kwargs - a dict {arg name: arg value} (used for non-tensor values)
      """
      # sanity checks
      if len(args) != len(args_name):
          raise ValueError(
              f"Mismatch between length in args_name ({len(args_name)}) and args ({len(args)})"
          )
      if any([n in kwargs for n in args_name]):
          raise ValueError(
              f"args_name = {args_name} cannot overlap kwargs = {list(kwargs.keys())}"
          )
  
      # get mapping of kwarg names to arg index
      kwargs_to_arg_idx = self._kwargs_to_arg_idx()
  
      # collect all arguments
      all_args_name = args_name[:]
      all_args = args[:]
      for k, v in kwargs.items():
          all_args_name.append(k)
          all_args.append(v)
  
      args_idx = [kwargs_to_arg_idx[n] for n in all_args_name]
  
      # print(f"all_args_name = {all_args_name}   args_idx = {args_idx}")
  
      # construct args ordered by name (with None as place-holder)
      forward_args = [None] * (max(args_idx) + 1)
      for i, v in zip(args_idx, all_args):
          forward_args[i] = v
  
      return forward_args
  
imports: import copy
  import functools
  import inspect
  from typing import Any, Dict, List, Optional
  import torch
  from omegaconf import OmegaConf, open_dict
  from omegaconf.dictconfig import DictConfig
  from pytorch_lightning.accelerators import CPUAccelerator
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.nlp.data.language_modeling.megatron.data_samplers import MegatronPretrainingRandomSampler, MegatronPretrainingSampler
  from nemo.collections.nlp.models.language_modeling.megatron_base_model import MegatronBaseModel
  from nemo.collections.nlp.modules.common.megatron.build_model import build_model
  from nemo.collections.nlp.modules.common.megatron.module import Float16Module
  from nemo.collections.nlp.modules.common.megatron.token_level_encoder_decoder import MegatronTokenLevelEncoderDecoderModule
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults, average_losses_across_data_parallel_group, get_params_for_weight_decay_optimization
  from nemo.collections.nlp.modules.common.text_generation_utils import compute_beam_search_len_penalty, get_sampling_token_fn
  from nemo.collections.nlp.parts.utils_funcs import get_last_rank
  from nemo.utils import AppState, logging
label_desc: Use image node_id 20 for calling the MegatronLMEncoderDecoderModel obj's underlying member method code with example usage: obj._build_forward_args_from_kwargs(args_name, args) and returns: forward_args