code: def sample_token_topk(
      logits,
      top_k=0,
      top_p=0.0,
      temperature=1.0,
      filter_value=-float("Inf"),
  ):
      """
      Greedy sampling. Returns the token with the highest probability, and corresponding log_prob.
  
      Args:
          logits: [batch_size, vocab_size] - unnormalized log probabilities of the next token
          top_k: int - if > 0: only sample from top k tokens with highest probability
          top_p: float - if > 0.0: only sample from a subset of candidates, where the cumulative probability
          temperature: float - temperature for sampling
          filter_value: float - value to set filtered tokens to
  
      Returns:
          log_probs: [batch_size] - log probabilities of the sampled tokens
          token_ids: [batch_size] - sampled token ids
      """
      logits = logits.float()
      logits /= temperature
      logits = top_k_logits(
          logits, top_k=top_k, top_p=top_p, filter_value=filter_value
      )
      log_probs = torch.nn.functional.log_softmax(logits, dim=-1)
  
      token_ids = torch.multinomial(
          log_probs.exp(), num_samples=1
      ).view(-1)
      log_probs = log_probs.gather(1, token_ids.unsqueeze(1)).squeeze(1)
  
      return log_probs, token_ids
  
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 19 for calling a global function with example usage: sample_token_topk(logits, top_k, top_p, temperature, filter_value) and returns: log_probs,  token_ids