code: def test_categorical_dense_encoder(
      vocab: List[str], embedding_size: int, trainable: bool
  ):
      # make repeatable
      torch.manual_seed(RANDOM_SEED)
  
      dense_encoder = CategoricalEmbedEncoder(
          vocab=vocab,
          embedding_size=embedding_size,
          embeddings_trainable=trainable,
      ).to(DEVICE)
      inputs = torch.randint(len(vocab), (10,)).to(
          DEVICE
      )  # Chooses 10 items from vocab with replacement.
      inputs = torch.unsqueeze(inputs, 1)
      outputs = dense_encoder(inputs)[ENCODER_OUTPUT]
      # In dense mode, the embedding size should be less than or equal to vocab size.
      assert outputs.shape[-1] == min(embedding_size, len(vocab))
      # Ensures output shape matches encoder expected output shape.
      assert outputs.shape[1:] == dense_encoder.output_shape
  
      # check for parameter updating
      target = torch.randn(outputs.shape)
      fpc, tpc, upc, not_updated = check_module_parameters_updated(
          dense_encoder, (inputs,), target
      )
  
      if trainable:
          assert (
              fpc == 0
          ), "Embedding layer should be trainable, but found to be frozen."
      else:
          assert (
              fpc == 1
          ), "Embedding layer should be frozen, but found to be trainable."
  
      assert (
          upc == tpc
      ), f"Not all parameters updated.  Parameters not updated: {not_updated}.\nModule: {dense_encoder}"
  
file_path: ludwig/tests/ludwig/encoders/test_category_encoders.py
imports: from typing import List
  import pytest
  import torch
  from ludwig.constants import ENCODER_OUTPUT
  from ludwig.encoders.category_encoders import CategoricalEmbedEncoder, CategoricalSparseEncoder
  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 1 for calling a global function with example usage: test_categorical_dense_encoder(vocab, embedding_size, trainable) without return types