class_docstr: A wrapper class of storage backends.
  
  This class is used in :func:`~optuna.get_storage` function and automatically
  wraps :class:`~optuna.storages.RDBStorage` class.
  
  :class:`~optuna.storages._CachedStorage` meets the following **Data persistence** requirements.
  
  **Data persistence**
  
  :class:`~optuna.storages._CachedStorage` does not guarantee that write operations are logged
  into a persistent storage, even when write methods succeed.
  Thus, when process failure occurs, some writes might be lost.
  As exceptions, when a persistent storage is available, any writes on any attributes
  of `Study` and writes on `state` of `Trial` are guaranteed to be persistent.
  Additionally, any preceding writes on any attributes of `Trial` are guaranteed to
  be written into a persistent storage before writes on `state` of `Trial` succeed.
  The same applies for `param`, `user_attrs', 'system_attrs' and 'intermediate_values`
  attributes.
  
  Args:
      backend:
          :class:`~optuna.storages.RDBStorage` class instance to wrap.
class_docstr_tok: ["A","wrapper","class","of","storage","backends",".","This","class","is","used","in",":","func",":","`","~optuna.get_storage","`","function","and","automatically","wraps",":","class",":","`","~optuna.storages.RDBStorage","`","class",".",":","class",":","`","~optuna.storages._CachedStorage","`","meets","the","following","*","*","Data","persistence","*","*","requirements",".","*","*","Data","persistence","*","*",":","class",":","`","~optuna.storages._CachedStorage","`","does","not","guarantee","that","write","operations","are","logged","into","a","persistent","storage",",","even","when","write","methods","succeed",".","Thus",",","when","process","failure","occurs",",","some","writes","might","be","lost",".","As","exceptions",",","when","a","persistent","storage","is","available",",","any","writes","on","any","attributes","of","`","Study","`","and","writes","on","`","state","`","of","`","Trial","`","are","guaranteed","to","be","persistent",".","Additionally",",","any","preceding","writes","on","any","attributes","of","`","Trial","`","are","guaranteed","to","be","written","into","a","persistent","storage","before","writes","on","`","state","`","of","`","Trial","`","succeed",".","The","same","applies","for","`","param","`",",","`","user_attrs","'",",","'system_attrs","'","and","'intermediate_values","`","attributes",".","Args",":","backend",":",":","class",":","`","~optuna.storages.RDBStorage","`","class","instance","to","wrap","."]
code: def create_new_trial(
      self, study_id: int, template_trial: Optional[FrozenTrial] = None
  ) -> int:
      frozen_trial = self._backend._create_new_trial(
          study_id, template_trial
      )
      trial_id = frozen_trial._trial_id
      with self._lock:
          if study_id not in self._studies:
              self._studies[study_id] = _StudyInfo()
          study = self._studies[study_id]
          self._add_trials_to_cache(study_id, [frozen_trial])
          # Since finished trials will not be modified by any worker, we do not
          # need storage access for them.
          if frozen_trial.state.is_finished():
              study.finished_trial_ids.add(frozen_trial._trial_id)
      return trial_id
  
imports: import copy
  import threading
  from typing import Any
  from typing import Callable
  from typing import Container
  from typing import Dict
  from typing import List
  from typing import Optional
  from typing import Sequence
  from typing import Set
  from typing import Tuple
  from typing import Union
  import optuna
  from optuna import distributions
  from optuna._typing import JSONSerializable
  from optuna.storages import BaseStorage
  from optuna.storages._heartbeat import BaseHeartbeat
  from optuna.storages._rdb.storage import RDBStorage
  from optuna.study._frozen import FrozenStudy
  from optuna.study._study_direction import StudyDirection
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
label_desc: Use image node_id 14 for calling the _CachedStorage obj's underlying member method code with example usage: obj.create_new_trial(study_id, template_trial) and returns: trial_id