code: def get_label_weights(
      vocab_dict: Dict[str, int], label_weights: Dict[str, float]
  ):
      """
      Get label weights from user-provided label_weights field
      """
      # prune the label_weights to remove the labels that do not exist in the dataset
      pruned_label_weights = {
          vocab_dict[k]: v
          for (k, v) in label_weights.items()
          if k in vocab_dict
      }
      if len(pruned_label_weights) != len(label_weights):
          filtered_labels = [
              k for k in label_weights if k not in vocab_dict
          ]
          logging.warning(
              f"WARNING: these labels are filtered from original label weights \
              {filtered_labels}"
          )
      if len(pruned_label_weights) == 0:
          return None
  
      # All unspecified classes will get a weight of 1
      weights_tensor = [1] * len(vocab_dict)
      for k, v in pruned_label_weights.items():
          weights_tensor[k] = v
      return tensor(weights_tensor, dtype=torch.float)
  
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 2 for calling a global function with example usage: get_label_weights(vocab_dict, label_weights) and returns: tensor, None