code: def _get_weights(y_true, nb_ch):
      """
      args:
          y_true : 3-d ndarray in [batch_size, img_rows, img_cols]
          nb_ch : int
      return [float] weights
      """
      batch_size, img_rows, img_cols = y_true.shape
      pixels = batch_size * img_rows * img_cols
      weights = [
          torch.sum(y_true == ch).item() / pixels for ch in range(nb_ch)
      ]
      return weights
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 7 for calling a global function with example usage: _get_weights(y_true, nb_ch) and returns: weights