code: def main(args):
      data, covariates = preprocess(args)
  
      # We will model positive count data by log1p-transforming it into real
      # valued data.  But since we want to evaluate back in the count domain, we
      # will also define a transform to apply during evaluation, transforming
      # from real back to count-valued data. Truth is mapped by the log1p()
      # inverse expm1(), but the prediction will be sampled from a Poisson
      # distribution.
      data = data.log1p()
  
      def transform(pred, truth):
          pred = torch.poisson(pred.clamp(min=1e-4).expm1())
          truth = truth.expm1()
          return pred, truth
  
      # The backtest() function automatically trains and evaluates our model on
      # different windows of data.
      forecaster_options = {
          "num_steps": args.num_steps,
          "learning_rate": args.learning_rate,
          "log_every": args.log_every,
          "dct_gradients": args.dct,
      }
      metrics = backtest(
          data,
          covariates,
          Model,
          train_window=args.train_window,
          test_window=args.test_window,
          stride=args.stride,
          num_samples=args.num_samples,
          forecaster_options=forecaster_options,
      )
  
      for name in ["mae", "rmse", "crps"]:
          values = [m[name] for m in metrics]
          mean = np.mean(values)
          std = np.std(values)
          print("{} = {:0.3g} +- {:0.3g}".format(name, mean, std))
      return metrics
  
file_path: pyro/examples/contrib/forecast/bart.py
imports: import argparse
  import logging
  import numpy
  import torch
  import pyro
  import pyro.distributions
  from pyro.contrib.examples.bart import load_bart_od
  from pyro.contrib.forecast import ForecastingModel, backtest
  from pyro.ops.tensor_utils import periodic_cumsum, periodic_repeat
label_desc: Use image node_id 2 for calling a global function with example usage: main(args) and returns: metrics, pred,  truth