code: def torch_apply(obj, func):
      """
      Apply a function to all tensors inside a Python object composed of the supported types.
  
      Supported types are: list, tuple and dict.
  
      Args:
          obj: The Python object to convert.
          func: The function to apply.
  
      Returns:
          A new Python object with the same structure as `obj` but where the tensors have been applied
          the function `func`. Not supported type are left as reference in the new object.
      """
  
      def fn(t):
          return func(t) if torch.is_tensor(t) else t
  
      return _apply(obj, fn)
  
imports: import contextlib
  import numbers
  import os
  import random
  import warnings
  from typing import IO, Any, BinaryIO, Optional, Union
  import numpy
  import torch
  from torch.nn.utils.rnn import PackedSequence
  from torch.utils.data import Dataset
  from poutyne.warning_manager import warning_settings
label_desc: Use image node_id 3 for calling a global function with example usage: torch_apply(obj, func) and returns: _apply, unknown