code: def sample_posterior_predictive(
      model, posterior_samples, baseball_dataset
  ):
      """
      Generate samples from posterior predictive distribution.
      """
      train, test, player_names = train_test_split(baseball_dataset)
      at_bats = train[:, 0]
      at_bats_season = test[:, 0]
      logging.Formatter("%(message)s")
      logging.info("\nPosterior Predictive:")
      logging.info("Hit Rate - Initial 45 At Bats")
      logging.info("-----------------------------")
      # set hits=None to convert it from observation node to sample node
      train_predict = Predictive(model, posterior_samples)(
          at_bats, None
      )
      train_summary = get_summary_table(
          train_predict, sites=["obs"], player_names=player_names
      )["obs"]
      train_summary = train_summary.assign(
          ActualHits=baseball_dataset[["Hits"]].values
      )
      logging.info(train_summary)
      logging.info("\nHit Rate - Season Predictions")
      logging.info("-----------------------------")
      with ignore_experimental_warning():
          test_predict = Predictive(model, posterior_samples)(
              at_bats_season, None
          )
      test_summary = get_summary_table(
          test_predict, sites=["obs"], player_names=player_names
      )["obs"]
      test_summary = test_summary.assign(
          ActualHits=baseball_dataset[["SeasonHits"]].values
      )
      logging.info(test_summary)
  
file_path: pyro/examples/baseball.py
imports: import argparse
  import logging
  import math
  import pandas
  import torch
  import pyro
  from pyro.distributions import Beta, Binomial, HalfCauchy, Normal, Pareto, Uniform
  from pyro.distributions.util import scalar_like
  from pyro.infer import MCMC, NUTS, Predictive
  from pyro.infer.mcmc.util import initialize_model, summary
  from pyro.util import ignore_experimental_warning
label_desc: Use image node_id 7 for calling a global function with example usage: sample_posterior_predictive(model, posterior_samples, baseball_dataset) without return types