code: def freeze_non_lora(
      module: nn.Module,
      unfreeze_bias: Literal["none", "all", "lora_only"] = "none",
  ) -> None:
      # Set requires_grad to False for all parameters in the module except
      # lora layers
      for submodule in module.modules():
          if isinstance(submodule, LoRALayer):
              for param_name, param in submodule.named_parameters(
                  recurse=False
              ):
                  if param_name in ["lora_A", "lora_B"]:
                      param.requires_grad = True
                  elif param_name == "bias" and unfreeze_bias in [
                      "all",
                      "lora_only",
                  ]:
                      param.requires_grad = True
                  else:
                      param.requires_grad = False
          else:
              for param_name, param in submodule.named_parameters(
                  recurse=False
              ):
                  if param_name == "bias" and unfreeze_bias == "all":
                      param.requires_grad = True
                  else:
                      param.requires_grad = False
  
imports: import math
  import re
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from typing import Any, Dict, List, Literal, Optional, final
  import torch
  import torch.nn
  from torch import Tensor
  from torch.nn import Dropout
  from torch.nn.functional import embedding, linear
  from torch.nn.parameter import Parameter
  from fairseq2.nn import Embedding, Projection
  from fairseq2.typing import DataType, Device
label_desc: Use image node_id 6 for calling a global function with example usage: freeze_non_lora(module, unfreeze_bias) without return types