code: def test_normalizing_flow_model_reload():
      """Test that NormalizingFlowModel can be reloaded correctly."""
      from deepchem.models.normalizing_flows import (
          NormalizingFlow,
          NormalizingFlowModel,
      )
      import tensorflow_probability as tfp
  
      tfd = tfp.distributions
      tfb = tfp.bijectors
  
      model_dir = tempfile.mkdtemp()
  
      Made = tfb.AutoregressiveNetwork(
          params=2,
          hidden_units=[512, 512],
          activation="relu",
          dtype="float64",
      )
  
      flow_layers = [
          tfb.MaskedAutoregressiveFlow(shift_and_log_scale_fn=Made)
      ]
      # 3D Multivariate Gaussian base distribution
      nf = NormalizingFlow(
          base_distribution=tfd.MultivariateNormalDiag(
              loc=np.zeros(2), scale_diag=np.ones(2)
          ),
          flow_layers=flow_layers,
      )
  
      nfm = NormalizingFlowModel(nf, model_dir=model_dir)
  
      target_distribution = tfd.MultivariateNormalDiag(
          loc=np.array([1.0, 0.0])
      )
      dataset = dc.data.NumpyDataset(X=target_distribution.sample(96))
      _ = nfm.fit(dataset, nb_epoch=1)
  
      x = np.zeros(2)
      lp1 = nfm.flow.log_prob(x).numpy()
  
      assert nfm.flow.sample().numpy().shape == (2,)
  
      reloaded_model = NormalizingFlowModel(nf, model_dir=model_dir)
      reloaded_model.restore()
  
      # Check that reloaded model can sample from the distribution
      assert reloaded_model.flow.sample().numpy().shape == (2,)
  
      lp2 = reloaded_model.flow.log_prob(x).numpy()
  
      # Check that density estimation is same for reloaded model
      assert np.all(lp1 == lp2)
  
imports: import os
  import pytest
  import tempfile
  import numpy
  import deepchem
  import scipy.io
  from flaky import flaky
  from sklearn.ensemble import RandomForestClassifier
  from deepchem.molnet.load_function.chembl25_datasets import CHEMBL25_TASKS
  from deepchem.feat import create_char_to_idx
label_desc: Use image node_id 7 for calling a global function with example usage: test_normalizing_flow_model_reload() without return types