code: def get_custom_or_automatic_label_weights(
      vocab_dict,
      label_counts,
      label_weights_field,
      automatic_label_weighting_method_field,
  ):
      if label_weights_field and automatic_label_weighting_method_field:
          label_weights = get_automatic_label_weights(
              vocab_dict,
              label_counts,
              automatic_label_weighting_method_field,
          )
          custom_labels = []
          for label, custom_weight in label_weights_field.items():
              if label in vocab_dict:
                  label_weights[0][vocab_dict[label]] = custom_weight
                  custom_labels.append(label)
          logging.warning(
              f"WARNING: following labels are updated with user provided custom values \
              {custom_labels}"
          )
      elif label_weights_field:
          label_weights = get_label_weights(
              vocab_dict, label_weights_field
          )
      elif automatic_label_weighting_method_field:
          label_weights = get_automatic_label_weights(
              vocab_dict,
              label_counts,
              automatic_label_weighting_method_field,
          )
      else:
          return
      logging.info(f"INFO: Final label weights are {label_weights}")
      return label_weights
  
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 1 for calling a global function with example usage: get_custom_or_automatic_label_weights(vocab_dict, label_counts, label_weights_field, automatic_label_weighting_method_field) and returns: label_weights