code: def week_of_year_index(index: pd.PeriodIndex) -> np.ndarray:
      """
      Week of year encoded as zero-based index, between 0 and 52.
      """
  
      # TODO:
      # * pandas >= 1.1 does not support `.week`
      # * pandas == 1.0 does not support `.isocalendar()`
      # as soon as we drop support for `pandas == 1.0`, we should remove this
      try:
          week = index.isocalendar().week
      except AttributeError:
          week = index.week
  
      return np.asarray(week) - 1
  
imports: from typing import Any, Callable, Dict, List
  import numpy
  import pandas
  from pandas.tseries import offsets
  from pandas.tseries.frequencies import to_offset
  from gluonts.pydantic import BaseModel
label_desc: Use image node_id 17 for calling a global function with example usage: week_of_year_index(index) and returns: unknown