code: def test_sequence_encoders(
      enc_encoder: str,
      enc_cell_type: str,
      enc_dropout: float,
      enc_num_layers: int,
      enc_norm: Union[None, str],
      enc_reduce_output: Union[None, str],
      input_sequence: torch.Tensor,
  ):
      # update encoder parameters for specific unit test case
      encoder_parameters["cell_type"] = enc_cell_type
      encoder_parameters["dropout"] = enc_dropout
      encoder_parameters["num_layers"] = enc_num_layers
      encoder_parameters["norm"] = enc_norm
      encoder_parameters["reduce_output"] = enc_reduce_output
  
      # retrieve encoder to test
      encoder_obj = get_encoder_cls(SEQUENCE, enc_encoder)(
          **encoder_parameters
      )
      if torch.cuda.is_available():
          encoder_obj = encoder_obj.cuda()
  
      encoder_out = encoder_obj(input_sequence)
  
      assert ENCODER_OUTPUT in encoder_out
      assert isinstance(encoder_out[ENCODER_OUTPUT], torch.Tensor)
  
      if enc_encoder == "parallel_cnn":
          number_parallel_cnn_layers = PARALLEL_CNN_LAYERS
          output_dimension = (
              encoder_parameters["num_filters"]
              * number_parallel_cnn_layers
          )
          assert (
              encoder_out[ENCODER_OUTPUT].shape
              == (BATCH_SIZE, SEQ_SIZE, output_dimension)
              if enc_reduce_output is None
              else (BATCH_SIZE, output_dimension)
          )
  
      elif enc_encoder == "stacked_parallel_cnn":
          number_parallel_cnn_layers = PARALLEL_CNN_LAYERS
          output_dimension = (
              encoder_parameters["num_filters"]
              * number_parallel_cnn_layers
          )
          assert (
              encoder_out[ENCODER_OUTPUT].shape
              == (BATCH_SIZE, SEQ_SIZE, output_dimension)
              if enc_reduce_output is None
              else (BATCH_SIZE, output_dimension)
          )
  
      elif enc_encoder == "rnn":
          assert (
              encoder_out[ENCODER_OUTPUT].shape
              == (BATCH_SIZE, SEQ_SIZE, TEST_STATE_SIZE)
              if enc_reduce_output is None
              else (BATCH_SIZE, TEST_STATE_SIZE)
          )
  
          assert ENCODER_OUTPUT_STATE in encoder_out
          if enc_cell_type == "lstm":
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE], tuple
              )
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE][0], torch.Tensor
              )
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE][1], torch.Tensor
              )
              assert encoder_out[ENCODER_OUTPUT_STATE][0].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
              assert encoder_out[ENCODER_OUTPUT_STATE][1].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
          else:
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE], torch.Tensor
              )
              assert encoder_out[ENCODER_OUTPUT_STATE].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
  
      elif enc_encoder == "cnnrnn":
          assert (
              encoder_out[ENCODER_OUTPUT].shape[1:]
              == encoder_obj.output_shape
          )
          assert ENCODER_OUTPUT_STATE in encoder_out
  
          if enc_cell_type == "lstm":
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE], tuple
              )
              assert encoder_out[ENCODER_OUTPUT_STATE][0].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
              assert encoder_out[ENCODER_OUTPUT_STATE][1].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
          else:
              assert isinstance(
                  encoder_out[ENCODER_OUTPUT_STATE], torch.Tensor
              )
              assert encoder_out[ENCODER_OUTPUT_STATE].shape == (
                  BATCH_SIZE,
                  TEST_STATE_SIZE,
              )
  
      elif enc_encoder == "stacked_cnn":
          assert (
              encoder_out[ENCODER_OUTPUT].shape[1:]
              == encoder_obj.output_shape
          )
  
      elif enc_encoder == "embed":
          assert (
              encoder_out[ENCODER_OUTPUT].shape
              == (BATCH_SIZE, SEQ_SIZE, TEST_EMBEDDING_SIZE)
              if enc_reduce_output is None
              else (BATCH_SIZE, TEST_EMBEDDING_SIZE)
          )
  
      elif enc_encoder == "transformer":
          assert (
              encoder_out[ENCODER_OUTPUT].shape[1:]
              == encoder_obj.output_shape
          )
  
      elif enc_encoder == "passthrough":
          assert (
              encoder_out[ENCODER_OUTPUT].shape
              == (BATCH_SIZE, SEQ_SIZE, 1)
              if enc_reduce_output is None
              else (BATCH_SIZE, 1)
          )
  
      else:
          raise ValueError(
              f"{enc_encoder} is an invalid encoder specification"
          )
  
file_path: ludwig/tests/integration_tests/test_sequence_encoders.py
imports: import logging
  from typing import Union
  import numpy
  import pytest
  import torch
  from ludwig.constants import ENCODER_OUTPUT, ENCODER_OUTPUT_STATE, SEQUENCE
  from ludwig.encoders.registry import get_encoder_cls
  from tests.integration_tests.utils import ENCODERS
label_desc: Use image node_id 2 for calling a global function with example usage: test_sequence_encoders(enc_encoder, enc_cell_type, enc_dropout, enc_num_layers, enc_norm, enc_reduce_output, input_sequence) without return types