class_docstr: Forecaster for a :class:`ForecastingModel` using Hamiltonian Monte Carlo.
  
  On initialization, this will run :class:`~pyro.infer.mcmc.nuts.NUTS`
  sampler to get posterior samples of the model.
  
  After construction, this can be called to generate sample forecasts.
  
  :param ForecastingModel model: A forecasting model subclass instance.
  :param data: A tensor dataset with time dimension -2.
  :type data: ~torch.Tensor
  :param covariates: A tensor of covariates with time dimension -2.
      For models not using covariates, pass a shaped empty tensor
      ``torch.empty(duration, 0)``.
  :type covariates: ~torch.Tensor
  :param int num_warmup: number of MCMC warmup steps.
  :param int num_samples: number of MCMC samples.
  :param int num_chains: number of parallel MCMC chains.
  :param bool dense_mass: a flag to control whether the mass matrix is dense
      or diagonal. Defaults to False.
  :param str time_reparam: If not None (default), reparameterize all
      time-dependent variables via the Haar wavelet transform (if "haar") or
      the discrete cosine transform (if "dct").
  :param bool jit_compile: whether to use the PyTorch JIT to trace the log
      density computation, and use this optimized executable trace in the
      integrator. Defaults to False.
  :param int max_tree_depth: Max depth of the binary tree created during the
      doubling scheme of the :class:`~pyro.infer.mcmc.nuts.NUTS` sampler.
      Defaults to 10.
class_docstr_tok: ["Forecaster","for","a",":","class",":","`","ForecastingModel","`","using","Hamiltonian","Monte","Carlo",".","On","initialization",",","this","will","run",":","class",":","`","~pyro.infer.mcmc.nuts.NUTS","`","sampler","to","get","posterior","samples","of","the","model",".","After","construction",",","this","can","be","called","to","generate","sample","forecasts",".",":","param","ForecastingModel","model",":","A","forecasting","model","subclass","instance",".",":","param","data",":","A","tensor","dataset","with","time","dimension","-2.",":","type","data",":","~torch.Tensor",":","param","covariates",":","A","tensor","of","covariates","with","time","dimension","-2",".","For","models","not","using","covariates",",","pass","a","shaped","empty","tensor","``","torch.empty","(","duration",",","0",")","``",".",":","type","covariates",":","~torch.Tensor",":","param","int","num_warmup",":","number","of","MCMC","warmup","steps",".",":","param","int","num_samples",":","number","of","MCMC","samples",".",":","param","int","num_chains",":","number","of","parallel","MCMC","chains",".",":","param","bool","dense_mass",":","a","flag","to","control","whether","the","mass","matrix","is","dense","or","diagonal",".","Defaults","to","False",".",":","param","str","time_reparam",":","If","not","None","(","default",")",",","reparameterize","all","time-dependent","variables","via","the","Haar","wavelet","transform","(","if","``","haar","''",")","or","the","discrete","cosine","transform","(","if","``","dct","''",")",".",":","param","bool","jit_compile",":","whether","to","use","the","PyTorch","JIT","to","trace","the","log","density","computation",",","and","use","this","optimized","executable","trace","in","the","integrator",".","Defaults","to","False",".",":","param","int","max_tree_depth",":","Max","depth","of","the","binary","tree","created","during","the","doubling","scheme","of","the",":","class",":","`","~pyro.infer.mcmc.nuts.NUTS","`","sampler",".","Defaults","to","10","."]
docstr: Samples forecasted values of data for time steps in ``[t1,t2)``, where
  ``t1 = data.size(-2)`` is the duration of observed data and ``t2 =
  covariates.size(-2)`` is the extended duration of covariates. For
  example to forecast 7 days forward conditioned on 30 days of
  observations, set ``t1=30`` and ``t2=37``.
  
  :param data: A tensor dataset with time dimension -2.
  :type data: ~torch.Tensor
  :param covariates: A tensor of covariates with time dimension -2.
      For models not using covariates, pass a shaped empty tensor
      ``torch.empty(duration, 0)``.
  :type covariates: ~torch.Tensor
  :param int num_samples: The number of samples to generate.
  :param int batch_size: Optional batch size for sampling. This is useful
      for generating many samples from models with large memory
      footprint. Defaults to ``num_samples``.
  :returns: A batch of joint posterior samples of shape
      ``(num_samples,1,...,1) + data.shape[:-2] + (t2-t1,data.size(-1))``,
      where the ``1``'s are inserted to avoid conflict with model plates.
  :rtype: ~torch.Tensor
