code: def flatten(items, seqtypes=(list, tuple)):
      # https://stackoverflow.com/a/10824086
      for i, x in enumerate(items):
          while i < len(items) and isinstance(items[i], seqtypes):
              items[i : i + 1] = items[i]
      return items
  
imports: import functools
  import numpy
  import tensorflow
  from finetune.base import BaseModel
  from finetune.encoding.target_encoders import Seq2SeqLabelEncoder
  from finetune.input_pipeline import BasePipeline
  from finetune.model import PredictMode
  from finetune.util.beam_search import beam_search, get_state_shape_invariants
  from tensorflow.python.util import nest
  import itertools
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: flatten(items, seqtypes) and returns: items