code: def compute_token_probabilities(
      probabilities: Union[list, tuple, np.ndarray],
  ) -> np.ndarray:
      """Gets the maximum probability per timestep.
  
      Args:
          probabilities: An iterable of iterables or np.ndarray with shape (sequence_length, num_classes)
              where each inner iterable or np.ndarray is the probability distribution for a single timestep.
      Returns:
          An np.ndarray with shape (sequence_length,) containing the maximum probability for each timestep.
      """
      if isinstance(probabilities, (list, tuple)):
          if not hasattr(probabilities[0], "__len__"):
              raise ValueError(
                  "Received token probabilities as a flat 1D list. Expected list of list of probabilities "
                  "(sequence_length, vocab_size)."
              )
          max_probs = []
          for timestep_probs in probabilities:
              max_probs.append(np.max(timestep_probs))
          max_probs = np.array(max_probs)
      elif isinstance(probabilities, np.ndarray):
          if len(probabilities.shape) != 2:
              raise ValueError(
                  f"Received token probabilities with non 2D shape: {probabilities.shape}. Expected shape: "
                  "(sequence_length, vocab_size)."
              )
          max_probs = np.max(probabilities, axis=-1)
      else:
          raise ValueError(
              f"probabilities type must be in [list, tuple, np.ndarray]. Got {type(probabilities)}"
          )
      return max_probs
  
imports: import re
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from ludwig.constants import NAME, PREPROCESSING, SEQUENCE, TEXT, TIMESERIES, TYPE
  from ludwig.utils.data_utils import hash_dict
  from ludwig.utils.strings_utils import get_tokenizer_from_registry, UNKNOWN_SYMBOL
label_desc: Use image node_id 3 for calling a global function with example usage: compute_token_probabilities(probabilities) and returns: max_probs