code: def clean_interp_method(method, **kwargs):
      order = kwargs.get("order")
      valid = [
          "linear",
          "time",
          "index",
          "values",
          "nearest",
          "zero",
          "slinear",
          "quadratic",
          "cubic",
          "barycentric",
          "polynomial",
          "krogh",
          "piecewise_polynomial",
          "pchip",
          "akima",
          "spline",
          "from_derivatives",
      ]
      if method in ("spline", "polynomial") and order is None:
          raise ValueError(
              "You must specify the order of the spline or "
              "polynomial."
          )
      if method not in valid:
          raise ValueError(
              "method must be one of {valid}. Got '{method}' "
              "instead.".format(valid=valid, method=method)
          )
  
      return method
  
imports: from distutils.version import LooseVersion
  import operator
  import numpy
  from pandas._libs import algos, lib
  from pandas.compat import range, string_types
  from pandas.core.dtypes.cast import infer_dtype_from_array
  from pandas.core.dtypes.common import ensure_float64, is_datetime64_dtype, is_datetime64tz_dtype, is_float_dtype, is_integer, is_integer_dtype, is_numeric_v_string_like, is_scalar, is_timedelta64_dtype, needs_i8_conversion
  from pandas.core.dtypes.missing import isna
label_desc: Use image node_id 3 for calling a global function with example usage: clean_interp_method(method) and returns: method