code: def _calculate_griddata(
      info: _SubContourInfo,
  ) -> tuple[
      np.ndarray,
      np.ndarray,
      np.ndarray,
      list[int],
      list[str],
      list[int],
      list[str],
      _PlotValues,
      _PlotValues,
  ]:
      xaxis = info.xaxis
      yaxis = info.yaxis
      z_values_dict = info.z_values
  
      x_values = []
      y_values = []
      z_values = []
      for x_value, y_value in zip(xaxis.values, yaxis.values):
          if x_value is not None and y_value is not None:
              x_values.append(x_value)
              y_values.append(y_value)
              x_i = xaxis.indices.index(x_value)
              y_i = yaxis.indices.index(y_value)
              z_values.append(z_values_dict[(x_i, y_i)])
  
      # Return empty values when x or y has no value.
      if len(x_values) == 0 or len(y_values) == 0:
          return (
              np.array([]),
              np.array([]),
              np.array([]),
              [],
              [],
              [],
              [],
              _PlotValues([], []),
              _PlotValues([], []),
          )
  
      def _calculate_axis_data(
          axis: _AxisInfo,
          values: Sequence[str | float],
      ) -> tuple[np.ndarray, list[str], list[int], list[int | float]]:
          # Convert categorical values to int.
          cat_param_labels: list[str] = []
          cat_param_pos: list[int] = []
          returned_values: Sequence[int | float]
          if axis.is_cat:
              enc = _LabelEncoder()
              returned_values = enc.fit_transform(
                  list(map(str, values))
              )
              cat_param_labels = enc.get_labels()
              cat_param_pos = enc.get_indices()
          else:
              returned_values = list(map(lambda x: float(x), values))
  
          # For x and y, create 1-D array of evenly spaced coordinates on linear or log scale.
          if axis.is_log:
              ci = np.logspace(
                  np.log10(axis.range[0]),
                  np.log10(axis.range[1]),
                  CONTOUR_POINT_NUM,
              )
          else:
              ci = np.linspace(
                  axis.range[0], axis.range[1], CONTOUR_POINT_NUM
              )
  
          return (
              ci,
              cat_param_labels,
              cat_param_pos,
              list(returned_values),
          )
  
      (
          xi,
          cat_param_labels_x,
          cat_param_pos_x,
          transformed_x_values,
      ) = _calculate_axis_data(
          xaxis,
          x_values,
      )
      (
          yi,
          cat_param_labels_y,
          cat_param_pos_y,
          transformed_y_values,
      ) = _calculate_axis_data(
          yaxis,
          y_values,
      )
  
      # Calculate grid data points.
      zi: np.ndarray = np.array([])
      # Create irregularly spaced map of trial values
      # and interpolate it with Plotly's interpolation formulation.
      if xaxis.name != yaxis.name:
          zmap = _create_zmap(
              transformed_x_values,
              transformed_y_values,
              z_values,
              xi,
              yi,
          )
          zi = _interpolate_zmap(zmap, CONTOUR_POINT_NUM)
  
      # categorize by constraints
      feasible = _PlotValues([], [])
      infeasible = _PlotValues([], [])
  
      for x_value, y_value, c in zip(
          transformed_x_values, transformed_y_values, info.constraints
      ):
          if c:
              feasible.x.append(x_value)
              feasible.y.append(y_value)
          else:
              infeasible.x.append(x_value)
              infeasible.y.append(y_value)
  
      return (
          xi,
          yi,
          zi,
          cat_param_pos_x,
          cat_param_labels_x,
          cat_param_pos_y,
          cat_param_labels_y,
          feasible,
          infeasible,
      )
  
imports: from __future__ import annotations
  from typing import Callable
  from typing import Sequence
  import numpy
  from optuna._experimental import experimental_func
  from optuna._imports import try_import
  from optuna.logging import get_logger
  from optuna.study import Study
  from optuna.trial import FrozenTrial
  from optuna.visualization._contour import _AxisInfo
  from optuna.visualization._contour import _ContourInfo
  from optuna.visualization._contour import _get_contour_info
  from optuna.visualization._contour import _PlotValues
  from optuna.visualization._contour import _SubContourInfo
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 4 for calling a global function with example usage: _calculate_griddata(info) and returns: xi,  yi,  zi,  cat_param_pos_x,  cat_param_labels_x,  cat_param_pos_y,  cat_param_labels_y,  feasible,  infeasible, np,  np,  np,  list,  list,  list,  list,  _PlotValues,  _PlotValues, ci,  cat_param_labels,  cat_param_pos,  list