code: def __init__(
      self,
      model_dim,
      num_global_experts,
      k=1,
      fp32_gate=False,
      proj_dim=256,
      init_t=0.5,
      **options,
  ):
      super(CosineTopKGate, self).__init__()
      self.top_k = min(num_global_experts, int(k))
      self.fp32_gate = fp32_gate
      self.temperature = torch.nn.Parameter(
          torch.log(torch.full([1], 1.0 / init_t)), requires_grad=True
      )
      self.cosine_projector = torch.nn.Linear(model_dim, proj_dim)
      self.sim_matrix = torch.nn.Parameter(
          torch.randn(size=(proj_dim, num_global_experts)),
          requires_grad=True,
      )
      self.clamp_max = torch.log(torch.tensor(1.0 / 0.01)).item()
      torch.nn.init.normal_(self.sim_matrix, 0, 0.01)
  
      for opt in options:
          if opt not in ("capacity_factor", "gate_noise"):
              raise Exception(
                  "Unrecognized argument provided to Gating module: %s"
                  % opt
              )
  
imports: import torch
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new CosineTopKGate object from inherited base classes: torch.nn with example: obj = CosineTopKGate(model_dim, num_global_experts, k, fp32_gate, proj_dim, init_t)