code: def build_compiled_opt_kwarg_db():
      compiled_opt_db = []
      for optim_info in optim_db:
          if optim_info.optim_cls not in KERNEL_COUNTS:
              continue
  
          for optim_inputs in optim_info.optim_inputs_func():
              for device in ["cpu", "cuda"]:
                  for foreach in [True, False]:
                      if (
                          device == "cpu"
                          and "capturable" in optim_inputs.kwargs
                      ):
                          continue
  
                      kwargs = dict(optim_inputs.kwargs)
                      name = (
                          f"test_{optim_info.optim_cls.__name__.lower()}"
                          f"{'_foreach' if foreach else ''}"
                      )
  
                      for key in optim_inputs.kwargs:
                          if key == "lr":
                              continue
                          name += "_" + key
  
                      name += f"_{device}"
  
                      # Eager for-loop impl doesn't support capturable ASGD
                      if name == "test_asgd_capturable_cuda":
                          continue
  
                      kwargs["foreach"] = foreach
                      kwargs["device"] = device
                      if name in KERNEL_COUNT_OVERRIDES:
                          kwargs[
                              "kernel_count"
                          ] = KERNEL_COUNT_OVERRIDES[name]
                      else:
                          kwargs["kernel_count"] = (
                              KERNEL_COUNTS[
                                  optim_info.optim_cls
                              ].multitensor
                              if foreach and device == "cuda"
                              else KERNEL_COUNTS[
                                  optim_info.optim_cls
                              ].singletensor
                          )
  
                      # Note on tolerances:
                      # test_adadelta_foreach_rho_weight_decay_cuda
                      # Mismatched elements: 1 / 100 (1.0%)
                      # Greatest absolute difference: 2.0936131477355957e-05 at index (2, 7) (up to 2e-05 allowed)
                      # Greatest relative difference: 8.520411211065948e-05 at index (2, 7) (up to 1e-06 allowed)
                      if optim_info.optim_cls is Adadelta:
                          kwargs["rtol"] = 2e-5
                          kwargs["atol"] = 2e-5
  
                      compiled_opt_db.append(
                          (optim_info.optim_cls, name, kwargs)
                      )
  
      return compiled_opt_db
  
imports: import sys
  import unittest
  import weakref
  from copy import deepcopy
  from typing import NamedTuple
  import torch
  import torch._inductor
  from torch.optim import Adadelta, Adagrad, Adam, AdamW, ASGD, NAdam, RMSprop, Rprop
  from torch.testing._internal.common_optimizers import optim_db
  from torch.testing._internal.common_utils import TestCase
  from torch.testing._internal.inductor_utils import HAS_CPU, HAS_CUDA
label_desc: Use image node_id 1 for calling a global function with example usage: build_compiled_opt_kwarg_db() and returns: compiled_opt_db