code: def __init__(
      self,
      in_dim: int,
      out_dim: int,
      *,
      bias: bool = True,
      pruner_config: Optional[Dict[str, Any]] = None,
      init_method: Optional[str] = None,
      rank: Optional[int] = None,
      rank_ratio: Optional[float] = None,
      hook: Optional[IBasicHook] = None,
  ):
      super().__init__()
      original_rank = min(in_dim, out_dim)
      if rank is None:
          if rank_ratio is not None:
              rank = round(original_rank * rank_ratio)
      if rank is not None and rank >= original_rank:
          print_warning(
              f"specified rank ({rank}) should be smaller than "
              f"the original rank ({original_rank})"
          )
      if rank is None:
          self.w1 = self.w2 = self.b = None
          self.linear = nn.Linear(in_dim, out_dim, bias)
      else:
          self.w1 = nn.Parameter(torch.zeros(rank, in_dim))
          self.w2 = nn.Parameter(torch.zeros(out_dim, rank))
          self.b = (
              nn.Parameter(torch.zeros(1, out_dim)) if bias else None
          )
          self.linear = None
      if pruner_config is None:
          self.pruner = self.pruner1 = self.pruner2 = None
      else:
          if rank is None:
              self.pruner1 = self.pruner2 = None
              self.pruner = Pruner(pruner_config, [out_dim, in_dim])
          else:
              self.pruner1 = Pruner(pruner_config, [rank, in_dim])
              self.pruner2 = Pruner(pruner_config, [out_dim, rank])
              self.pruner = None
      # initialize
      init_method = init_method or "xavier_normal"
      init_fn = getattr(
          nn.init, f"{init_method}_", nn.init.xavier_normal_
      )
      self.init_weights_with(lambda t: init_fn(t, 1.0 / math.sqrt(2.0)))
      # hook
      self.hook = hook
  
imports: import math
  import torch
  import numpy
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Union
  from typing import Callable
  from typing import Optional
  from functools import partial
  from torch.nn import Module
  from cftool.misc import print_warning
  from .hooks import IBasicHook
label_desc: Use image node_id 1 to create a new Linear object from inherited base classes: Module with example: obj = Linear(in_dim, out_dim)