code: def refactor_levels(
      level: Level | list[Level] | None,
      obj: Index,
  ) -> list[int]:
      """
      Returns a consistent levels arg for use in ``hide_index`` or ``hide_columns``.
  
      Parameters
      ----------
      level : int, str, list
          Original ``level`` arg supplied to above methods.
      obj:
          Either ``self.index`` or ``self.columns``
  
      Returns
      -------
      list : refactored arg with a list of levels to hide
      """
      if level is None:
          levels_: list[int] = list(range(obj.nlevels))
      elif isinstance(level, int):
          levels_ = [level]
      elif isinstance(level, str):
          levels_ = [obj._get_level_number(level)]
      elif isinstance(level, list):
          levels_ = [
              obj._get_level_number(lev)
              if not isinstance(lev, int)
              else lev
              for lev in level
          ]
      else:
          raise ValueError(
              "`level` must be of type `int`, `str` or list of such"
          )
      return levels_
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Sequence
  from functools import partial
  import re
  from typing import TYPE_CHECKING, Any, Callable, DefaultDict, Optional, TypedDict, Union
  from uuid import uuid4
  import numpy
  from pandas._config import get_option
  from pandas._libs import lib
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.common import is_complex, is_float, is_integer
  from pandas.core.dtypes.generic import ABCSeries
  from pandas import DataFrame, Index, IndexSlice, MultiIndex, Series, isna
  from pandas.api.types import is_list_like
  import pandas.core.common
  from markupsafe import escape
label_desc: Use image node_id 13 for calling a global function with example usage: refactor_levels(level, obj) and returns: levels_