code: def test_dict_class_weights_text():
      input_features = [text_feature()]
      output_features = [
          text_feature(
              decoder={"vocab_size": 3, "max_sequence_length": 10}
          )
      ]
      config = {
          "input_features": input_features,
          "output_features": output_features,
      }
  
      # Set class weights as dictionary on config
      class_weights_dict = {
          "<EOS>": 0,
          "<SOS>": 0,
          "<PAD>": 0,
          "<UNK>": 0,
          "token_1": 0.5,
          "token_2": 0.4,
          "token_3": 0.1,
      }
      config["output_features"][0]["loss"] = {
          "type": "sequence_softmax_cross_entropy",
          "class_weights": class_weights_dict,
      }
  
      # Mock feature metadata
      feature_metadata = {
          "idx2str": [
              "<EOS>",
              "<SOS>",
              "<PAD>",
              "<UNK>",
              "token_1",
              "token_2",
              "token_3",
          ],
          "str2idx": {
              "<EOS>": 0,
              "<SOS>": 1,
              "<PAD>": 2,
              "<UNK>": 3,
              "token_1": 4,
              "token_2": 5,
              "token_3": 6,
          },
          "str2freq": {
              "<EOS>": 0,
              "<SOS>": 0,
              "<PAD>": 0,
              "<UNK>": 0,
              "token_1": 300,
              "token_2": 200,
              "token_3": 100,
          },
          "str2idf": None,
          "vocab_size": 7,
          "max_sequence_length": 9,
          "max_sequence_length_99ptile": 9.0,
          "pad_idx": 2,
          "padding_symbol": "<PAD>",
          "unknown_symbol": "<UNK>",
          "index_name": None,
          "preprocessing": {
              "prompt": {
                  "retrieval": {
                      "type": None,
                      "index_name": None,
                      "model_name": None,
                      "k": 0,
                  },
                  "task": None,
                  "template": None,
              },
              "pretrained_model_name_or_path": None,
              "tokenizer": "space_punct",
              "vocab_file": None,
              "sequence_length": None,
              "max_sequence_length": 256,
              "most_common": 20000,
              "padding_symbol": "<PAD>",
              "unknown_symbol": "<UNK>",
              "padding": "right",
              "lowercase": True,
              "missing_value_strategy": "drop_row",
              "fill_value": "<UNK>",
              "computed_fill_value": "<UNK>",
              "ngram_size": 2,
              "cache_encoder_embeddings": False,
              "compute_idf": False,
          },
      }
  
      model_config = ModelConfig.from_dict(config)
  
      TextOutputFeature.update_config_with_metadata(
          feature_config=model_config.output_features[0],
          feature_metadata=feature_metadata,
      )
  
      assert model_config.output_features[0].loss.class_weights == [
          0,
          0,
          0,
          0,
          0.5,
          0.4,
          0.1,
      ]
  
imports: import contextlib
  from typing import Optional, Type, Union
  import pytest
  import torch
  from marshmallow import ValidationError
  from ludwig.features.category_feature import CategoryOutputFeature
  from ludwig.features.set_feature import SetOutputFeature
  from ludwig.features.text_feature import TextOutputFeature
  from ludwig.modules import loss_modules
  from ludwig.schema.features.loss.loss import BWCEWLossConfig, CORNLossConfig, HuberLossConfig, MAELossConfig, MAPELossConfig, MSELossConfig, RMSELossConfig, RMSPELossConfig, SigmoidCrossEntropyLossConfig, SoftmaxCrossEntropyLossConfig
  from ludwig.schema.model_config import ModelConfig
  from tests.integration_tests.utils import category_feature, set_feature, text_feature
label_desc: Use image node_id 14 for calling a global function with example usage: test_dict_class_weights_text() without return types