code: def test_estimator_constant_dataset(
      estimator_constructor, use_validation_data: bool
  ):
      constant = get_dataset("constant")
  
      estimator = estimator_constructor(constant)
  
      if use_validation_data:
          predictor = estimator.train(
              training_data=constant.train,
              validation_data=constant.train,
          )
      else:
          predictor = estimator.train(
              training_data=constant.train,
          )
  
      with tempfile.TemporaryDirectory() as td:
          predictor.serialize(Path(td))
          predictor_copy = Predictor.deserialize(Path(td))
  
      assert predictor == predictor_copy
  
      forecasts = predictor_copy.predict(constant.test)
  
      for f in islice(forecasts, 5):
          if isinstance(f, DistributionForecast):
              f = f.to_sample_forecast()
          f.mean
  
imports: import tempfile
  from functools import partial
  from itertools import islice
  from pathlib import Path
  import pytest
  import pandas
  import numpy
  from gluonts.dataset.repository import get_dataset
  from gluonts.model.predictor import Predictor
  from gluonts.torch.distributions import QuantileOutput, StudentTOutput
  from gluonts.torch.model.deepar import DeepAREstimator
  from gluonts.torch.model.deep_npts import DeepNPTSEstimator, DeepNPTSNetworkDiscrete, DeepNPTSNetworkSmooth
  from gluonts.torch.model.forecast import DistributionForecast
  from gluonts.torch.model.mqf2 import MQF2MultiHorizonEstimator
  from gluonts.torch.model.simple_feedforward import SimpleFeedForwardEstimator
  from gluonts.torch.model.d_linear import DLinearEstimator
  from gluonts.torch.model.patch_tst import PatchTSTEstimator
  from gluonts.torch.model.tide import TiDEEstimator
  from gluonts.torch.model.lag_tst import LagTSTEstimator
  from gluonts.torch.model.tft import TemporalFusionTransformerEstimator
  from gluonts.torch.model.wavenet import WaveNetEstimator
  from gluonts.torch.distributions import ImplicitQuantileNetworkOutput
label_desc: Use image node_id 1 for calling a global function with example usage: test_estimator_constant_dataset(estimator_constructor, use_validation_data) without return types