code: def _apply_numerical_encoding_to_feature_array(
      feature_array: pa.Array,
      histogram_bin_boundaries: np.ndarray,
      encoding_length: int,
  ) -> List[int]:
      """Determines encoding of numeric feature array from histogram bins.
  
      Using the provided histogram_bin_boundaries, a histogram is constructed for
      each example to obtain an encoding for a feature value.
  
      Args:
        feature_array: Arrow Array.
        histogram_bin_boundaries: A monotonically increasing np.ndarray representing
          the boundaries of each bin in the histogram.
        encoding_length: The length of the list containing the encoded feature
          values.
  
      Returns:
        A list conatining the encoded feature values for each example.
      """
      if pa.types.is_null(feature_array.type):
          return []
      result = [None for _ in range(len(feature_array))]  # type: List
      flattened, non_missing_parent_indices = array_util.flatten_nested(
          feature_array, True
      )
      assert non_missing_parent_indices is not None
      non_missing_values = np.asarray(flattened)
      non_missing_parent_indices = non_missing_parent_indices.astype(
          np.int32
      )
      values_indices = np.stack(
          (non_missing_values, non_missing_parent_indices), axis=-1
      )
      nan_mask = pd.isnull(non_missing_values)
      for value, index in values_indices[~nan_mask]:
          index = int(index)
          if result[index] is None:
              result[index] = []
          result[index].append(value)
      for value, index in values_indices[nan_mask]:
          index = int(index)
          if result[index] is None:
              result[index] = []
      for i in range(len(result)):
          if result[i] is None:
              result[i] = [None] * encoding_length
          else:
              result[i] = np.bincount(
                  np.digitize(result[i], histogram_bin_boundaries) - 1,
                  minlength=encoding_length,
              ).tolist()
      return result
  
imports: import collections
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
  from absl import logging
  import apache_beam
  import numpy
  import pandas
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import partitioned_stats_generator
  from tensorflow_data_validation.utils import feature_partition_util
  from tensorflow_data_validation.utils import mutual_information_util
  from tensorflow_data_validation.utils import schema_util
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import array_util
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 5 for calling a global function with example usage: _apply_numerical_encoding_to_feature_array(feature_array, histogram_bin_boundaries, encoding_length) and returns: result, list