code: def _add_gdp_formulation_to_block(
      block, model_definition, input_vars, output_vars, transformation
  ):
      """
      This function adds the GDP representation to the OmltBlock using Pyomo.GDP
  
      Arguments:
          block -- OmltBlock
          model_definition -- LinearTreeDefinition Object
          input_vars -- input variables to the linear tree model
          output_vars -- output variable of the linear tree model
          transformation -- Transformation to apply
  
      """
      leaves = model_definition.leaves
      input_bounds = model_definition.scaled_input_bounds
      n_inputs = model_definition.n_inputs
  
      # The set of leaves and the set of features
      tree_ids = list(leaves.keys())
      t_l = []
      for tree in tree_ids:
          for leaf in leaves[tree].keys():
              t_l.append((tree, leaf))
      features = np.arange(0, n_inputs)
  
      # Use the input_bounds and the linear models in the leaves to calculate
      # the lower and upper bounds on the output variable. Required for Pyomo.GDP
      output_bounds = _build_output_bounds(
          model_definition, input_bounds
      )
  
      # Ouptuts are automatically scaled based on whether inputs are scaled
      block.outputs.setub(output_bounds[1])
      block.outputs.setlb(output_bounds[0])
      block.scaled_outputs.setub(output_bounds[1])
      block.scaled_outputs.setlb(output_bounds[0])
  
      block.intermediate_output = pe.Var(
          tree_ids, bounds=(output_bounds[0], output_bounds[1])
      )
  
      # Create a disjunct for each leaf containing the bound constraints
      # and the linear model expression.
      def disjuncts_rule(dsj, tree, leaf):
          def lb_rule(dsj, feat):
              return (
                  input_vars[feat]
                  >= leaves[tree][leaf]["bounds"][feat][0]
              )
  
          dsj.lb_constraint = pe.Constraint(features, rule=lb_rule)
  
          def ub_rule(dsj, feat):
              return (
                  input_vars[feat]
                  <= leaves[tree][leaf]["bounds"][feat][1]
              )
  
          dsj.ub_constraint = pe.Constraint(features, rule=ub_rule)
  
          slope = leaves[tree][leaf]["slope"]
          intercept = leaves[tree][leaf]["intercept"]
          dsj.linear_exp = pe.Constraint(
              expr=sum(slope[k] * input_vars[k] for k in features)
              + intercept
              == block.intermediate_output[tree]
          )
  
      block.disjunct = Disjunct(t_l, rule=disjuncts_rule)
  
      @block.Disjunction(tree_ids)
      def disjunction_rule(b, tree):
          leaf_ids = list(leaves[tree].keys())
          return [block.disjunct[tree, leaf] for leaf in leaf_ids]
  
      block.total_output = pe.Constraint(
          expr=output_vars[0]
          == sum(block.intermediate_output[tree] for tree in tree_ids)
      )
  
      transformation_string = "gdp." + transformation
  
      if transformation != "custom":
          pe.TransformationFactory(transformation_string).apply_to(
              block
          )
  
file_path: OMLT/src/omlt/linear_tree/lt_formulation.py
imports: import numpy
  import pyomo.environ
  from pyomo.gdp import Disjunct
  from omlt.formulation import _PyomoFormulation, _setup_scaled_inputs_outputs
label_desc: Use image node_id 2 for calling a global function with example usage: _add_gdp_formulation_to_block(block, model_definition, input_vars, output_vars, transformation) and returns: unknown, unknown, unknown