class_docstr: Coloring a chunk graph according to an algorithm
  described in https://github.com/mars-project/mars/issues/2435
class_docstr_tok: ["Coloring","a","chunk","graph","according","to","an","algorithm","described","in","https",":","\/\/github.com\/mars-project\/mars\/issues\/2435"]
code: def __init__(
      self,
      chunk_graph: ChunkGraph,
      all_bands: List[BandType],
      chunk_to_bands: Dict[ChunkType, BandType],
      initial_same_color_num: int = None,
      as_broadcaster_successor_num: int = None,
  ):
      self.chunk_graph = chunk_graph
      self.all_bands = all_bands
      self.chunk_to_bands = chunk_to_bands
      if initial_same_color_num is None:
          has_gpu = any(c.op.gpu for c in chunk_graph)
          if not has_gpu:
              initial_same_color_num = max(options.combine_size // 2, 1)
          else:
              # if gpu exists, we try to fuse more node to reduce cost
              initial_same_color_num = max(options.combine_size * 2, 1)
      self.initial_same_color_num = initial_same_color_num
      if as_broadcaster_successor_num is None:
          as_broadcaster_successor_num = options.combine_size * 2
      self.successor_same_color_num = as_broadcaster_successor_num
  
      self._coloring_iter = itertools.count()
  
file_path: mars/mars/services/task/analyzer/fusion.py
imports: import itertools
  from collections import defaultdict
  from typing import Dict, List
  from ....config import options
  from ....core import ChunkGraph
  from ....core.operand import VirtualOperand
  from ....typing import BandType, ChunkType, OperandType
label_desc: Use image node_id 1 to create a new Coloring object  with example: obj = Coloring(chunk_graph, all_bands, chunk_to_bands, initial_same_color_num, as_broadcaster_successor_num)