class_docstr: Interface for Module that allows registering buffers/parameters with configurable optimizer hyperparameters. # noqa
class_docstr_tok: ["Interface","for","Module","that","allows","registering","buffers\/parameters","with","configurable","optimizer","hyperparameters",".","#","noqa"]
docstr: Register a tensor with a configurable learning rate and 0 weight decay.
docstr_tok: ["Register","a","tensor","with","a","configurable","learning","rate","and","0","weight","decay","."]
code: def register(self, name, tensor, lr=None):
      """Register a tensor with a configurable learning rate and 0 weight decay."""
      if lr == 0.0:
          self.register_buffer(name, tensor)
      else:
          self.register_parameter(name, nn.Parameter(tensor))
  
          optim = {"weight_decay": 0.0}
          if lr is not None:
              optim["lr"] = lr
          setattr(getattr(self, name), "_optim", optim)
  
imports: import logging
  import math
  import os
  from functools import wraps
  from typing import Any, Callable, Optional
  import numpy
  import opt_einsum
  import torch
  import torch.nn
  import torch.nn.functional
  from einops import rearrange, repeat
  from espnet2.asr.state_spaces.components import Activation, DropoutNd, LinearActivation
label_desc: Use image node_id 1 for calling the OptimModule obj's underlying member method code with example usage: obj.register(name, tensor, lr) without return types