code: def rank(
      values: ArrayLike,
      axis: AxisInt = 0,
      method: str = "average",
      na_option: str = "keep",
      ascending: bool = True,
      pct: bool = False,
  ) -> npt.NDArray[np.float64]:
      """
      Rank the values along a given axis.
  
      Parameters
      ----------
      values : np.ndarray or ExtensionArray
          Array whose values will be ranked. The number of dimensions in this
          array must not exceed 2.
      axis : int, default 0
          Axis over which to perform rankings.
      method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
          The method by which tiebreaks are broken during the ranking.
      na_option : {'keep', 'top'}, default 'keep'
          The method by which NaNs are placed in the ranking.
          - ``keep``: rank each NaN value with a NaN ranking
          - ``top``: replace each NaN with either +/- inf so that they
                     there are ranked at the top
      ascending : bool, default True
          Whether or not the elements should be ranked in ascending order.
      pct : bool, default False
          Whether or not to the display the returned rankings in integer form
          (e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
      """
      is_datetimelike = needs_i8_conversion(values.dtype)
      values = _ensure_data(values)
  
      if values.ndim == 1:
          ranks = algos.rank_1d(
              values,
              is_datetimelike=is_datetimelike,
              ties_method=method,
              ascending=ascending,
              na_option=na_option,
              pct=pct,
          )
      elif values.ndim == 2:
          ranks = algos.rank_2d(
              values,
              axis=axis,
              is_datetimelike=is_datetimelike,
              ties_method=method,
              ascending=ascending,
              na_option=na_option,
              pct=pct,
          )
      else:
          raise TypeError("Array with ndim > 2 are not supported.")
  
      return ranks
  
imports: from __future__ import annotations
  import decimal
  import operator
  from textwrap import dedent
  from typing import TYPE_CHECKING, Literal, cast
  import warnings
  import numpy
  from pandas._libs import algos, hashtable, iNaT, lib
  from pandas._typing import AnyArrayLike, ArrayLike, ArrayLikeT, AxisInt, DtypeObj, TakeIndexer, npt
  from pandas.util._decorators import doc
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike, np_find_common_type
  from pandas.core.dtypes.common import ensure_float64, ensure_object, ensure_platform_int, is_array_like, is_bool_dtype, is_complex_dtype, is_dict_like, is_extension_array_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, is_list_like, is_object_dtype, is_signed_integer_dtype, needs_i8_conversion
  from pandas.core.dtypes.concat import concat_compat
  from pandas.core.dtypes.dtypes import BaseMaskedDtype, CategoricalDtype, ExtensionDtype, NumpyEADtype
  from pandas.core.dtypes.generic import ABCDatetimeArray, ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries, ABCTimedeltaArray
  from pandas.core.dtypes.missing import isna, na_value_for_dtype
  from pandas.core.array_algos.take import take_nd
  from pandas.core.construction import array, ensure_wrapped_if_datetimelike, extract_array
  from pandas.core.indexers import validate_indices
label_desc: Use image node_id 17 for calling a global function with example usage: rank(values, axis, method, na_option, ascending, pct) and returns: ranks