code: def test_sequence_decoders(
      dec_cell_type,
      combiner_output_shapes,
      generate_sequence_training_data,
  ):
      # retrieve pre-computed dataset and features
      raw_df = generate_sequence_training_data[0]
      input_features = generate_sequence_training_data[1]
      output_features = generate_sequence_training_data[2]
      output_feature_name = output_features[0]["name"]
      output_features[0][DECODER]["cell_type"] = dec_cell_type
  
      with setup_model_scaffolding(
          raw_df, input_features, output_features
      ) as (model, _):
          # generate synthetic encoder_output tensors and make it look like
          # it came out of the combiner
          encoder_output = torch.randn(combiner_output_shapes[0])
          combiner_outputs = {"hidden": encoder_output}
  
          if combiner_output_shapes[1] is not None:
              if len(combiner_output_shapes[1]) > 1:
                  encoder_output_state = (
                      torch.randn(combiner_output_shapes[1][0]),
                      torch.randn(combiner_output_shapes[1][1]),
                  )
              else:
                  encoder_output_state = torch.randn(
                      combiner_output_shapes[1][0]
                  )
  
              combiner_outputs[
                  ENCODER_OUTPUT_STATE
              ] = encoder_output_state
  
          decoder = model.model.output_features.get(
              output_feature_name
          ).decoder_obj
          decoder_out = decoder(combiner_outputs)
  
          # gather expected components of the shape
          batch_size = combiner_outputs["hidden"].shape[0]
          seq_size = (
              output_features[0][DECODER]["max_len"] + 2
          )  # For start and stop symbols.
          vocab_size = model.config_obj.output_features.to_list()[0][
              DECODER
          ]["vocab_size"]
  
          # confirm shape and format of decoder output
          assert list(decoder_out[LOGITS].size()) == [
              batch_size,
              seq_size,
              vocab_size,
          ]
  
file_path: ludwig/tests/integration_tests/test_sequence_features.py
imports: import contextlib
  import copy
  from io import StringIO
  import pandas
  import pytest
  import torch
  from ludwig.api import LudwigModel
  from ludwig.constants import DECODER, ENCODER_OUTPUT_STATE, LOGITS
  from ludwig.data.dataset_synthesizer import build_synthetic_dataset
  from ludwig.data.preprocessing import preprocess_for_training
  from ludwig.features.feature_registries import update_config_with_metadata
  from tests.integration_tests.utils import generate_data, run_experiment, sequence_feature
label_desc: Use image node_id 3 for calling a global function with example usage: test_sequence_decoders(dec_cell_type, combiner_output_shapes, generate_sequence_training_data) without return types