class_docstr: An operation which builds an optimizer for an OpenAlphaTensor model.
class_docstr_tok: ["An","operation","which","builds","an","optimizer","for","an","OpenAlphaTensor","model","."]
docstr: Builds the optimizer for the OpenAlphaTensor model.
  
  Args:
      optimizer_name (str): Name of the optimizer used.
      model (AlphaTensorModel): OpenAlphaTensor model to be trained.
      lr (float): Learning rate.
      weight_decay (float): Weight decay used by the optimizer.
docstr_tok: ["Builds","the","optimizer","for","the","OpenAlphaTensor","model",".","Args",":","optimizer_name","(","str",")",":","Name","of","the","optimizer","used",".","model","(","AlphaTensorModel",")",":","OpenAlphaTensor","model","to","be","trained",".","lr","(","float",")",":","Learning","rate",".","weight_decay","(","float",")",":","Weight","decay","used","by","the","optimizer","."]
code: def execute(
      self,
      optimizer_name: str,
      model: AlphaTensorModel,
      lr: float,
      weight_decay: float,
  ):
      """Builds the optimizer for the OpenAlphaTensor model.
  
      Args:
          optimizer_name (str): Name of the optimizer used.
          model (AlphaTensorModel): OpenAlphaTensor model to be trained.
          lr (float): Learning rate.
          weight_decay (float): Weight decay used by the optimizer.
      """
      if optimizer_name == "adam":
          optimizer = torch.optim.Adam(model.parameters(), lr=lr)
      elif optimizer_name == "adamw":
          optimizer = torch.optim.AdamW(
              model.parameters(), lr=lr, weight_decay=weight_decay
          )
      elif optimizer_name == "sgd":
          optimizer = torch.optim.SGD(model.parameters(), lr=lr)
      else:
          raise ValueError(f"Optimizer {optimizer_name} not supported")
      self._optimizer = optimizer
  
imports: import json
  from pathlib import Path
  from typing import Any
  import torch
  from nebullvm.operations.base import Operation
  from open_alpha_tensor.core.modules.alpha_tensor import AlphaTensorModel
label_desc: Use image node_id 2 for calling the BuildOptimizerOp obj's underlying member method code with example usage: obj.execute(optimizer_name, model, lr, weight_decay) without return types