code: def test_bayesian_gru():
      input_size = 2
      hidden_size = 3
      batch_size = 4
      seq_len = 5
  
      # Construct a simple GRU.
      gru = nn.GRU(input_size, hidden_size)
      input_ = torch.randn(seq_len, batch_size, input_size)
      output, _ = gru(input_)
      assert output.shape == (seq_len, batch_size, hidden_size)
      output2, _ = gru(input_)
      assert torch.allclose(output2, output)
  
      # Make it Bayesian.
      to_pyro_module_(gru)
      for name, value in list(gru.named_parameters(recurse=False)):
          prior = (
              dist.Normal(0, 1)
              .expand(value.shape)
              .to_event(value.dim())
          )
          setattr(gru, name, PyroSample(prior=prior))
      output, _ = gru(input_)
      assert output.shape == (seq_len, batch_size, hidden_size)
      output2, _ = gru(input_)
      assert not torch.allclose(output2, output)
  
imports: import io
  import warnings
  import pytest
  import torch
  from torch import nn
  from torch.distributions import constraints, transform_to
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import SVI, Trace_ELBO
  from pyro.nn.module import PyroModule, PyroParam, PyroSample, clear, to_pyro_module_
  from pyro.optim import Adam
  from tests.common import assert_equal
label_desc: Use image node_id 20 for calling a global function with example usage: test_bayesian_gru() without return types