code: def get_language_balancer_weights(items: list):
      language_names = np.array([item["language"] for item in items])
      unique_language_names = np.unique(language_names).tolist()
      language_ids = [
          unique_language_names.index(l) for l in language_names
      ]
      language_count = np.array(
          [
              len(np.where(language_names == l)[0])
              for l in unique_language_names
          ]
      )
      weight_language = 1.0 / language_count
      # get weight for each sample
      dataset_samples_weight = np.array(
          [weight_language[l] for l in language_ids]
      )
      # normalize
      dataset_samples_weight = dataset_samples_weight / np.linalg.norm(
          dataset_samples_weight
      )
      return torch.from_numpy(dataset_samples_weight).float()
  
imports: import os
  from typing import Any, Dict, List
  import fsspec
  import numpy
  import torch
  from coqpit import Coqpit
  from TTS.config import check_config_and_model_args
  from TTS.tts.utils.managers import BaseIDManager
label_desc: Use image node_id 2 for calling a global function with example usage: get_language_balancer_weights(items) and returns: torch