code: def get_auto_label_weights(
      vocab_dict: Dict[str, int], label_counts: Counter
  ):
      """
      label weights automatically calculated from training data
      """
      label_weights = {}
      for label in vocab_dict:
          if label in label_counts:
              pos_count = label_counts[label]
              neg_count = sum(label_counts.values()) - pos_count
              weight = neg_count / pos_count
              label_weights[label] = weight
          else:
              label_weights[label] = 1.0
  
      # initialize
      weights_tensor = torch.ones(1, len(label_weights.keys()))
      for label, weight in label_weights.items():
          weights_tensor[0][vocab_dict[label]] = weight
  
      return weights_tensor
  
file_path: pytext/pytext/utils/label.py
imports: import logging
  from collections import Counter
  from typing import Dict
  import torch
  from pytext.utils.cuda import tensor
  from pytext.utils.typing import WeightingMethod
label_desc: Use image node_id 4 for calling a global function with example usage: get_auto_label_weights(vocab_dict, label_counts) and returns: weights_tensor