code: def detach_tensor(tensor: Any) -> Any:
      """Detaches any element passed which has a `.detach` function defined.
      Currently, in MMF can be SampleList, Report or a tensor.
  
      Args:
          tensor (Any): Item to be detached
  
      Returns:
          Any: Detached element
      """
      if hasattr(tensor, "detach"):
          tensor = tensor.detach()
      return tensor
  
imports: import collections
  import collections.abc
  import warnings
  from collections import OrderedDict
  from typing import Any, Dict, Union
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: detach_tensor(tensor) and returns: tensor