code: def test_mean_var(batch_shape):
      dim = 2
      loc = torch.randn(batch_shape + (dim,))
      A = torch.randn(batch_shape + (dim, dim + dim))
      scale_tril = torch.linalg.cholesky(A.matmul(A.transpose(-2, -1)))
      df = torch.randn(batch_shape).exp() + 4
      num_samples = 100000
      d = MultivariateStudentT(df, loc, scale_tril)
      samples = d.sample(sample_shape=(num_samples,))
      expected_mean = samples.mean(0)
      expected_variance = samples.var(0)
      assert_equal(d.mean, expected_mean, prec=0.1)
      assert_equal(d.variance, expected_variance, prec=0.2)
  
      assert_equal(
          MultivariateStudentT(0.5, loc, scale_tril).mean,
          torch.full(batch_shape + (dim,), float("nan")),
      )
      assert_equal(
          MultivariateStudentT(0.5, loc, scale_tril).variance,
          torch.full(batch_shape + (dim,), float("nan")),
      )
      assert_equal(
          MultivariateStudentT(1.5, loc, scale_tril).variance,
          torch.full(batch_shape + (dim,), float("inf")),
      )
  
file_path: pyro/tests/distributions/test_mvt.py
imports: import math
  import pytest
  import torch
  from torch.distributions import Gamma, MultivariateNormal, StudentT
  from pyro.distributions import MultivariateStudentT
  from tests.common import assert_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_mean_var(batch_shape) without return types