class_docstr: Do various flavours of stochastic gradient descent, with first and
  second order momentum. Currently support 'vanilla' SGD, Adam, and RAdam.
class_docstr_tok: ["Do","various","flavours","of","stochastic","gradient","descent",",","with","first","and","second","order","momentum",".","Currently","support","'vanilla","'","SGD",",","Adam",",","and","RAdam","."]
code: def _set_attr_or_schedule(self, name, value):
      if isinstance(value, (float, bool, int)):
          setattr(self, name, value)
      else:
          if isinstance(value, list):
              value = iter(value)
          self.schedules[name] = value
          try:
              setattr(self, name, next(value))
          except (StopIteration, TypeError) as e:
              err = (
                  f"Invalid schedule for '{name}' ({type(value)})\n{e}"
              )
              raise ValueError(err)
  
file_path: thinc/thinc/optimizers.py
imports: import math
  from collections import defaultdict
  from typing import Dict, List, Optional, Tuple, Union, cast
  from .backends import get_array_ops
  from .config import registry
  from .types import FloatsXd, Generator
label_desc: Use image node_id 2 for calling the Optimizer obj's underlying member method code with example usage: obj._set_attr_or_schedule(name, value) without return types