code: def test_sequence_encoder_embed():
      num_sentences = 4
      embedding_size = 5
      max_len = 6
  
      # make repeatable
      np.random.seed(RANDOM_SEED)
      torch.manual_seed(RANDOM_SEED)
  
      # Generate data
      text, vocab = generate_random_sentences(
          num_sentences=num_sentences,
          max_len=max_len,
      )
  
      encoder_kwargs = {
          "embedding_size": embedding_size,
          "vocab": vocab,
      }
  
      # Different values for reduce_output and the corresponding expected size
      reduce_outputs = ["sum", None, "concat"]
      output_shapes = [
          [num_sentences, embedding_size],
          [num_sentences, max_len, embedding_size],
          [num_sentences, max_len * embedding_size],
      ]
  
      for reduce_output, output_shape in zip(
          reduce_outputs, output_shapes
      ):
          for trainable in [True, False]:
              encoder_kwargs["reduce_output"] = reduce_output
              encoder_kwargs["embeddings_trainable"] = trainable
              encoder_kwargs["dropout"] = DROPOUT
              encoder = create_encoder(
                  SequenceEmbedEncoder,
                  max_sequence_length=max_len,
                  **encoder_kwargs,
              )
  
              encoder_test(
                  encoder=encoder,
                  input_data=text,
                  output_dtype=torch.float32,
                  output_shape=output_shape,
                  output_data=None,
              )
  
              assert encoder.embed_sequence.dropout is not None
  
              # test for parameter updates
              # generate tensors for parameter update test
              target = torch.rand(output_shape)
  
              # check for parameter updates
              (
                  fpc,
                  tpc,
                  upc,
                  not_updated,
              ) = check_module_parameters_updated(
                  encoder,
                  (torch.tensor(text, dtype=torch.int32),),
                  target,
              )
              assert upc == tpc, (
                  f"Not all trainable parameters updated.  Parameters not updated: {not_updated}."
                  f"  Module structure\n{encoder}"
              )
  
imports: import random
  import numpy
  import pytest
  import torch
  from ludwig.constants import ENCODER_OUTPUT
  from ludwig.data.dataset_synthesizer import build_vocab
  from ludwig.encoders.base import Encoder
  from ludwig.encoders.image.base import MLPMixerEncoder, Stacked2DCNN
  from ludwig.encoders.sequence_encoders import ParallelCNN, SequenceEmbedEncoder, StackedCNN, StackedCNNRNN, StackedParallelCNN, StackedRNN
  from ludwig.utils.torch_utils import get_torch_device
  from tests.integration_tests.parameter_update_utils import check_module_parameters_updated
label_desc: Use image node_id 9 for calling a global function with example usage: test_sequence_encoder_embed() without return types