code: def get_freq_weights_bce_with_logits_loss(label_freq):
      """
      Calculate positive class weights to be passed to BCEWithLogitsLoss
      https://pytorch.org/docs/1.9.1/generated/torch.nn.BCEWithLogitsLoss.html
  
      Args:
          label_freq: dictionary of tuples where keys represents class id, and tuple represents counts of positive and negative classes,
                      positive classes are at index 1 and negative at index 0
      Returns:
          weights: dictionary of labels with their weights
      """
      weights = {}
  
      for label_id, class_values in label_freq.items():
          positive_class = class_values[1]
          negative_class = class_values[0]
  
          if positive_class == 0:
              weights[label_id] = 0
  
          else:
              weights[label_id] = float(negative_class) / float(
                  positive_class
              )
  
      return weights
  
imports: import csv
  import json
  import os
  import pickle
  import random
  import re
  import string
  from collections import Counter
  import numpy
  import torch
  from tqdm.auto import tqdm
  from nemo.utils import logging
  from nemo.utils.env_var_parsing import get_envint
label_desc: Use image node_id 26 for calling a global function with example usage: get_freq_weights_bce_with_logits_loss(label_freq) and returns: weights