code: def _most_frequent(array, extra_value, n_repeat):
      """Compute the most frequent value in a 1d array extended with
      [extra_value] * n_repeat, where extra_value is assumed to be not part
      of the array."""
      # Compute the most frequent value in array only
      if array.size > 0:
          mode = stats.mode(array)
          most_frequent_value = mode[0][0]
          most_frequent_count = mode[1][0]
      else:
          most_frequent_value = 0
          most_frequent_count = 0
  
      # Compare to array + [extra_value] * n_repeat
      if most_frequent_count == 0 and n_repeat == 0:
          return np.nan
      elif most_frequent_count < n_repeat:
          return extra_value
      elif most_frequent_count > n_repeat:
          return most_frequent_value
      elif most_frequent_count == n_repeat:
          # Ties the breaks. Copy the behaviour of scipy.stats.mode
          if most_frequent_value < extra_value:
              return most_frequent_value
          else:
              return extra_value
  
imports: import warnings
  import numpy
  import numpy.ma
  from scipy import sparse
  from scipy import stats
  from ..base import BaseEstimator, TransformerMixin
  from ..utils import check_array
  from ..utils.fixes import astype
  from ..utils.sparsefuncs import _get_median
  from ..utils.validation import check_is_fitted
  from ..utils.validation import FLOAT_DTYPES
  from ..externals import six
label_desc: Use image node_id 2 for calling a global function with example usage: _most_frequent(array, extra_value, n_repeat) and returns: np, extra_value, most_frequent_value, most_frequent_value, extra_value