class_docstr: Tracks experiment specifications.
  
  Implicitly registers the Trainable if needed. The args here take
  the same meaning as the arguments defined `tune.py:run`.
  
  .. code-block:: python
  
      experiment_spec = Experiment(
          "my_experiment_name",
          my_func,
          stop={"mean_accuracy": 100},
          config={
              "alpha": tune.grid_search([0.2, 0.4, 0.6]),
              "beta": tune.grid_search([1, 2]),
          },
          resources_per_trial={
              "cpu": 1,
              "gpu": 0
          },
          num_samples=10,
          local_dir="~/ray_results",
          checkpoint_freq=10,
          max_failures=2)
class_docstr_tok: ["Tracks","experiment","specifications",".","Implicitly","registers","the","Trainable","if","needed",".","The","args","here","take","the","same","meaning","as","the","arguments","defined","`","tune.py",":","run","`",".","..","code-block",":",":","python","experiment_spec","=","Experiment","(","``","my_experiment_name","''",",","my_func",",","stop=","{","``","mean_accuracy","''",":","100","}",",","config=","{","``","alpha","''",":","tune.grid_search","(","[","0.2",",","0.4",",","0.6","]",")",",","``","beta","''",":","tune.grid_search","(","[","1",",","2","]",")",",","}",",","resources_per_trial=","{","``","cpu","''",":","1",",","``","gpu","''",":","0","}",",","num_samples=10",",","local_dir=","''","~\/ray_results","''",",","checkpoint_freq=10",",","max_failures=2",")"]
docstr: Registers Trainable or Function at runtime.
  
  Assumes already registered if run_object is a string.
  Also, does not inspect interface of given run_object.
  
  Args:
      run_object: Trainable to run. If string,
          assumes it is an ID and does not modify it. Otherwise,
          returns a string corresponding to the run_object name.
  
  Returns:
      A string representing the trainable identifier.
docstr_tok: ["Registers","Trainable","or","Function","at","runtime",".","Assumes","already","registered","if","run_object","is","a","string",".","Also",",","does","not","inspect","interface","of","given","run_object",".","Args",":","run_object",":","Trainable","to","run",".","If","string",",","assumes","it","is","an","ID","and","does","not","modify","it",".","Otherwise",",","returns","a","string","corresponding","to","the","run_object","name",".","Returns",":","A","string","representing","the","trainable","identifier","."]
code: def register_if_needed(cls, run_object: Union[str, Callable, Type]):
      """Registers Trainable or Function at runtime.
  
      Assumes already registered if run_object is a string.
      Also, does not inspect interface of given run_object.
  
      Args:
          run_object: Trainable to run. If string,
              assumes it is an ID and does not modify it. Otherwise,
              returns a string corresponding to the run_object name.
  
      Returns:
          A string representing the trainable identifier.
      """
      from ray.tune.search.sample import Domain
  
      if isinstance(run_object, str):
          return run_object
      elif isinstance(run_object, Domain):
          logger.warning(
              "Not registering trainable. Resolving as variant."
          )
          return run_object
      name = cls.get_trainable_name(run_object)
      try:
          register_trainable(name, run_object)
      except (TypeError, PicklingError) as e:
          extra_msg = (
              "Other options: "
              "\n-Try reproducing the issue by calling "
              "`pickle.dumps(trainable)`. "
              "\n-If the error is typing-related, try removing "
              "the type annotations and try again."
          )
          raise type(e)(str(e) + " " + extra_msg) from None
      return name
  
imports: import copy
  import datetime
  from functools import partial
  import logging
  from pathlib import Path
  from pickle import PicklingError
  import pprint
  import traceback
  from typing import Any, Dict, Optional, Sequence, Union, Callable, Type, List, Mapping, TYPE_CHECKING
  import ray
  from ray.exceptions import RpcError
  from ray.train import CheckpointConfig, SyncConfig
  from ray.train._internal.storage import StorageContext
  from ray.tune.error import TuneError
  from ray.tune.registry import register_trainable, is_function_trainable
  from ray.tune.stopper import CombinedStopper, FunctionStopper, Stopper, TimeoutStopper
  from ray.util.annotations import DeveloperAPI, Deprecated
label_desc: Use image node_id 4 for calling the Experiment obj's underlying member method code with example usage: obj.register_if_needed(cls, run_object) and returns: name, run_object, run_object