code: def make_labels(mapping: dict[str, Any] | aes) -> labels_view:
      """
      Convert aesthetic mapping into text labels
      """
  
      def _nice_label(value: Any) -> str | None:
          if isinstance(value, str):
              return value
          elif isinstance(value, pd.Series):
              return value.name  # pyright: ignore
          elif not isinstance(value, Iterable):
              return str(value)
          elif isinstance(value, Sequence) and len(value) == 1:
              return str(value[0])
          else:
              return None
  
      def _make_label(ae: str, value: Any) -> str | None:
          if not isinstance(value, stage):
              return _nice_label(value)
          elif value.start is None:
              if value.after_stat is not None:
                  return value.after_stat
              elif value.after_scale is not None:
                  return value.after_scale
              else:
                  raise ValueError("Unknown mapping")
          else:
              if value.after_stat is not None:
                  return value.after_stat
              else:
                  return _nice_label(value)
  
      valid_names = {f.name for f in fields(labels_view)}
      return labels_view(
          **{
              str(ae): _make_label(ae, label)
              for ae, label in mapping.items()
              if ae in valid_names
          }
      )
  
imports: from __future__ import annotations
  import re
  import typing
  from collections.abc import Iterable, Sequence
  from contextlib import suppress
  from copy import deepcopy
  from dataclasses import fields
  from typing import Any, Dict
  import pandas
  from ..iapi import labels_view
  from .evaluation import after_stat, stage
label_desc: Use image node_id 8 for calling a global function with example usage: make_labels(mapping) and returns: labels_view, value, _nice_label, value, str, value, value, _nice_label, str, None, value