code: def clean_interp_method(method: str, index: Index, **kwargs) -> str:
      order = kwargs.get("order")
  
      if method in ("spline", "polynomial") and order is None:
          raise ValueError(
              "You must specify the order of the spline or polynomial."
          )
  
      valid = NP_METHODS + SP_METHODS
      if method not in valid:
          raise ValueError(
              f"method must be one of {valid}. Got '{method}' instead."
          )
  
      if method in ("krogh", "piecewise_polynomial", "pchip"):
          if not index.is_monotonic_increasing:
              raise ValueError(
                  f"{method} interpolation requires that the index be monotonic."
              )
  
      return method
  
imports: from __future__ import annotations
  from functools import partial, wraps
  from typing import TYPE_CHECKING, Any, cast
  import numpy
  from pandas._libs import NaT, algos, lib
  from pandas._typing import ArrayLike, Axis, AxisInt, F, npt
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.cast import infer_dtype_from
  from pandas.core.dtypes.common import is_array_like, is_numeric_v_string_like, is_object_dtype, needs_i8_conversion
  from pandas.core.dtypes.missing import is_valid_na_for_dtype, isna, na_value_for_dtype
label_desc: Use image node_id 4 for calling a global function with example usage: clean_interp_method(method, index) and returns: method