class_docstr: Update a parameter during training by using a user defined callable object.
      User defined callable object is taking an event index as input and returns parameter value.
  
  Args:
      lambda_obj: user defined callable object.
      param_name: name of parameter to update.
      save_history: whether to log the parameter values to
          `engine.state.param_history`, (default=False).
      create_new: whether to create ``param_name`` on
          ``engine.state`` taking into account whether
          ``param_name`` attribute already exists or not.
          Overrides existing attribute by default, (default=False).
  
  Examples:
  
      .. include:: defaults.rst
          :start-after: :orphan:
  
      .. testcode::
  
          default_trainer = get_default_trainer()
  
          class LambdaState:
              def __init__(self, initial_value, gamma):
                  self.initial_value = initial_value
                  self.gamma = gamma
  
              def __call__(self, event_index):
                  return self.initial_value * self.gamma ** (event_index % 9)
  
          param_scheduler = LambdaStateScheduler(
              param_name="param", lambda_obj=LambdaState(1, 0.9), create_new=True
          )
  
          # parameter is param, initial_value sets param to 1 and in this example gamma = 1
          # using class 'LambdaState' user defined callable object can be created
          # update a parameter during training by using a user defined callable object
          # user defined callable object is taking an event index as input and returns parameter value
          # in this example, we update as initial_value * gamma ** (event_endex % 9)
          # in every Epoch the parameter is updated as 1 * 0.9 ** (Epoch % 9)
          # In Epoch 3, parameter param = 1 * 0.9 ** (3 % 9) = 0.729
          # In Epoch 10, parameter param = 1 * 0.9 ** (10 % 9) = 0.9
  
          param_scheduler.attach(default_trainer, Events.EPOCH_COMPLETED)
  
          @default_trainer.on(Events.EPOCH_COMPLETED)
          def print_param():
              print(default_trainer.state.param)
  
          default_trainer.run([0], max_epochs=10)
  
      .. testoutput::
  
          0.9
          0.81
          0.7290...
          0.6561
          0.5904...
          0.5314...
          0.4782...
          0.4304...
          1.0
          0.9
  
  .. versionadded:: 0.4.7
class_docstr_tok: ["Update","a","parameter","during","training","by","using","a","user","defined","callable","object",".","User","defined","callable","object","is","taking","an","event","index","as","input","and","returns","parameter","value",".","Args",":","lambda_obj",":","user","defined","callable","object",".","param_name",":","name","of","parameter","to","update",".","save_history",":","whether","to","log","the","parameter","values","to","`","engine.state.param_history","`",",","(","default=False",")",".","create_new",":","whether","to","create","``","param_name","``","on","``","engine.state","``","taking","into","account","whether","``","param_name","``","attribute","already","exists","or","not",".","Overrides","existing","attribute","by","default",",","(","default=False",")",".","Examples",":","..","include",":",":","defaults.rst",":","start-after",":",":","orphan",":","..","testcode",":",":","default_trainer","=","get_default_trainer","(",")","class","LambdaState",":","def","__init__","(","self",",","initial_value",",","gamma",")",":","self.initial_value","=","initial_value","self.gamma","=","gamma","def","__call__","(","self",",","event_index",")",":","return","self.initial_value","*","self.gamma","*","*","(","event_index","%","9",")","param_scheduler","=","LambdaStateScheduler","(","param_name=","''","param","''",",","lambda_obj=LambdaState","(","1",",","0.9",")",",","create_new=True",")","#","parameter","is","param",",","initial_value","sets","param","to","1","and","in","this","example","gamma","=","1","#","using","class","'LambdaState","'","user","defined","callable","object","can","be","created","#","update","a","parameter","during","training","by","using","a","user","defined","callable","object","#","user","defined","callable","object","is","taking","an","event","index","as","input","and","returns","parameter","value","#","in","this","example",",","we","update","as","initial_value","*","gamma","*","*","(","event_endex","%","9",")","#","in","every","Epoch","the","parameter","is","updated","as","1","*","0.9","*","*","(","Epoch","%","9",")","#","In","Epoch","3",",","parameter","param","=","1","*","0.9","*","*","(","3","%","9",")","=","0.729","#","In","Epoch","10",",","parameter","param","=","1","*","0.9","*","*","(","10","%","9",")","=","0.9","param_scheduler.attach","(","default_trainer",",","Events.EPOCH_COMPLETED",")","@","default_trainer.on","(","Events.EPOCH_COMPLETED",")","def","print_param","(",")",":","print","(","default_trainer.state.param",")","default_trainer.run","(","[","0","]",",","max_epochs=10",")","..","testoutput",":",":","0.9","0.81","0.7290","...","0.6561","0.5904","...","0.5314","...","0.4782","...","0.4304","...","1.0","0.9","..","versionadded",":",":","0.4.7"]
code: def __init__(
      self,
      lambda_obj: Any,
      param_name: str,
      save_history: bool = False,
      create_new: bool = False,
  ):
      super(LambdaStateScheduler, self).__init__(
          param_name, save_history, create_new
      )
  
      if not callable(lambda_obj):
          raise ValueError("Expected lambda_obj to be callable.")
  
      self.lambda_obj = lambda_obj
      self._state_attrs += ["lambda_obj"]
  
imports: import numbers
  import warnings
  from bisect import bisect_right
  from typing import Any, List, Sequence, Tuple, Union
  from ignite.engine import CallableEventWithFilter, Engine, Events, EventsList
  from ignite.handlers.param_scheduler import BaseParamScheduler
label_desc: Use image node_id 1 to create a new LambdaStateScheduler object from inherited base classes: StateParamScheduler with example: obj = LambdaStateScheduler(lambda_obj, param_name, save_history, create_new)