code: def _get_rank_info(
      study: Study,
      params: list[str] | None,
      target: Callable[[FrozenTrial], float] | None,
      target_name: str,
  ) -> _RankPlotInfo:
      _check_plot_args(study, target, target_name)
  
      trials = study.get_trials(
          deepcopy=False, states=(TrialState.COMPLETE,)
      )
  
      all_params = {
          p_name for t in trials for p_name in t.params.keys()
      }
      if len(trials) == 0:
          _logger.warning(
              "Your study does not have any completed trials."
          )
          params = []
      elif params is None:
          params = sorted(all_params)
      else:
          for input_p_name in params:
              if input_p_name not in all_params:
                  raise ValueError(
                      "Parameter {} does not exist in your study.".format(
                          input_p_name
                      )
                  )
  
      if len(params) == 0:
          _logger.warning("params is an empty list.")
  
      has_custom_target = True
      if target is None:
  
          def target(trial: FrozenTrial) -> float:
              return typing.cast(float, trial.value)
  
          has_custom_target = False
      target_values = np.array([target(trial) for trial in trials])
      raw_ranks = _get_order_with_same_order_averaging(target_values)
      color_idxs = (
          raw_ranks / (len(trials) - 1)
          if len(trials) >= 2
          else np.array([0.5])
      )
      colors = _convert_color_idxs_to_scaled_rgb_colors(color_idxs)
  
      sub_plot_infos: list[list[_RankSubplotInfo]]
      if len(params) == 2:
          x_param = params[0]
          y_param = params[1]
          sub_plot_info = _get_rank_subplot_info(
              trials, target_values, colors, x_param, y_param
          )
          sub_plot_infos = [[sub_plot_info]]
      else:
          sub_plot_infos = [
              [
                  _get_rank_subplot_info(
                      trials, target_values, colors, x_param, y_param
                  )
                  for x_param in params
              ]
              for y_param in params
          ]
  
      return _RankPlotInfo(
          params=params,
          sub_plot_infos=sub_plot_infos,
          target_name=target_name,
          zs=target_values,
          colors=colors,
          has_custom_target=has_custom_target,
      )
  
imports: from __future__ import annotations
  import math
  import typing
  from typing import Any
  from typing import Callable
  from typing import NamedTuple
  import numpy
  from optuna._experimental import experimental_func
  from optuna.logging import get_logger
  from optuna.samplers._base import _CONSTRAINTS_KEY
  from optuna.study import Study
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
  from optuna.visualization._plotly_imports import _imports
  from optuna.visualization._utils import _check_plot_args
  from optuna.visualization._utils import _is_log_scale
  from optuna.visualization._utils import _is_numerical
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 3 for calling a global function with example usage: _get_rank_info(study, params, target, target_name) and returns: _RankPlotInfo, typing