code: def test_align_timestamp():
      def aligned_with(date_str, freq):
          return pd.Period(date_str, freq=freq).to_timestamp()
  
      for _ in range(2):
          assert aligned_with(
              "2012-03-05 09:13:12", "min"
          ) == pd.Timestamp("2012-03-05 09:13:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "2min"
          ) == pd.Timestamp("2012-03-05 09:13:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "H"
          ) == pd.Timestamp("2012-03-05 09:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "D"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "W"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "4W"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "M"
          ) == pd.Timestamp("2012-03-01 00:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "3M"
          ) == pd.Timestamp("2012-03-01 00:00:00")
          assert aligned_with(
              "2012-03-05 09:13:12", "Y"
          ) == pd.Timestamp("2012-01-01 00:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "min"
          ) == pd.Timestamp("2012-03-05 09:14:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "2min"
          ) == pd.Timestamp("2012-03-05 09:14:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "H"
          ) == pd.Timestamp("2012-03-05 09:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "D"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "W"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "4W"
          ) == pd.Timestamp("2012-03-05 00:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "M"
          ) == pd.Timestamp("2012-03-01 00:00:00")
          assert aligned_with(
              "2012-03-05 09:14:11", "3M"
          ) == pd.Timestamp("2012-03-01 00:00:00")
  
imports: from typing import Tuple, List
  import numpy
  import pandas
  from pandas.tseries.frequencies import to_offset
  import pytest
  import gluonts
  from gluonts import time_feature, transform
  from gluonts.core import fqname_for
  from gluonts.core.serde import dump_json, load_json
  from gluonts.dataset.common import DataEntry, ListDataset
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.stat import ScaleHistogram, calculate_dataset_statistics
  from gluonts.transform import CausalMeanValueImputation, DummyValueImputation, LastValueImputation, MeanValueImputation, RollingMeanValueImputation, Valmap
  from gluonts.transform.convert import ToIntervalSizeFormat, erf, erfinv
  from gluonts.transform.feature import CountTrailingZeros
label_desc: Use image node_id 1 for calling a global function with example usage: test_align_timestamp() and returns: pd