code: def oneshot_mode(
      mutable_id,
      mutable_layer_id,
      funcs,
      funcs_args,
      fixed_inputs,
      optional_inputs,
      optional_input_size,
      tf,
  ):
      """Similar to enas mode, oneshot mode also builds the full model graph.
      The difference is that oneshot mode does not receive subgraph.
      Instead, it uses dropout to randomly dropout inputs and ops."""
      # NNI requires to get_next_parameter before report a result. But the parameter will not be used in this mode
      if trial.get_current_parameter() is None:
          trial.get_next_parameter()
      optional_inputs = list(optional_inputs.values())
      inputs_num = len(optional_inputs)
      # Calculate dropout rate according to the formular r^(1/k), where r is a hyper-parameter and k is the number of inputs
      if inputs_num > 0:
          rate = 0.01 ** (1 / inputs_num)
          noise_shape = [inputs_num] + [1] * len(
              optional_inputs[0].get_shape()
          )
          optional_inputs = tf.nn.dropout(
              optional_inputs, rate=rate, noise_shape=noise_shape
          )
          optional_inputs = [
              optional_inputs[idx] for idx in range(inputs_num)
          ]
      layer_outs = [
          func([fixed_inputs, optional_inputs], **funcs_args[func_name])
          for func_name, func in funcs.items()
      ]
      output_num = len(layer_outs)
      rate = 0.01 ** (1 / output_num)
      noise_shape = [output_num] + [1] * len(layer_outs[0].get_shape())
      layer_outs = tf.nn.dropout(
          layer_outs, rate=rate, noise_shape=noise_shape
      )
      layer_out = tf.reduce_sum(layer_outs, axis=0)
  
      return layer_out
  
file_path: nni/nni/common/nas_utils.py
imports: import functools
  import logging
  from ..None import trial
label_desc: Use image node_id 3 for calling a global function with example usage: oneshot_mode(mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf) and returns: layer_out