code: def test_broadcast_params():
      ndims_params = [0, 0]
  
      mean = np.array([0, 1, 2])
      cov = np.array(1e-6)
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], mean)
      assert np.array_equal(res[1], np.broadcast_to(cov, (3,)))
  
      ndims_params = [1, 2]
  
      mean = np.r_[1, 2, 3]
      cov = np.stack([np.eye(3) * 1e-5, np.eye(3) * 1e-4])
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], np.broadcast_to(mean, (2, 3)))
      assert np.array_equal(res[1], cov)
  
      mean = np.stack([np.r_[0, 0, 0], np.r_[1, 1, 1]])
      cov = np.arange(3 * 3).reshape((3, 3))
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], mean)
      assert np.array_equal(res[1], np.broadcast_to(cov, (2, 3, 3)))
  
      mean = np.stack([np.r_[0, 0, 0], np.r_[1, 1, 1]])
      cov = np.stack(
          [
              np.arange(3 * 3).reshape((3, 3)),
              np.arange(3 * 3).reshape((3, 3)) * 10,
          ]
      )
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], mean)
      assert np.array_equal(res[1], cov)
  
      mean = np.array([[1, 2, 3]])
      cov = np.stack([np.eye(3) * 1e-5, np.eye(3) * 1e-4])
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], np.array([[1, 2, 3], [1, 2, 3]]))
      assert np.array_equal(res[1], cov)
  
      mean = np.array([[0], [10], [100]])
      cov = np.diag(np.array([1e-6]))
      params = [mean, cov]
      res = broadcast_params(params, ndims_params)
      assert np.array_equal(res[0], mean)
      assert np.array_equal(res[1], np.broadcast_to(cov, (3, 1, 1)))
  
      # Try it in PyTensor
      with config.change_flags(compute_test_value="raise"):
          mean = tensor(dtype=config.floatX, shape=(None, 1))
          mean.tag.test_value = np.array(
              [[0], [10], [100]], dtype=config.floatX
          )
          cov = matrix()
          cov.tag.test_value = np.diag(
              np.array([1e-6], dtype=config.floatX)
          )
          params = [mean, cov]
          res = broadcast_params(params, ndims_params)
          assert np.array_equal(
              res[0].get_test_value(), mean.get_test_value()
          )
          assert np.array_equal(
              res[1].get_test_value(),
              np.broadcast_to(cov.get_test_value(), (3, 1, 1)),
          )
  
file_path: pytensor/tests/tensor/random/test_utils.py
imports: import numpy
  import pytest
  from pytensor import config, function
  from pytensor.compile.mode import Mode
  from pytensor.graph.rewriting.db import RewriteDatabaseQuery
  from pytensor.tensor.random.utils import RandomStream, broadcast_params, supp_shape_from_ref_param_shape
  from pytensor.tensor.type import matrix, tensor
  from tests import unittest_tools
label_desc: Use image node_id 2 for calling a global function with example usage: test_broadcast_params() without return types