code: def test_set_value_borrow(rng_ctor):
      s_rng = shared(rng_ctor(123))
  
      new_rng = rng_ctor(234234)
  
      # Test the borrow contract is respected:
      # assigning with borrow=False makes a copy
      s_rng.set_value(new_rng, borrow=False)
      assert new_rng is not s_rng.container.storage[0]
      if hasattr(new_rng, "randn"):
          assert new_rng.randn() == s_rng.container.storage[0].randn()
      else:
          assert (
              new_rng.standard_normal()
              == s_rng.container.storage[0].standard_normal()
          )
  
      # Test that the current implementation is actually borrowing when it can.
      rr = rng_ctor(33)
      s_rng.set_value(rr, borrow=True)
      assert rr is s_rng.container.storage[0]
  
imports: import numpy
  import pytest
  from pytensor import shared
label_desc: Use image node_id 4 for calling a global function with example usage: test_set_value_borrow(rng_ctor) without return types