code: def closure_for_targets(cls, target_roots, exclude_scopes=None, include_scopes=None,
                            bfs=None, postorder=None, respect_intransitive=False):
      
      target_roots = list(target_roots) # Sometimes generators are passed into this function.
      if not target_roots:
        return OrderedSet()
  
      build_graph = target_roots[0]._build_graph
      addresses = [target.address for target in target_roots]
      dep_predicate = cls._closure_dep_predicate(target_roots,
                                                 include_scopes=include_scopes,
                                                 exclude_scopes=exclude_scopes,
                                                 respect_intransitive=respect_intransitive)
      closure = OrderedSet()
  
      if not bfs:
        build_graph.walk_transitive_dependency_graph(
          addresses=addresses,
          work=closure.add,
          postorder=postorder,
          dep_predicate=dep_predicate,
        )
      else:
        closure.update(build_graph.transitive_subgraph_of_addresses_bfs(
          addresses=addresses,
          dep_predicate=dep_predicate,
        ))
  
      # Make sure all the roots made it into the closure.
      closure.update(target_roots)
      return closure
docs: Computes the closure of the given targets respecting the given input scopes.
  
      :API: public
  
      :param list target_roots: The list of Targets to start from. These targets will always be
        included in the closure, regardless of scope settings.
      :param Scope exclude_scopes: If present and non-empty, only dependencies which have none of the
        scope names in this Scope will be traversed.
      :param Scope include_scopes: If present and non-empty, only dependencies which have at least one
        of the scope names in this Scope will be traversed.
      :param bool bfs: Whether to traverse in breadth-first or depth-first order. (Defaults to True).
      :param bool respect_intransitive: If True, any dependencies which have the 'intransitive' scope
        will not be included unless they are direct dependencies of one of the root targets. (Defaults
        to False).