code: def test_multivariate_estimator_constant_dataset(
      estimator_constructor, use_validation_data: bool
  ):
      constant = get_dataset("constant")
      estimator = estimator_constructor(constant)
  
      train_grouper = MultivariateGrouper(
          max_target_dim=int(
              constant.metadata.feat_static_cat[0].cardinality
          )
      )
      test_grouper = MultivariateGrouper(
          num_test_dates=int(len(constant.test) / len(constant.train)),
          max_target_dim=int(
              constant.metadata.feat_static_cat[0].cardinality
          ),
      )
      dataset_train = train_grouper(constant.train)
      dataset_test = test_grouper(constant.test)
  
      if use_validation_data:
          predictor = estimator.train(
              training_data=dataset_train, validation_data=dataset_test
          )
      else:
          predictor = estimator.train(training_data=dataset_train)
  
      with tempfile.TemporaryDirectory() as td:
          predictor.serialize(Path(td))
          predictor_copy = Predictor.deserialize(Path(td))
  
      assert predictor == predictor_copy
  
      forecasts = predictor_copy.predict(dataset_test)
  
      for f in islice(forecasts, 5):
          if isinstance(f, DistributionForecast):
              f = f.to_sample_forecast()
          f.mean
  
file_path: gluonts/test/torch/model/test_multivariate_estimators.py
imports: import tempfile
  from itertools import islice
  from pathlib import Path
  import pytest
  import pandas
  import numpy
  from gluonts.dataset.repository import get_dataset
  from gluonts.dataset.multivariate_grouper import MultivariateGrouper
  from gluonts.model.predictor import Predictor
  from gluonts.torch.model.forecast import DistributionForecast
  from gluonts.torch.model.i_transformer import ITransformerEstimator
label_desc: Use image node_id 1 for calling a global function with example usage: test_multivariate_estimator_constant_dataset(estimator_constructor, use_validation_data) without return types