code: def posterior_predictive_to_xarray(self):
          
          if self.model_fn is None:
              return None
  
          posterior_preds = []
          sample_size = self.posterior[0].shape[0]
  
          for i in np.arange(0, sample_size, int(sample_size / self.posterior_predictive_samples)):
              variables = {}
              for var_i, var_name in enumerate(self.var_names):
                  variables[var_name] = self.posterior[var_i][i]
  
              with self.ed.interception(self._value_setter(variables)):
                  if self.posterior_predictive_size > 1:
                      posterior_preds.append(
                          [self.model_fn() for _ in range(self.posterior_predictive_size)]
                      )
                  else:
                      posterior_preds.append(self.model_fn())
  
          data = {}
          with self.tf.Session() as sess:
              data["obs"] = np.expand_dims(
                  sess.run(posterior_preds, feed_dict=self.feed_dict), axis=0
              )
          return dict_to_dataset(data, library=self.tfp, coords=self.coords, dims=self.dims)
docs: Convert posterior_predictive samples to xarray.