code: def get_computeprob_response(tokenizer, response, inputs):
      if (
          parallel_state.is_pipeline_first_stage()
          or parallel_state.is_pipeline_last_stage()
      ):
          # we only have a response on the first and last pipeline stages
          compute_prob_response = {}
          new_token_ids = []
          new_tokens = []
          new_texts = []
          log_probs = []
          full_logprobs = []
          offsets = []
          for batch_id in range(len(response["tokens"])):
              if isinstance(inputs, (list, tuple)):
                  if isinstance(inputs[0], str):
                      new_token_id = tokenizer.text_to_ids(
                          inputs[batch_id]
                      )
                      new_text = inputs[batch_id]
                      token_len = len(new_token_id)
                  elif isinstance(inputs[0], torch.Tensor):
                      token_len = int(inputs[1][batch_id].item())
                      new_token_id = inputs[0][batch_id][
                          :token_len
                      ].tolist()
                      new_text = tokenizer.ids_to_text(new_token_id)
                  else:
                      raise TypeError(
                          f"Unsupported type of `inputs[0]`: {type(inputs[0])}. Supported types: `str`, `torch.Tensor`."
                      )
              else:
                  raise TypeError(
                      f"Unsupported type of parameter `inputs`: {type(inputs)}. Supported types: `list` and `tuple`"
                  )
              new_token_ids.append(new_token_id)
              new_tokens.append(
                  response["tokens"][batch_id][:token_len]
              )
              new_texts.append(new_text)
              log_probs.append(
                  response["logprob"][batch_id][:token_len]
              )
              full_logprobs.append(
                  response["full_logprob"][batch_id][:token_len]
              )
              offsets.append(response["offsets"][batch_id][:-1])
          compute_prob_response["sentences"] = new_texts
          compute_prob_response["tokens"] = new_tokens
          compute_prob_response["token_ids"] = new_token_ids
          compute_prob_response["logprob"] = log_probs
          compute_prob_response["full_logprob"] = full_logprobs
          compute_prob_response["offsets"] = offsets
          return compute_prob_response
      else:
          # intermediate stages
          return None
  
imports: import os
  import pickle
  import re
  from collections.abc import Iterable
  from functools import partial
  from typing import Callable, Tuple
  import numpy
  import torch
  import torch.nn.functional
  from nemo.collections.common.tokenizers.tabular_tokenizer import TabularTokenizer
  from nemo.collections.nlp.modules.common.megatron.utils import get_ltor_masks_and_position_ids
  from nemo.collections.nlp.modules.common.text_generation_strategy import model_inference_strategy_dispatcher
  from nemo.collections.nlp.modules.common.transformer.text_generation import LengthParam, OutputType, SamplingParam
  from nemo.utils import AppState
label_desc: Use image node_id 5 for calling a global function with example usage: get_computeprob_response(tokenizer, response, inputs) and returns: compute_prob_response, None