code: def _flatten(x):
      """Flattens the tree of tensors to flattened sequence of tensors"""
      if isinstance(x, torch.Tensor):
          return [x]
      if isinstance(x, Sequence):
          res = []
          for xi in x:
              res += _flatten(xi)
          return res
      return []
  
imports: import time
  from collections import OrderedDict
  from typing import Dict, Sequence
  import functools
  import itertools
  import numpy
  import torch
  import torch.nn
  from .compute_madd import compute_madd
  from .compute_flops import compute_flops
  from .compute_memory import compute_memory
  from .stat_tree import StatTree, StatNode
  from .reporter import report_format
label_desc: Use image node_id 5 for calling a global function with example usage: _flatten(x) and returns: list, list, res