docstr: Used for generate method only for now.
docstr_tok: ["Used","for","generate","method","only","for","now","."]
code: def get_forward_output_only_func(self):
      """
      Used for generate method only for now.
      """
  
      def fwd_output_only_func(dataloader_iter, model):
          batch = next(dataloader_iter)
          extra_arg = {}
          (
              tokens,
              attention_mask,
              position_ids,
              task_ids,
              set_inference_key_value_memory,
              inference_max_sequence_len,
          ) = batch
  
          tokens = tokens.cuda()
          attention_mask = attention_mask.cuda()
          position_ids = position_ids.cuda()
          task_ids = task_ids.cuda()
          extra_arg[
              "set_inference_key_value_memory"
          ] = set_inference_key_value_memory[0].item()
          extra_arg[
              "inference_max_sequence_len"
          ] = inference_max_sequence_len[0].item()
  
          output_tensor = model(
              tokens,
              position_ids,
              attention_mask,
              task_ids,
              **extra_arg,
          )
  
          def id_func(output_tensor):
              return output_tensor, {"logits": output_tensor}
  
          return output_tensor, id_func
  
      return fwd_output_only_func
  
imports: import itertools
  import os
  import torch
  from omegaconf.dictconfig import DictConfig
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.common.parts.adapter_modules import LinearAdapterConfig
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_model import MegatronGPTModel
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_prompt_learning_model import MegatronGPTPromptLearningModel
  from nemo.collections.nlp.modules.common import VirtualPromptStyle
  from nemo.collections.nlp.modules.common.megatron.adapters.parallel_adapters import AdapterName, InfusedAdapterConfig, MLPInfusedAdapterConfig, ParallelLinearAdapterConfig
  from nemo.collections.nlp.modules.common.megatron.utils import average_losses_across_data_parallel_group
  from nemo.collections.nlp.parts.nlp_overrides import NLPSaveRestoreConnector
  from nemo.collections.nlp.parts.utils_funcs import get_last_rank
  from nemo.core.classes.mixins import adapter_mixins
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 5 for calling the MegatronGPTBaseAdapterModel obj's underlying member method code with example usage: obj.get_forward_output_only_func() and returns: fwd_output_only_func, output_tensor,  id_func, output_tensor,  dict