code: def visualize(
      tc: "TaskComposition",
      fhandle: BytesIO = None,
      format: str = "png",
      *,
      no_optimization: bool = False,
  ):
      """Visualize a graph."""
      dsk = tc.pre_optimization_dsk if no_optimization else tc.dsk
      dependencies, dependents = get_deps(dsk)
      g = _dag_to_graphviz(
          dag=dsk,
          dependencies=dependencies,
          request_data=tc.ep_dsk_input_keys,
          response_data=tc.ep_dsk_output_keys,
          no_optimization=no_optimization,
      )
      if fhandle is not None:
          data = g.pipe(format=format)
          fhandle.seek(0)
          fhandle.write(data)
          return None
  
      return g
  
imports: from contextlib import suppress
  from io import BytesIO
  from flash.core.serve.dag.task import get_deps
  from flash.core.serve.execution import TaskComposition
label_desc: Use image node_id 2 for calling a global function with example usage: visualize(tc, fhandle, format) and returns: g, None