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."""
      values, counts = np.unique(array, return_counts=True)
      most_frequent_count = counts.max()
      if most_frequent_count > n_repeat:
          value = values[counts == most_frequent_count].min()
      elif n_repeat > most_frequent_count:
          value = extra_value
      else:
          value = min(
              extra_value, values[counts == most_frequent_count].min()
          )
      return value
  
imports: from ....internals import _deprecate_pos_args
  from ....common.array_descriptor import CumlArrayDescriptor
  from ....internals.array_sparse import SparseCumlArray
  from ..utils.validation import FLOAT_DTYPES
  from ..utils.validation import check_is_fitted
  from cuml.internals.mixins import AllowNaNTagMixin, SparseInputTagMixin, StringInputTagMixin
  from ..utils.skl_dependencies import BaseEstimator, TransformerMixin
  from ....thirdparty_adapters import _get_mask, _masked_column_median, _masked_column_mean, _masked_column_mode
  from cuml.internals.safe_imports import gpu_only_import_from
  import cuml
  from cuml.internals.safe_imports import gpu_only_import
  import numbers
  import warnings
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 5 for calling a global function with example usage: _most_frequent(array, extra_value, n_repeat) and returns: value