code: def nested_items_iter(x: Union[dict, list]):
      x_iter = x.items() if isinstance(x, dict) else enumerate(x)
      for k, v in x_iter:
          if isinstance(v, (dict, list)):
              yield from nested_items_iter(v)
          else:
              yield x, k, v
  
file_path: megatron-lm/megatron/core/dist_checkpointing/dict_utils.py
imports: from collections import defaultdict
  from typing import Any, Callable, Iterable, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 6 for calling a global function with example usage: nested_items_iter(x) without return types