code: def is_uniform(index: pd.PeriodIndex) -> bool:
      """
      Check if ``index`` contains monotonically increasing periods, evenly spaced
      with frequency ``index.freq``.
  
          >>> ts = ["2021-01-01 00:00", "2021-01-01 02:00", "2021-01-01 04:00"]
          >>> is_uniform(pd.DatetimeIndex(ts).to_period("2H"))
          True
          >>> ts = ["2021-01-01 00:00", "2021-01-01 04:00"]
          >>> is_uniform(pd.DatetimeIndex(ts).to_period("2H"))
          False
      """
  
      return cast(bool, np.all(np.diff(index.asi8) == index.freq.n))
  
imports: from __future__ import annotations
  import logging
  from dataclasses import dataclass, field, InitVar
  from typing import Any, Iterable, Optional, Type, Union, cast
  import numpy
  import pandas
  from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
  from toolz import first
  from gluonts import maybe
  from gluonts.dataset.common import DataEntry
  from gluonts.itertools import Map, StarMap, SizedIterable
label_desc: Use image node_id 3 for calling a global function with example usage: is_uniform(index) and returns: cast