class_docstr: A class to generate Multi-Layer Perceptron.
      
class_docstr_tok: ["A","class","to","generate","Multi-Layer","Perceptron","."]
docstr: Generates a Multi-Layer Perceptron.
  Args:
      model_len: An integer. Number of hidden layers.
      model_width: An integer or a list of integers of length `model_len`. If it is a list, it represents the
          number of nodes in each hidden layer. If it is an integer, all hidden layers have nodes equal to this
          value.
  Returns:
      An instance of the class Graph. Represents the neural architecture graph of the generated model.
docstr_tok: ["Generates","a","Multi-Layer","Perceptron",".","Args",":","model_len",":","An","integer",".","Number","of","hidden","layers",".","model_width",":","An","integer","or","a","list","of","integers","of","length","`","model_len","`",".","If","it","is","a","list",",","it","represents","the","number","of","nodes","in","each","hidden","layer",".","If","it","is","an","integer",",","all","hidden","layers","have","nodes","equal","to","this","value",".","Returns",":","An","instance","of","the","class","Graph",".","Represents","the","neural","architecture","graph","of","the","generated","model","."]
code: def generate(self, model_len=None, model_width=None):
      """Generates a Multi-Layer Perceptron.
      Args:
          model_len: An integer. Number of hidden layers.
          model_width: An integer or a list of integers of length `model_len`. If it is a list, it represents the
              number of nodes in each hidden layer. If it is an integer, all hidden layers have nodes equal to this
              value.
      Returns:
          An instance of the class Graph. Represents the neural architecture graph of the generated model.
      """
      if model_len is None:
          model_len = Constant.MODEL_LEN
      if model_width is None:
          model_width = Constant.MODEL_WIDTH
      if (
          isinstance(model_width, list)
          and not len(model_width) == model_len
      ):
          raise ValueError(
              "The length of 'model_width' does not match 'model_len'"
          )
      elif isinstance(model_width, int):
          model_width = [model_width] * model_len
  
      graph = Graph(self.input_shape, False)
      output_node_id = 0
      n_nodes_prev_layer = self.input_shape[0]
      for width in model_width:
          output_node_id = graph.add_layer(
              StubDense(n_nodes_prev_layer, width), output_node_id
          )
          output_node_id = graph.add_layer(
              StubDropout1d(Constant.MLP_DROPOUT_RATE), output_node_id
          )
          output_node_id = graph.add_layer(StubReLU(), output_node_id)
          n_nodes_prev_layer = width
  
      graph.add_layer(
          StubDense(n_nodes_prev_layer, self.n_output_node),
          output_node_id,
      )
      return graph
  
file_path: nni/nni/algorithms/hpo/networkmorphism_tuner/nn.py
imports: from abc import abstractmethod
  from .graph import Graph
  from .layers import StubDense, StubDropout1d, StubReLU, get_batch_norm_class, get_conv_class, get_dropout_class, get_global_avg_pooling_class, get_pooling_class
  from .utils import Constant
label_desc: Use image node_id 2 for calling the MlpGenerator obj's underlying member method code with example usage: obj.generate(model_len, model_width) and returns: graph