class_docstr: Input choice selects ``n_chosen`` inputs from ``choose_from`` (contains ``n_candidates`` keys).
  
  It is mainly for choosing (or trying) different connections. It takes several tensors and chooses ``n_chosen`` tensors from them.
  When specific inputs are chosen, ``InputChoice`` will become :class:`ChosenInputs`.
  
  Use ``reduction`` to specify how chosen inputs are reduced into one output. A few options are:
  
  * ``none``: do nothing and return the list directly.
  * ``sum``: summing all the chosen inputs.
  * ``mean``: taking the average of all chosen inputs.
  * ``concat``: concatenate all chosen inputs at dimension 1.
  
  We don't support customizing reduction yet.
  
  Parameters
  ----------
  n_candidates : int
      Number of inputs to choose from. It is required.
  n_chosen : int
      Recommended inputs to choose. If None, mutator is instructed to select any.
  reduction : str
      ``mean``, ``concat``, ``sum`` or ``none``.
  weights : list of float
      Prior distribution used in random sampling.
  label : str
      Identifier of the input choice.
  
  Examples
  --------
  ::
  
      # import nni.nas.nn.pytorch as nn
      # declared in `__init__` method
      self.input_switch = nn.InputChoice(n_chosen=1)
      # invoked in `forward` method, choose one from the three
      out = self.input_switch([tensor1, tensor2, tensor3])
class_docstr_tok: ["Input","choice","selects","``","n_chosen","``","inputs","from","``","choose_from","``","(","contains","``","n_candidates","``","keys",")",".","It","is","mainly","for","choosing","(","or","trying",")","different","connections",".","It","takes","several","tensors","and","chooses","``","n_chosen","``","tensors","from","them",".","When","specific","inputs","are","chosen",",","``","InputChoice","``","will","become",":","class",":","`","ChosenInputs","`",".","Use","``","reduction","``","to","specify","how","chosen","inputs","are","reduced","into","one","output",".","A","few","options","are",":","*","``","none","``",":","do","nothing","and","return","the","list","directly",".","*","``","sum","``",":","summing","all","the","chosen","inputs",".","*","``","mean","``",":","taking","the","average","of","all","chosen","inputs",".","*","``","concat","``",":","concatenate","all","chosen","inputs","at","dimension","1",".","We","do","n't","support","customizing","reduction","yet",".","Parameters","--","--","--","--","--","n_candidates",":","int","Number","of","inputs","to","choose","from",".","It","is","required",".","n_chosen",":","int","Recommended","inputs","to","choose",".","If","None",",","mutator","is","instructed","to","select","any",".","reduction",":","str","``","mean","``",",","``","concat","``",",","``","sum","``","or","``","none","``",".","weights",":","list","of","float","Prior","distribution","used","in","random","sampling",".","label",":","str","Identifier","of","the","input","choice",".","Examples","--","--","--","--",":",":","#","import","nni.nas.nn.pytorch","as","nn","#","declared","in","`","__init__","`","method","self.input_switch","=","nn.InputChoice","(","n_chosen=1",")","#","invoked","in","`","forward","`","method",",","choose","one","from","the","three","out","=","self.input_switch","(","[","tensor1",",","tensor2",",","tensor3","]",")"]
code: def _inner_choice(
      n_candidates: int,
      n_chosen: Optional[int],
      weights: Optional[List[float]],
      label: Optional[str],
  ) -> CategoricalMultiple:
      return CategoricalMultiple(
          range(n_candidates),
          n_chosen=n_chosen,
          weights=weights,
          label=label,
      )
  
imports: import functools
  import warnings
  from typing import Any, Iterator, List, Optional, Dict, Union, Tuple, cast
  from typing_extensions import Literal
  import torch
  import torch.nn
  from nni.mutable import Categorical, CategoricalMultiple, Sample, SampleValidationError, ensure_frozen
  from .base import MutableModule, recursive_freeze
label_desc: Use image node_id 2 for calling the InputChoice obj's underlying member method code with example usage: obj._inner_choice(n_candidates, n_chosen, weights, label) and returns: CategoricalMultiple