code: def time_series(
      values: Collection,
      *,
      index: Optional[Periods] = None,
      start: Optional[Union[Period, str]] = None,
      freq: Optional[str] = None,
      tdim: int = -1,
      name: Optional[str] = None,
      metadata: Optional[Dict] = None,
  ):
      """Create a ``zebras.TimeSeries`` object that represents a time series.
  
      Parameters
      ----------
      values
          A sequence (e.g., list, numpy arrays) representing the values
          of the time series.
      index, optional
          A ``zebras.Periods`` object representing timestamps.
          Must have the same length as the `values`, by default None
      start, optional
          The start time represented by a string (e.g., "2023-01-01"),
          or a ``zebras.Period`` object. An index will be constructed using
          this start time and the specificed frequency, by default None
      freq, optional
          The frequency of the period, e.g, "H" for hourly, by default None
      tdim, optional
          The time dimension in `values`, by default -1
      name: optional
          A description for the time series. This will be the column names when
          returned from a ``TimeFrame``.
      metadata, optional
          A dictionary of metadata associated with the time series, by default None
  
      Returns
      -------
          A ``zebras.TimeSeries`` object.
      """
      values = np.array(values)
  
      ts = TimeSeries(
          values,
          index=index,
          tdim=tdim,
          name=name,
          metadata=metadata,
      )
  
      if ts.index is None and start is not None:
          if freq is not None:
              start = period(start, freq)
          else:
              assert isinstance(start, Period)
  
          return ts.with_index(start.periods(len(ts)))
  
      return ts
  
imports: from __future__ import annotations
  import dataclasses
  from operator import itemgetter
  from typing import Collection, Union, Optional, Dict, List, Tuple
  import numpy
  from toolz import first
  from gluonts import maybe
  from gluonts.itertools import pluck_attr
  from ._base import Pad, TimeBase
  from ._period import period, Period, Periods
  from ._util import AxisView, pad_axis, _replace
label_desc: Use image node_id 1 for calling a global function with example usage: time_series(values) and returns: ts, ts