code: def update_config_with_metadata(
      feature_config, feature_metadata, *args, **kwargs
  ):
      feature_config.decoder.vocab_size = feature_metadata["vocab_size"]
      feature_config.decoder.max_sequence_length = feature_metadata[
          "max_sequence_length"
      ]
      if isinstance(feature_config.loss.class_weights, (list, tuple)):
          if (
              len(feature_config.loss.class_weights)
              != feature_config.decoder.vocab_size
          ):
              raise ValueError(
                  f"The length of class_weights ({len(feature_config.loss.class_weights)}) is not compatible with "
                  f"the number of classes ({feature_config.decoder.vocab_size}) for feature {feature_config.column}. "
                  "Check the metadata JSON file to see the classes "
                  "and their order and consider there needs to be a weight "
                  "for the <UNK> and <PAD> class too."
              )
  
      if isinstance(feature_config.loss.class_weights, dict):
          if (
              feature_metadata["str2idx"].keys()
              != feature_config.loss.class_weights.keys()
          ):
              raise ValueError(
                  f"The class_weights keys ({feature_config.loss.class_weights.keys()}) are not compatible with "
                  f'the classes ({feature_metadata["str2idx"].keys()}) of feature {feature_config.column}. '
                  "Check the metadata JSON file to see the classes "
                  "and consider there needs to be a weight "
                  "for the <UNK> class too."
              )
          else:
              class_weights = feature_config.loss.class_weights
              idx2str = feature_metadata["idx2str"]
              class_weights_list = [class_weights[s] for s in idx2str]
              feature_config.loss.class_weights = class_weights_list
  
      if feature_config.loss.class_similarities_temperature > 0:
          if "class_similarities" in feature_config.loss:
              similarities = feature_config.loss.class_similarities
              temperature = (
                  feature_config.loss.class_similarities_temperature
              )
  
              curr_row = 0
              first_row_length = 0
              is_first_row = True
              for row in similarities:
                  if is_first_row:
                      first_row_length = len(row)
                      is_first_row = False
                      curr_row += 1
                  else:
                      curr_row_length = len(row)
                      if curr_row_length != first_row_length:
                          raise ValueError(
                              "The length of row {} of the class_similarities "
                              "of {} is {}, different from the length of "
                              "the first row {}. All rows must have "
                              "the same length.".format(
                                  curr_row,
                                  feature_config.column,
                                  curr_row_length,
                                  first_row_length,
                              )
                          )
                      else:
                          curr_row += 1
              all_rows_length = first_row_length
  
              if all_rows_length != len(similarities):
                  raise ValueError(
                      f"The class_similarities matrix of {feature_config.column} has "
                      f"{len(similarities)} rows and {all_rows_length} columns, "
                      "their number must be identical."
                  )
  
              if all_rows_length != feature_config.decoder.vocab_size:
                  raise ValueError(
                      f"The size of the class_similarities matrix of {feature_config.column} is "
                      f"{all_rows_length}, different from the number of classes "
                      f"({feature_config.decoder.vocab_size}). Check the metadata JSON file to see the classes "
                      "and their order and "
                      "consider <UNK> and <PAD> class too."
                  )
  
              similarities = np.array(similarities, dtype=np.float32)
              for i in range(len(similarities)):
                  similarities[i, :] = softmax(
                      similarities[i, :], temperature=temperature
                  )
              feature_config.loss.class_similarities = similarities
          else:
              raise ValueError(
                  "class_similarities_temperature > 0, "
                  "but no class_similarities are provided "
                  f"for feature {feature_config.column}"
              )
  
imports: import logging
  from functools import partial
  from typing import Dict, List, Union
  import numpy
  import torch
  from ludwig.constants import COLUMN, LAST_PREDICTIONS, LENGTHS, NAME, PREDICTIONS, PROBABILITIES, PROBABILITY, PROC_COLUMN, SEQUENCE
  from ludwig.features.base_feature import BaseFeatureMixin, InputFeature, OutputFeature, PredictModule
  from ludwig.features.feature_utils import compute_sequence_probability, compute_token_probabilities
  from ludwig.schema.features.sequence_feature import SequenceInputFeatureConfig, SequenceOutputFeatureConfig
  from ludwig.types import FeatureMetadataDict, FeaturePostProcessingOutputDict, ModelConfigDict, PreprocessingConfigDict, TrainingSetMetadataDict
  from ludwig.utils import output_feature_utils
  from ludwig.utils.math_utils import softmax
  from ludwig.utils.strings_utils import build_sequence_matrix, create_vocabulary, SpecialSymbol, START_SYMBOL, STOP_SYMBOL, UNKNOWN_SYMBOL
  from ludwig.utils.tokenizers import get_tokenizer_from_registry
  from ludwig.utils.types import TorchscriptPreprocessingInput
label_desc: Use image node_id 8 for calling the SequenceOutputFeature obj's underlying member method code with example usage: obj.update_config_with_metadata(feature_config, feature_metadata) without return types