code: def flatten(structure, expand_composites=False):
      if expand_composites and _is_composite_array(structure):
          return _flatten_composite_array(
              structure, expand_composites=expand_composites
          )
      elif isinstance(structure, (tuple, list)):
          return [x for child in structure for x in flatten(child)]
      elif isinstance(structure, dict):
          return [
              x
              for key in sorted(structure)
              for x in flatten(structure[key])
          ]
      return [structure]
  
imports: import ivy.functional.frontends.tensorflow.ragged
  from ivy.functional.frontends.tensorflow.func_wrapper import to_ivy_arrays_and_back
  import ivy
label_desc: Use image node_id 3 for calling a global function with example usage: flatten(structure, expand_composites) and returns: list, _flatten_composite_array, unknown, unknown