code: def test_normalizing_flow_pytorch():
      """
      This test aims to evaluate if the normalizingFlow model is being applied
      correctly. That is if the sampling, and its log_prob, are being computed
      after performing the transformation layers. Also, if log_prob of an input
      tensor have consistency with the NormalizingFlow model.
  
      NormalizingFlow:
        sample:
          input shape: (samples)
          output shape: ((samples, dim), (samples))
  
        log_prob: Method used to learn parameter (optimizing loop)
          input shape: (samples)
          output shape: (samples)
  
      """
  
      dim = 2
      samples = 96
      base_distribution = MultivariateNormal(
          torch.zeros(dim), torch.eye(dim)
      )
      tensor = base_distribution.sample(torch.Size((samples, dim)))
      transformation = [Affine(dim)]
      model = NormalizingFlow(transformation, base_distribution, dim)
  
      # Test sampling method
      sampling, log_prob_ = model.sample(samples)
  
      # Test log_prob method (this method is used when inverse pass)
      # Output must be a Nth zero array since nothing is being learned yet
      log_prob = model.log_prob(tensor)
  
      # Featurize to assert for tests
      log_prob_ = log_prob_.detach().numpy()
      log_prob = log_prob.detach().numpy()
      zeros = np.zeros((samples,))
  
      # Assert errors for sample method
      assert log_prob_.any()
  
      # Assert errors for log_prob method
      assert np.array_equal(log_prob, zeros)
  
imports: import pytest
  import numpy
  import unittest
label_desc: Use image node_id 2 for calling a global function with example usage: test_normalizing_flow_pytorch() without return types