code: def forward(ctx, x, dutyCycles, k, boostStrength):
      
      batchSize = x.shape[0]
      if boostStrength > 0.0:
        targetDensity = float(k) / (x.shape[1] * x.shape[2] * x.shape[3])
        boostFactors = torch.exp((targetDensity - dutyCycles) * boostStrength)
        boosted = x.detach() * boostFactors
      else:
        boosted = x.detach()
  
      # Take the boosted version of the input x, find the top k winners.
      # Compute an output that only contains the values of x corresponding to the top k
      # boosted values. The rest of the elements in the output should be 0.
      boosted = boosted.reshape((batchSize, -1))
      xr = x.reshape((batchSize, -1))
      res = torch.zeros_like(boosted)
      topk, indices = boosted.topk(k, dim=1, sorted=False)
      res.scatter_(1, indices, xr.gather(1, indices))
      res = res.reshape(x.shape)
  
      ctx.save_for_backward(indices)
      return res
docs: Use the boost strength to compute a boost factor for each unit represented
      in x. These factors are used to increase the impact of each unit to improve
      their chances of being chosen. This encourages participation of more columns
      in the learning process. See :meth:`k_winners.forward` for more details.
  
      :param ctx:
        Place where we can store information we will need to compute the gradients
        for the backward pass.
  
      :param x:
        Current activity of each unit.
  
      :param dutyCycles:
        The averaged duty cycle of each unit.
  
      :param k:
        The activity of the top k units will be allowed to remain, the rest are
        set to zero.
  
      :param boostStrength:
        A boost strength of 0.0 has no effect on x.
  
      :return:
        A tensor representing the activity of x after k-winner take all.