code: def _cycle_colors(
      colors: list[Color], num_colors: int
  ) -> Iterator[Color]:
      """Cycle colors until achieving max of `num_colors` or length of `colors`.
  
      Extra colors will be ignored by matplotlib if there are more colors
      than needed and nothing needs to be done here.
      """
      max_colors = max(num_colors, len(colors))
      yield from itertools.islice(itertools.cycle(colors), max_colors)
  
imports: from __future__ import annotations
  import itertools
  from typing import TYPE_CHECKING, Collection, Iterator, cast
  import warnings
  import matplotlib
  import matplotlib.colors
  import numpy
  from pandas._typing import MatplotlibColor
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.common import is_list_like
  import pandas.core.common
label_desc: Use image node_id 3 for calling a global function with example usage: _cycle_colors(colors, num_colors) without return types