code: def create_objects(
      root_yaml,
      be_type="gpu",
      batch_size=128,
      rng_seed=None,
      device_id=0,
      default_dtype=np.float32,
      stochastic_rounding=False,
  ):
      """
      Instantiate objects as per the given specifications.
  
      Arguments:
          root_yaml (dict): Model definition dictionary parse from YAML file
  
          be_type (str): backend either 'gpu', 'mgpu' or 'cpu'
  
          batch_size (int): Batch size.
          rng_seed (None or int): random number generator seed
  
          device_id (int): for GPU backends id of device to use
  
          default_dtype (type): numpy data format for default data types,
  
          stochastic_rounding (bool or int): number of bits for stochastic rounding
                                             use False for no rounding
  
      Returns:
          tuple: Contains model, cost and optimizer objects.
      """
  
      assert (
          NervanaObject.be is not None
      ), "Must generate a backend before running this function"
  
      # can give filename or parse dictionary
      if type(root_yaml) is str:
          with open(root_yaml, "r") as fid:
              root_yaml = yaml.safe_load(fid.read())
  
      # in case references were used
      root_yaml = deepcopy(root_yaml)
  
      # initialize layers
      yaml_layers = root_yaml["layers"]
  
      # currently only support sequential in yaml
      layer_dict = {"layers": yaml_layers}
      layers = Sequential.gen_class(layer_dict)
  
      # initialize model
      model = Model(layers=layers)
  
      # cost (before layers for shortcut derivs)
      cost_name = root_yaml["cost"]
      cost = GeneralizedCost.gen_class(
          {"costfunc": {"type": cost_name}}
      )
  
      # create optimizer
      opt = None
      if "optimizer" in root_yaml:
          yaml_opt = root_yaml["optimizer"]
          typ = yaml_opt["type"]
          opt = getattr(neon.optimizers, typ).gen_class(
              yaml_opt["config"]
          )
  
      return model, cost, opt
  
file_path: neon/neon/util/yaml_parse.py
imports: from copy import deepcopy
  import numpy
  import yaml
  from neon import NervanaObject
  from neon.layers import GeneralizedCost
  from neon.models import Model
  import neon.optimizers
  from neon.layers.container import Sequential
label_desc: Use image node_id 2 for calling a global function with example usage: create_objects(root_yaml, be_type, batch_size, rng_seed, device_id, default_dtype, stochastic_rounding) and returns: model,  cost,  opt