code: def choice(
      label: str, choices: list[T] | list[Module]
  ) -> Categorical[T] | LayerChoice:
      """Choose from a list of options.
  
      By default, it will create a :class:`~nni.mutable.Categorical` object.
      ``choices`` should be a list of numbers or a list of strings.
      Using arbitrary objects as members of this list (like sublists, a mixture of numbers and strings, or null values)
      should work in most cases, but may trigger undefined behaviors.
      If PyTorch modules are presented in the choices, it will create a :class:`~nni.nas.nn.pytorch.LayerChoice`.
  
      For most search algorithms, choice are non-ordinal.
      Even if the choices are numbers, they will still be treated as individual options,
      and their numeric values will be neglected.
  
      Nested choices (i.e., choice inside one of the options) is not currently supported by this API.
  
      Examples
      --------
      >>> nni.choice('x', [1, 2, 3])
      Categorical([1, 2, 3], label='x')
      >>> nni.choice('conv', [nn.Conv2d(3, 3, 3), nn.Conv2d(3, 3, 5)])
      LayerChoice(
          label='conv'
          (0): Conv2d(3, 3, kernel_size=(3, 3), stride=(1, 1))
          (1): Conv2d(3, 3, kernel_size=(5, 5), stride=(1, 1))
      )
      """
      try:
          from torch.nn import Module
  
          if all(isinstance(c, Module) for c in choices):
              from nni.nas.nn.pytorch import LayerChoice
  
              return LayerChoice(
                  cast(List[Module], choices), label=label
              )
  
          from torch import Tensor
  
          if any(isinstance(c, Tensor) for c in choices):
              raise TypeError(
                  "Please do not use choice to choose from tensors. "
                  "If you are using this in forward, please use `InputChoice` explicitly in `__init__` instead."
              )
      except ImportError:
          # In case PyTorch is not installed.
          pass
  
      return Categorical(cast(List[T], choices), label=label)
  
file_path: nni/nni/mutable/shortcut.py
imports: from __future__ import annotations
  import logging
  from typing import TYPE_CHECKING, TypeVar, overload, List, cast
  from .mutable import Categorical, Numerical
label_desc: Use image node_id 3 for calling a global function with example usage: choice(label, choices) and returns: Categorical, LayerChoice