class_docstr: Only ``kernel_size`` ``in_channels`` and ``out_channels`` are supported. Kernel size candidates should be larger or smaller
  than each other in both candidates. See examples below:
  the following example is not allowed:
      >>> ValueChoice(candidates = [(5, 3), (3, 5)])
          □ ■ ■ ■ □   □ □ □ □ □
          □ ■ ■ ■ □   ■ ■ ■ ■ ■    # candidates are not bigger or smaller on both dimension
          □ ■ ■ ■ □   ■ ■ ■ ■ ■
          □ ■ ■ ■ □   ■ ■ ■ ■ ■
          □ ■ ■ ■ □   □ □ □ □ □
  the following 3 examples are valid:
      >>> ValueChoice(candidates = [5, 3, 1])
          ■ ■ ■ ■ ■   □ □ □ □ □   □ □ □ □ □
          ■ ■ ■ ■ ■   □ ■ ■ ■ □   □ □ □ □ □
          ■ ■ ■ ■ ■   □ ■ ■ ■ □   □ □ ■ □ □
          ■ ■ ■ ■ ■   □ ■ ■ ■ □   □ □ □ □ □
          ■ ■ ■ ■ ■   □ □ □ □ □   □ □ □ □ □
      >>> ValueChoice(candidates = [(5, 7), (3, 5), (1, 3)])
          ■ ■ ■ ■ ■ ■ ■  □ □ □ □ □ □ □   □ □ □ □ □ □ □
          ■ ■ ■ ■ ■ ■ ■  □ ■ ■ ■ ■ ■ □   □ □ □ □ □ □ □
          ■ ■ ■ ■ ■ ■ ■  □ ■ ■ ■ ■ ■ □   □ □ ■ ■ ■ □ □
          ■ ■ ■ ■ ■ ■ ■  □ ■ ■ ■ ■ ■ □   □ □ □ □ □ □ □
          ■ ■ ■ ■ ■ ■ ■  □ □ □ □ □ □ □   □ □ □ □ □ □ □
      >>> # when the difference between any two candidates is not even, the left upper will be picked:
      >>> ValueChoice(candidates = [(5, 5), (4, 4), (3, 3)])
          ■ ■ ■ ■ ■   ■ ■ ■ ■ □   □ □ □ □ □
          ■ ■ ■ ■ ■   ■ ■ ■ ■ □   □ ■ ■ ■ □
          ■ ■ ■ ■ ■   ■ ■ ■ ■ □   □ ■ ■ ■ □
          ■ ■ ■ ■ ■   ■ ■ ■ ■ □   □ ■ ■ ■ □
          ■ ■ ■ ■ ■   □ □ □ □ □   □ □ □ □ □
class_docstr_tok: ["Only","``","kernel_size","``","``","in_channels","``","and","``","out_channels","``","are","supported",".","Kernel","size","candidates","should","be","larger","or","smaller","than","each","other","in","both","candidates",".","See","examples","below",":","the","following","example","is","not","allowed",":",">",">",">","ValueChoice","(","candidates","=","[","(","5",",","3",")",",","(","3",",","5",")","]",")","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","#","candidates","are","not","bigger","or","smaller","on","both","dimension","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","the","following","3","examples","are","valid",":",">",">",">","ValueChoice","(","candidates","=","[","5",",","3",",","1","]",")","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a0","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1",">",">",">","ValueChoice","(","candidates","=","[","(","5",",","7",")",",","(","3",",","5",")",",","(","1",",","3",")","]",")","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1",">",">",">","#","when","the","difference","between","any","two","candidates","is","not","even",",","the","left","upper","will","be","picked",":",">",">",">","ValueChoice","(","candidates","=","[","(","5",",","5",")",",","(","4",",","4",")",",","(","3",",","3",")","]",")","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a0","\u25a0","\u25a0","\u25a1","\u25a0","\u25a0","\u25a0","\u25a0","\u25a0","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1","\u25a1"]
docstr: result = {
      'kernel_size': i,
      'out_channels': j
  }
  which means the best candidate for an argument is the i-th one if candidates are sorted in descending order
docstr_tok: ["result","=","{","'kernel_size","'",":","i",",","'out_channels","'",":","j","}","which","means","the","best","candidate","for","an","argument","is","the","i-th","one","if","candidates","are","sorted","in","descending","order"]
code: def export(self):
      """
      result = {
          'kernel_size': i,
          'out_channels': j
      }
      which means the best candidate for an argument is the i-th one if candidates are sorted in descending order
      """
      result = {}
      eps = 1e-5
      with torch.no_grad():
          if self.kernel_size_candidates is not None:
              weight = torch.zeros_like(self.weight)
              # ascending order
              for i in range(
                  len(self.kernel_size_candidates) - 2, -1, -1
              ):
                  mask = self.kernel_masks[i]
                  t = self.t_kernel[i]
                  cur_part = self.weight * mask
                  alpha = self.Lasso_sigmoid(cur_part, t)
                  if alpha <= eps:  # takes the smaller one
                      result[
                          "kernel_size"
                      ] = self.kernel_size_candidates[i + 1]
                      break
                  weight = (weight + cur_part) * alpha
  
              if "kernel_size" not in result:
                  result["kernel_size"] = self.kernel_size_candidates[0]
          else:
              weight = self.weight
  
          if self.out_channel_candidates is not None:
              for i in range(
                  len(self.out_channel_candidates) - 2, -1, -1
              ):
                  mask = self.channel_masks[i]
                  t = self.t_expansion[i]
                  alpha = self.Lasso_sigmoid(weight * mask, t)
                  if alpha <= eps:
                      result[
                          "out_channels"
                      ] = self.out_channel_candidates[i + 1]
  
              if "out_channels" not in result:
                  result["out_channels"] = self.out_channel_candidates[
                      0
                  ]
  
      return result
  
file_path: nni/nni/nas/oneshot/pytorch/supermodule/_singlepathnas.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from nni.nas.nn.pytorch import ValueChoice
label_desc: Use image node_id 5 for calling the DifferentiableSuperConv2d obj's underlying member method code with example usage: obj.export() and returns: result