code: def enas_mode(
      mutable_id,
      mutable_layer_id,
      funcs,
      funcs_args,
      fixed_inputs,
      optional_inputs,
      optional_input_size,
      tf,
  ):
      """For enas mode, we build the full model graph in trial but only run a subgraph。
      This is implemented by masking inputs and branching ops.
      Specifically, based on the received subgraph (through nni.get_next_parameter),
      it can be known which inputs should be masked and which op should be executed.
      """
      name_prefix = "{}_{}".format(mutable_id, mutable_layer_id)
      # store namespace
      _namespace[mutable_id] = True
      _namespace[name_prefix] = dict()
      _namespace[name_prefix]["funcs"] = list(funcs)
      _namespace[name_prefix]["optional_inputs"] = list(optional_inputs)
      # create tensorflow variables as 1/0 signals used to form subgraph
      name_for_optional_inputs = name_prefix + "_optional_inputs"
      name_for_funcs = name_prefix + "_funcs"
      _tf_variables[name_prefix] = dict()
      _tf_variables[name_prefix]["optional_inputs"] = tf.get_variable(
          name_for_optional_inputs,
          [len(optional_inputs)],
          dtype=tf.bool,
          trainable=False,
      )
      _tf_variables[name_prefix]["funcs"] = tf.get_variable(
          name_for_funcs, [], dtype=tf.int64, trainable=False
      )
  
      # get real values using their variable names
      real_optional_inputs_value = [
          optional_inputs[name]
          for name in _namespace[name_prefix]["optional_inputs"]
      ]
      real_func_value = [
          funcs[name] for name in _namespace[name_prefix]["funcs"]
      ]
      real_funcs_args = [
          funcs_args[name] for name in _namespace[name_prefix]["funcs"]
      ]
      # build tensorflow graph of geting chosen inputs by masking
      real_chosen_inputs = tf.boolean_mask(
          real_optional_inputs_value,
          _tf_variables[name_prefix]["optional_inputs"],
      )
      # build tensorflow graph of different branches by using tf.case
      branches = dict()
      func_output = None
      for func_id in range(len(funcs)):
          func_output = real_func_value[func_id](
              [fixed_inputs, real_chosen_inputs],
              **real_funcs_args[func_id],
          )
          branches[
              tf.equal(_tf_variables[name_prefix]["funcs"], func_id)
          ] = lambda: func_output
      layer_out = tf.case(
          branches, exclusive=True, default=lambda: func_output
      )
  
      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 2 for calling a global function with example usage: enas_mode(mutable_id, mutable_layer_id, funcs, funcs_args, fixed_inputs, optional_inputs, optional_input_size, tf) and returns: layer_out