code: def _average_path_length(n_samples_leaf):
      """The average path length in a n_samples iTree, which is equal to
      the average path length of an unsuccessful BST search since the
      latter has the same structure as an isolation tree.
      Parameters
      ----------
      n_samples_leaf : array-like of shape (n_samples, n_estimators), or int.
          The number of training samples in each test sample leaf, for
          each estimators.
  
      Returns
      -------
      average_path_length : array, same shape as n_samples_leaf
  
      """
      if isinstance(n_samples_leaf, INTEGER_TYPES):
          if n_samples_leaf <= 1:
              return 1.0
          else:
              return (
                  2.0 * (np.log(n_samples_leaf) + 0.5772156649)
                  - 2.0 * (n_samples_leaf - 1.0) / n_samples_leaf
              )
  
      else:
          n_samples_leaf_shape = n_samples_leaf.shape
          n_samples_leaf = n_samples_leaf.reshape((1, -1))
          average_path_length = np.zeros(n_samples_leaf.shape)
  
          mask = n_samples_leaf <= 1
          not_mask = np.logical_not(mask)
  
          average_path_length[mask] = 1.0
          average_path_length[not_mask] = (
              2.0 * (np.log(n_samples_leaf[not_mask]) + 0.5772156649)
              - 2.0
              * (n_samples_leaf[not_mask] - 1.0)
              / n_samples_leaf[not_mask]
          )
  
          return average_path_length.reshape(n_samples_leaf_shape)
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/ensemble/iforest.py
imports: from __future__ import division
  import numpy
  import scipy
  from warnings import warn
  from scipy.sparse import issparse
  import numbers
  from ..externals import six
  from ..tree import ExtraTreeRegressor
  from ..utils import check_random_state, check_array
  from .bagging import BaseBagging
label_desc: Use image node_id 1 for calling a global function with example usage: _average_path_length(n_samples_leaf) and returns: average_path_length, int, unknown