code: def test_perplexity_input_format(csr_container):
      # Test LDA perplexity for sparse and dense input
      # score should be the same for both dense and sparse input
      n_components, X = _build_sparse_array(csr_container)
      lda = LatentDirichletAllocation(
          n_components=n_components,
          max_iter=1,
          learning_method="batch",
          total_samples=100,
          random_state=0,
      )
      lda.fit(X)
      perp_1 = lda.perplexity(X)
      perp_2 = lda.perplexity(X.toarray())
      assert_almost_equal(perp_1, perp_2)
  
imports: import sys
  from io import StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from scipy.linalg import block_diag
  from scipy.special import psi
  from sklearn.decomposition import LatentDirichletAllocation
  from sklearn.decomposition._online_lda_fast import _dirichlet_expectation_1d, _dirichlet_expectation_2d
  from sklearn.exceptions import NotFittedError
  from sklearn.utils._testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, if_safe_multiprocessing_with_blas
  from sklearn.utils.fixes import CSR_CONTAINERS
label_desc: Use image node_id 16 for calling a global function with example usage: test_perplexity_input_format(csr_container) without return types