code: def test_adult_encoder(input_dim, hidden_dim, latent_dim):
      """Tests whether the latent representation is [-1, 1] and has the expected shape,
      and if the fully connected hidden layers have the expected shapes.
      """
      x = torch.randn(1, input_dim)
      model = ADULTEncoder(hidden_dim=hidden_dim, latent_dim=latent_dim)
  
      z = model(x)
      assert z.shape[-1] == latent_dim
      assert torch.all((z >= -1) & (z <= 1))
  
      layers = list(model.children())
      w1, b1 = layers[0].weight, layers[0].bias
      assert w1.shape == (hidden_dim, input_dim)
      assert b1.shape == (hidden_dim,)
  
      w2, b2 = layers[1].weight, layers[1].bias
      assert w2.shape == (latent_dim, hidden_dim)
      assert b2.shape == (latent_dim,)
  
file_path: alibi/alibi/models/pytorch/tests/test_cfrl_models.py
imports: import pytest
  import torch
  from alibi.models.pytorch import AE, HeAE
  from alibi.models.pytorch.cfrl_models import ADULTDecoder, ADULTEncoder, MNISTClassifier, MNISTDecoder, MNISTEncoder
label_desc: Use image node_id 3 for calling a global function with example usage: test_adult_encoder(input_dim, hidden_dim, latent_dim) without return types