code: def test_predictions_constant_data(self):
      with pm.Model():
          x = pm.ConstantData("x", [1.0, 2.0, 3.0])
          y = pm.MutableData("y", [1.0, 2.0, 3.0])
          beta = pm.Normal("beta", 0, 1)
          obs = pm.Normal("obs", x * beta, 1, observed=y)
          trace = pm.sample(100, tune=100, return_inferencedata=False)
          inference_data = to_inference_data(trace)
  
      test_dict = {
          "posterior": ["beta"],
          "observed_data": ["obs"],
          "constant_data": ["x"],
      }
      fails = check_multiple_attrs(test_dict, inference_data)
      assert not fails
  
      with pm.Model():
          x = pm.MutableData("x", [1.0, 2.0])
          y = pm.ConstantData("y", [1.0, 2.0])
          beta = pm.Normal("beta", 0, 1)
          obs = pm.Normal("obs", x * beta, 1, observed=y)
          predictive_trace = pm.sample_posterior_predictive(
              inference_data, return_inferencedata=False
          )
          assert set(predictive_trace.keys()) == {"obs"}
          # this should be four chains of 100 samples
          # assert predictive_trace["obs"].shape == (400, 2)
          # but the shape seems to vary between pymc versions
          with warnings.catch_warnings():
              warnings.filterwarnings(
                  "ignore", "More chains .* than draws.*", UserWarning
              )
              inference_data = predictions_to_inference_data(
                  predictive_trace, posterior_trace=trace
              )
      test_dict = {"posterior": ["beta"], "~observed_data": ""}
      fails = check_multiple_attrs(test_dict, inference_data)
      assert not fails, "Posterior data not copied over as expected."
      test_dict = {"predictions": ["obs"]}
      fails = check_multiple_attrs(test_dict, inference_data)
      assert not fails, "Predictions not instantiated as expected."
      test_dict = {"predictions_constant_data": ["x"]}
      fails = check_multiple_attrs(test_dict, inference_data)
      assert (
          not fails
      ), "Predictions constant data not instantiated as expected."
  
imports: import warnings
  from typing import Dict, Tuple
  import numpy
  import pytensor.tensor
  import pytest
  from arviz import InferenceData
  from arviz.tests.helpers import check_multiple_attrs
  from numpy import ma
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1
  import pymc
  from pymc.backends.arviz import InferenceDataConverter, predictions_to_inference_data, to_inference_data
  from pymc.exceptions import ImputationWarning
label_desc: Use image node_id 18 for calling the TestDataPyMC obj's underlying member method code with example usage: obj.test_predictions_constant_data() without return types