code: def class_weight_tensor(class_weights, target_dim, label_encoder):
      """
      Convert from dictionary of class weights to tf tensor
      """
      class_weight_arr = np.ones(target_dim, dtype=np.float32)
      for i, cls in enumerate(label_encoder.target_labels):
          class_weight_arr[i] = class_weights.get(cls, 1.0)
  
      class_weight_tensor = tf.convert_to_tensor(value=class_weight_arr)
      return class_weight_tensor
  
file_path: finetune/finetune/util/imbalance.py
imports: import tensorflow
  import numpy
  from collections import Counter
  from finetune.encoding.target_encoders import LabelEncoder
  from finetune.errors import FinetuneError
label_desc: Use image node_id 3 for calling a global function with example usage: class_weight_tensor(class_weights, target_dim, label_encoder) and returns: class_weight_tensor