docstr_tok: ["Samples","forecasted","values","of","data","for","time","steps","in","``","[","t1",",","t2",")","``",",","where","``","t1","=","data.size","(","-2",")","``","is","the","duration","of","observed","data","and","``","t2","=","covariates.size","(","-2",")","``","is","the","extended","duration","of","covariates",".","For","example","to","forecast","7","days","forward","conditioned","on","30","days","of","observations",",","set","``","t1=30","``","and","``","t2=37","``",".",":","param","data",":","A","tensor","dataset","with","time","dimension","-2.",":","type","data",":","~torch.Tensor",":","param","covariates",":","A","tensor","of","covariates","with","time","dimension","-2",".","For","models","not","using","covariates",",","pass","a","shaped","empty","tensor","``","torch.empty","(","duration",",","0",")","``",".",":","type","covariates",":","~torch.Tensor",":","param","int","num_samples",":","The","number","of","samples","to","generate",".",":","param","int","batch_size",":","Optional","batch","size","for","sampling",".","This","is","useful","for","generating","many","samples","from","models","with","large","memory","footprint",".","Defaults","to","``","num_samples","``",".",":","returns",":","A","batch","of","joint","posterior","samples","of","shape","``","(","num_samples,1",",","...",",1",")","+","data.shape","[",":","-2","]","+","(","t2-t1",",","data.size","(","-1",")",")","``",",","where","the","``","1","``","'s","are","inserted","to","avoid","conflict","with","model","plates",".",":","rtype",":","~torch.Tensor"]
code: def __call__(self, data, covariates, num_samples, batch_size=None):
      """
      Samples forecasted values of data for time steps in ``[t1,t2)``, where
      ``t1 = data.size(-2)`` is the duration of observed data and ``t2 =
      covariates.size(-2)`` is the extended duration of covariates. For
      example to forecast 7 days forward conditioned on 30 days of
      observations, set ``t1=30`` and ``t2=37``.
  
      :param data: A tensor dataset with time dimension -2.
      :type data: ~torch.Tensor
      :param covariates: A tensor of covariates with time dimension -2.
          For models not using covariates, pass a shaped empty tensor
          ``torch.empty(duration, 0)``.
      :type covariates: ~torch.Tensor
      :param int num_samples: The number of samples to generate.
      :param int batch_size: Optional batch size for sampling. This is useful
          for generating many samples from models with large memory
          footprint. Defaults to ``num_samples``.
      :returns: A batch of joint posterior samples of shape
          ``(num_samples,1,...,1) + data.shape[:-2] + (t2-t1,data.size(-1))``,
          where the ``1``'s are inserted to avoid conflict with model plates.
      :rtype: ~torch.Tensor
      """
      return super().__call__(data, covariates, num_samples, batch_size)
  
imports: import logging
  from abc import ABCMeta, abstractmethod
  from contextlib import ExitStack
  import torch
  import torch.nn
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.infer import MCMC, NUTS, SVI, Trace_ELBO
  from pyro.infer.autoguide import AutoNormal, init_to_sample
  from pyro.infer.predictive import _guess_max_plate_nesting
  from pyro.nn.module import PyroModule
  from pyro.optim import DCTAdam
  from .util import MarkDCTParamMessenger, PrefixConditionMessenger, PrefixReplayMessenger, PrefixWarmStartMessenger, reshape_batch, time_reparam_dct, time_reparam_haar
label_desc: Use image node_id 2 for calling the HMCForecaster obj's underlying member method code with example usage: obj.__call__(data, covariates, num_samples, batch_size) and returns: super