docstr: This method essentially tests whether autodiff will not throw any errors
  when you're doing maximum-likelihood learning with the transform. Many
  transforms have only one direction with an explicit inverse, hence why we
  pass in the inverse flag.
docstr_tok: ["This","method","essentially","tests","whether","autodiff","will","not","throw","any","errors","when","you","'re","doing","maximum-likelihood","learning","with","the","transform",".","Many","transforms","have","only","one","direction","with","an","explicit","inverse",",","hence","why","we","pass","in","the","inverse","flag","."]
code: def _test_autodiff(self, input_dim, transform, inverse=False):
      """
      This method essentially tests whether autodiff will not throw any errors
      when you're doing maximum-likelihood learning with the transform. Many
      transforms have only one direction with an explicit inverse, hence why we
      pass in the inverse flag.
      """
      temp_transform = transform
      if inverse:
          transform = transform.inv
  
      base_dist = dist.Normal(
          torch.zeros(input_dim), torch.ones(input_dim)
      )
      flow_dist = dist.TransformedDistribution(base_dist, [transform])
      optimizer = torch.optim.Adam(temp_transform.parameters())
      x = torch.rand(1, input_dim)
      for _ in range(3):
          optimizer.zero_grad()
          loss = -flow_dist.log_prob(x.detach()).mean()
          loss.backward()
          optimizer.step()
  
imports: import operator
  from functools import partial, reduce
  from unittest import TestCase
  import pytest
  import torch
  import pyro.distributions
  import pyro.distributions.transforms
  from pyro.distributions import constraints
  from tests.common import assert_close
label_desc: Use image node_id 5 for calling the TransformTests obj's underlying member method code with example usage: obj._test_autodiff(input_dim, transform, inverse) without return types