code: def _find_tensors(
      obj: Union[Tensor, list, tuple, dict, Any]
  ) -> Union[List[Tensor], itertools.chain]:  # pragma: no-cover
      """Recursively find all tensors contained in the specified object."""
      if isinstance(obj, Tensor):
          return [obj]
      if isinstance(obj, (list, tuple)):
          return itertools.chain(*map(_find_tensors, obj))
      if isinstance(obj, dict):
          return itertools.chain(*map(_find_tensors, obj.values()))
      return []
  
imports: import itertools
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sized, Union, cast
  import torch
  from torch import Tensor
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.utils.data import DistributedSampler, Sampler
  from typing_extensions import Self
  from lightning.fabric.utilities.distributed import _DatasetSamplerWrapper
  from lightning.pytorch.utilities.rank_zero import rank_zero_debug, rank_zero_info
  from lightning.pytorch.utilities.types import _SizedIterable
label_desc: Use image node_id 1 for calling a global function with example usage: _find_tensors(obj) and returns: list, list, itertools, itertools