class_docstr: A very general abstract class representing a metric which can be
  accumulated.
docstr: If you actually passed gradient-tracking Tensors to a Metric, there will be
  a huge memory leak, because it will prevent garbage collection for the computation
  graph. This method ensures the tensors are detached.
code: def detach_tensors(*tensors: torch.Tensor) -> Iterable[torch.Tensor]:
      """
      If you actually passed gradient-tracking Tensors to a Metric, there will be
      a huge memory leak, because it will prevent garbage collection for the computation
      graph. This method ensures the tensors are detached.
      """
      # Check if it's actually a tensor in case something else was passed.
      return (
          x.detach() if isinstance(x, torch.Tensor) else x
          for x in tensors
      )
  
file_path: allennlp/allennlp/training/metrics/metric.py
imports: from typing import Iterable, Optional
  import torch
  from allennlp.common.registrable import Registrable
label_desc: Use image node_id 4 for calling the Metric obj's underlying member method code with example usage: obj.detach_tensors() and returns: unknown