class_docstr: A module that chooses from a tensor list and outputs a reduced tensor.
  The already-chosen version of InputChoice.
  
  When forward, ``chosen`` will be used to select inputs from ``candidate_inputs``,
  and ``reduction`` will be used to choose from those inputs to form a tensor.
  
  Attributes
  ----------
  chosen : list of int
      Indices of chosen inputs.
  reduction : ``mean`` | ``concat`` | ``sum`` | ``none``
      How to reduce the inputs when multiple are selected.
class_docstr_tok: ["A","module","that","chooses","from","a","tensor","list","and","outputs","a","reduced","tensor",".","The","already-chosen","version","of","InputChoice",".","When","forward",",","``","chosen","``","will","be","used","to","select","inputs","from","``","candidate_inputs","``",",","and","``","reduction","``","will","be","used","to","choose","from","those","inputs","to","form","a","tensor",".","Attributes","--","--","--","--","--","chosen",":","list","of","int","Indices","of","chosen","inputs",".","reduction",":","``","mean","``","|","``","concat","``","|","``","sum","``","|","``","none","``","How","to","reduce","the","inputs","when","multiple","are","selected","."]
code: def _tensor_reduction(
      reduction_type: str, tensor_list: List[torch.Tensor]
  ) -> Union[List[torch.Tensor], torch.Tensor, None]:
      if reduction_type == "none":
          return tensor_list
      if not tensor_list:
          return None  # empty. return None for now
      if len(tensor_list) == 1:
          return tensor_list[0]
      if reduction_type == "sum":
          return cast(torch.Tensor, sum(tensor_list))
      if reduction_type == "mean":
          return cast(torch.Tensor, sum(tensor_list) / len(tensor_list))
      if reduction_type == "concat":
          return torch.cat(tensor_list, dim=1)
      raise ValueError(
          f'Unrecognized reduction policy: "{reduction_type}"'
      )
  
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 3 for calling the ChosenInputs obj's underlying member method code with example usage: obj._tensor_reduction(reduction_type, tensor_list) and returns: tensor_list, None, tensor_list, cast, cast, torch