class_docstr: Retry a failed trial up to a maximum number of times.
  
  When a trial fails, this callback can be used with a class in :mod:`optuna.storages` to
  recreate the trial in ``TrialState.WAITING`` to queue up the trial to be run again.
  
  The failed trial can be identified by the
  :func:`~optuna.storages.RetryFailedTrialCallback.retried_trial_number` function.
  Even if repetitive failure occurs (a retried trial fails again),
  this method returns the number of the original trial.
  To get a full list including the numbers of the retried trials as well as their original trial,
  call the :func:`~optuna.storages.RetryFailedTrialCallback.retry_history` function.
  
  This callback is helpful in environments where trials may fail due to external conditions,
  such as being preempted by other processes.
  
  Usage:
  
      .. testcode::
  
          import optuna
          from optuna.storages import RetryFailedTrialCallback
  
          storage = optuna.storages.RDBStorage(
              url="sqlite:///:memory:",
              heartbeat_interval=60,
              grace_period=120,
              failed_trial_callback=RetryFailedTrialCallback(max_retry=3),
          )
  
          study = optuna.create_study(
              storage=storage,
          )
  
  .. seealso::
      See :class:`~optuna.storages.RDBStorage`.
  
  Args:
      max_retry:
          The max number of times a trial can be retried. Must be set to :obj:`None` or an
          integer. If set to the default value of :obj:`None` will retry indefinitely.
          If set to an integer, will only retry that many times.
      inherit_intermediate_values:
          Option to inherit `trial.intermediate_values` reported by
          :func:`optuna.trial.Trial.report` from the failed trial. Default is :obj:`False`.
class_docstr_tok: ["Retry","a","failed","trial","up","to","a","maximum","number","of","times",".","When","a","trial","fails",",","this","callback","can","be","used","with","a","class","in",":","mod",":","`","optuna.storages","`","to","recreate","the","trial","in","``","TrialState.WAITING","``","to","queue","up","the","trial","to","be","run","again",".","The","failed","trial","can","be","identified","by","the",":","func",":","`","~optuna.storages.RetryFailedTrialCallback.retried_trial_number","`","function",".","Even","if","repetitive","failure","occurs","(","a","retried","trial","fails","again",")",",","this","method","returns","the","number","of","the","original","trial",".","To","get","a","full","list","including","the","numbers","of","the","retried","trials","as","well","as","their","original","trial",",","call","the",":","func",":","`","~optuna.storages.RetryFailedTrialCallback.retry_history","`","function",".","This","callback","is","helpful","in","environments","where","trials","may","fail","due","to","external","conditions",",","such","as","being","preempted","by","other","processes",".","Usage",":","..","testcode",":",":","import","optuna","from","optuna.storages","import","RetryFailedTrialCallback","storage","=","optuna.storages.RDBStorage","(","url=","''","sqlite",":","\/\/\/",":","memory",":","''",",","heartbeat_interval=60",",","grace_period=120",",","failed_trial_callback=RetryFailedTrialCallback","(","max_retry=3",")",",",")","study","=","optuna.create_study","(","storage=storage",",",")","..","seealso",":",":","See",":","class",":","`","~optuna.storages.RDBStorage","`",".","Args",":","max_retry",":","The","max","number","of","times","a","trial","can","be","retried",".","Must","be","set","to",":","obj",":","`","None","`","or","an","integer",".","If","set","to","the","default","value","of",":","obj",":","`","None","`","will","retry","indefinitely",".","If","set","to","an","integer",",","will","only","retry","that","many","times",".","inherit_intermediate_values",":","Option","to","inherit","`","trial.intermediate_values","`","reported","by",":","func",":","`","optuna.trial.Trial.report","`","from","the","failed","trial",".","Default","is",":","obj",":","`","False","`","."]
code: def __init__(
      self,
      max_retry: Optional[int] = None,
      inherit_intermediate_values: bool = False,
  ) -> None:
      self._max_retry = max_retry
      self._inherit_intermediate_values = inherit_intermediate_values
  
file_path: optuna/optuna/_callbacks.py
imports: from typing import Any
  from typing import Container
  from typing import Dict
  from typing import List
  from typing import Optional
  import optuna
  from optuna._experimental import experimental_class
  from optuna._experimental import experimental_func
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
label_desc: Use image node_id 1 to create a new RetryFailedTrialCallback object  with example: obj = RetryFailedTrialCallback(max_retry, inherit_intermediate_values)