code: def repackage_hidden(
      hidden: Union[torch.Tensor, Tuple[torch.Tensor, ...]]
  ) -> Union[torch.Tensor, Tuple[torch.Tensor, ...]]:
      """
      Wraps hidden states in new Tensors, to detach them from their history.
  
      Args:
          hidden (Union[torch.Tensor, Tuple[torch.Tensor, ...]]): Tensor or a
              tuple of tensors to repackage.
  
      Returns:
          Union[torch.Tensor, Tuple[torch.Tensor, ...]]: Repackaged output
  
      """
      if isinstance(hidden, torch.Tensor):
          return hidden.detach()
      else:
          return tuple(repackage_hidden(v) for v in hidden)
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  from pytext.config import ConfigBase
  from pytext.config.module_config import ExporterType
  from pytext.data import CommonMetadata
  from pytext.data.tensorizers import Tensorizer, TokenTensorizer
  from pytext.exporters.custom_exporters import get_exporter
  from pytext.exporters.exporter import ModelExporter
  from pytext.models.decoders import DecoderBase
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.embeddings import EmbeddingBase
  from pytext.models.embeddings.word_embedding import WordEmbedding
  from pytext.models.model import BaseModel, Model
  from pytext.models.module import create_module
  from pytext.models.output_layers import OutputLayerBase
  from pytext.models.output_layers.lm_output_layer import LMOutputLayer
  from pytext.models.representations.bilstm import BiLSTM
  from pytext.models.representations.deepcnn import DeepCNNRepresentation
  from pytext.models.representations.representation_base import RepresentationBase
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 1 for calling a global function with example usage: repackage_hidden(hidden) and returns: hidden, tuple