def unsafe_mark_active(self) -> "RandomStream":
    """Activates the random stream, returning itself for convenience."""
    if self.state != "pending":
      raise ValueError(
          "RandomStream instances can only be used as context managers once,"
          f" in state 'pending'. Got state {repr(self.state)}"
      )
    self.state = "active"
    return self
Activates the random stream, returning itself for convenience.
penzai/deprecated/v1/core/random_stream.py