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,)
          The number of training samples in each test sample leaf, for
          each estimators.
  
      Returns
      -------
      average_path_length : ndarray of shape (n_samples,)
      """
  
      n_samples_leaf = sklearn_check_array(
          n_samples_leaf, ensure_2d=False
      )
  
      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_1 = n_samples_leaf <= 1
      mask_2 = n_samples_leaf == 2
      not_mask = ~np.logical_or(mask_1, mask_2)
  
      average_path_length[mask_1] = 0.0
      average_path_length[mask_2] = 1.0
      average_path_length[not_mask] = (
          2.0
          * (np.log(n_samples_leaf[not_mask] - 1.0) + np.euler_gamma)
          - 2.0
          * (n_samples_leaf[not_mask] - 1.0)
          / n_samples_leaf[not_mask]
      )
  
      return average_path_length.reshape(n_samples_leaf_shape)
  
imports: import numbers
  import warnings
  from typing import Union
  import numpy
  from sklearn.base import OutlierMixin
  from sklearn.tree import ExtraTreeRegressor
  from sklearn.utils import check_array, gen_batches
  from ...None import tensor
  from ...lib.sparse import issparse
  from ...session import execute
  from ...tensor.utils import check_random_state
  from ..utils import get_chunk_n_rows, convert_to_tensor_or_dataframe
  from ..utils.validation import _num_samples, check_is_fitted
  from ._bagging import BaseBagging, BaggingPredictionOperand, PredictionType
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