code: def test_adult_decoder(input_dim, hidden_dim, output_dims):
      """Tests whether the reconstruction has the expected length and if each output
      head has the expected shape, and if the fully connected hidden layer have the
      expected shapes."""
      z = torch.randn(1, input_dim)
      model = ADULTDecoder(
          hidden_dim=hidden_dim, output_dims=output_dims
      )
  
      x_hat = model(z)
      assert len(x_hat) == len(output_dims)
      assert all(
          [
              x_hat[i].shape[-1] == output_dims[i]
              for i in range(len(output_dims))
          ]
      )
  
      layers = list(model.children())
      w1, b1 = layers[0].weight, layers[0].bias
      assert w1.shape == (hidden_dim, input_dim)
      assert b1.shape == (hidden_dim,)
  
      for i in range(len(output_dims)):
          w, b = layers[1][i].weight, layers[1][i].bias
          assert w.shape == (output_dims[i], hidden_dim)
          assert b.shape == (output_dims[i],)
  
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 4 for calling a global function with example usage: test_adult_decoder(input_dim, hidden_dim, output_dims) without return types