code: def test_vardrop():
      def check_vardrop(drop_inputs, drop_states, drop_outputs):
          cell = gluon.rnn.VariationalDropoutCell(
              mx.gluon.rnn.RNNCell(100),
              drop_outputs=drop_outputs,
              drop_states=drop_states,
              drop_inputs=drop_inputs,
          )
  
          input_data = mx.np.random.uniform(
              size=(10, 3, 50), device=mx.device.current_device()
          )
          cell.infer_shape(0, input_data, False)
          cell.initialize(init="xavier")
          with mx.autograd.record():
              outputs1, _ = cell.unroll(
                  3, input_data, merge_outputs=True
              )
              mx.npx.waitall()
              outputs2, _ = cell.unroll(
                  3, input_data, merge_outputs=True
              )
          assert not almost_equal(
              outputs1.asnumpy(), outputs2.asnumpy()
          )
  
          inputs = [mx.np.ones(shape=(10, 50)) for i in range(3)]
          cell.infer_shape(0, inputs[0], False)
          cell.initialize()
          outputs, _ = cell.unroll(3, inputs, merge_outputs=False)
  
          outs = [o.shape for o in outputs]
          assert outs == [(10, 100), (10, 100), (10, 100)]
  
          cell.reset()
          cell.hybridize()
          with mx.autograd.record():
              outputs3, _ = cell.unroll(
                  3, input_data, merge_outputs=True
              )
              mx.npx.waitall()
              outputs4, _ = cell.unroll(
                  3, input_data, merge_outputs=True
              )
          assert not almost_equal(
              outputs3.asnumpy(), outputs4.asnumpy()
          )
          assert not almost_equal(
              outputs1.asnumpy(), outputs3.asnumpy()
          )
  
      check_vardrop(0.5, 0.5, 0.5)
      check_vardrop(0.5, 0, 0.5)
  
imports: import mxnet
  from mxnet import gluon, np
  import numpy
  import copy
  from functools import partial
  from numpy.testing import assert_allclose
  from mxnet.gluon.utils import split_rnn_params
  import pytest
  from mxnet.test_utils import almost_equal, assert_almost_equal, default_device
  from common import assert_raises_cudnn_not_satisfied, retry
label_desc: Use image node_id 40 for calling a global function with example usage: test_vardrop() without return types