class_docstr: Decorator for unit tests that forces a unit test to be attempted
  multiple times. The test needs to pass a certain number of times for it to
  be considered to have succeeded. If it doesn't pass enough times, it is
  considered to have failed.
  
  Warning : care should be exercised when using this decorator. For some
  tests, the fact that they fail randomly could point to important issues
  such as race conditions, usage of uninitialized memory region, etc. and
  using this decorator could hide these problems.
  
  Usage:
      @AttemptManyTimes(n_attempts=5, n_req_successes=3)
      def fct(args):
          ...
class_docstr_tok: ["Decorator","for","unit","tests","that","forces","a","unit","test","to","be","attempted","multiple","times",".","The","test","needs","to","pass","a","certain","number","of","times","for","it","to","be","considered","to","have","succeeded",".","If","it","does","n't","pass","enough","times",",","it","is","considered","to","have","failed",".","Warning",":","care","should","be","exercised","when","using","this","decorator",".","For","some","tests",",","the","fact","that","they","fail","randomly","could","point","to","important","issues","such","as","race","conditions",",","usage","of","uninitialized","memory","region",",","etc",".","and","using","this","decorator","could","hide","these","problems",".","Usage",":","@","AttemptManyTimes","(","n_attempts=5",",","n_req_successes=3",")","def","fct","(","args",")",":","..."]
code: def __init__(self, n_attempts, n_req_successes=1):
      assert n_attempts >= n_req_successes
      self.n_attempts = n_attempts
      self.n_req_successes = n_req_successes
  
imports: import logging
  import sys
  from copy import copy, deepcopy
  from functools import wraps
  import numpy
  import pytest
  import pytensor
  from pytensor.compile.debugmode import str_diagnostic
  from pytensor.configdefaults import config
  from pytensor.gradient import verify_grad
  from pytensor.tensor.basic import as_tensor_variable
  from pytensor.tensor.math import _allclose
  from pytensor.tensor.math import add
label_desc: Use image node_id 1 to create a new AttemptManyTimes object  with example: obj = AttemptManyTimes(n_attempts, n_req_successes)