code: def test_diagnostics_ok_with_sample_shape(diagnostics, sample_shape):
      sample_shape = torch.Size(sample_shape)
      xs = torch.rand((4, 100) + sample_shape)
  
      with xfail_if_not_implemented():
          y = diagnostics(xs)
  
          # test correct shape
          assert_equal(y.shape, sample_shape)
  
          # test correct batch calculation
          batch_diagnostics = []
          for x in xs.reshape(4, 100, -1).split(1, dim=2):
              batch_diagnostics.append(diagnostics(x))
          assert_equal(
              torch.cat(batch_diagnostics, dim=0).reshape(sample_shape),
              y,
          )
  
          # test chain_dim, sample_dim at different positions
          a = xs.transpose(0, 1)
          b = xs.unsqueeze(-1).transpose(0, -1).squeeze(0)
          c = xs.unsqueeze(-1).transpose(1, -1).squeeze(1)
          assert_equal(diagnostics(a, chain_dim=1, sample_dim=0), y)
          assert_equal(diagnostics(b, chain_dim=-1, sample_dim=0), y)
          assert_equal(diagnostics(c, sample_dim=-1), y)
  
imports: import warnings
  import pytest
  import torch
  from pyro.ops.stats import _cummin, autocorrelation, autocovariance, crps_empirical, effective_sample_size, fit_generalized_pareto, gelman_rubin, hpdi, pi, quantile, resample, split_gelman_rubin, waic
  from tests.common import assert_close, assert_equal, xfail_if_not_implemented
label_desc: Use image node_id 18 for calling a global function with example usage: test_diagnostics_ok_with_sample_shape(diagnostics, sample_shape) without return types