code: def _check_density(density, n_features):
      """Factorize density check according to Li et al."""
      if density == "auto":
          density = 1 / np.sqrt(n_features)
  
      elif density <= 0 or density > 1:
          raise ValueError(
              "Expected density in range ]0, 1], got: %r" % density
          )
      return density
  
imports: from __future__ import division
  import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from numpy.testing import assert_equal
  import scipy.sparse
  from .base import BaseEstimator, TransformerMixin
  from .externals import six
  from .externals.six.moves import xrange
  from .utils import check_random_state
  from .utils.extmath import safe_sparse_dot
  from .utils.random import sample_without_replacement
  from .utils.validation import check_array
  from .exceptions import DataDimensionalityWarning
  from .exceptions import NotFittedError
label_desc: Use image node_id 2 for calling a global function with example usage: _check_density(density, n_features) and returns: density