code: def to_prob(probabilities: np.ndarray):
      """
      If the probabilities array is not a distrubution will softmax it.
  
      Args:
          probabilities (array): [batch_size, num_classes, ...]
  
      Returns:
          Same as probabilities.
      """
      not_bounded = (
          np.min(probabilities) < 0 or np.max(probabilities) > 1.0
      )
      multiclass = probabilities.shape[1] > 1
      sum_to_one = np.allclose(probabilities.sum(1), 1)
      if not_bounded or (multiclass and not sum_to_one):
          if multiclass:
              probabilities = softmax(probabilities, 1)
          else:
              probabilities = expit(probabilities)
      return probabilities
  
imports: import numpy
  import torch
  from scipy.special import softmax, expit
label_desc: Use image node_id 1 for calling a global function with example usage: to_prob(probabilities) and returns: probabilities