code: def get_non_wrapped_model(model: nn.Module) -> nn.Module:
      """
      Return real model from (maybe) wrapped in DP / DDP
  
      Args:
          model:
  
      Returns:
  
      """
      from torch.nn import DataParallel
      from torch.nn.parallel import DistributedDataParallel
  
      if not isinstance(model, nn.Module):
          raise RuntimeError(
              "Input model must be a subclass of nn.Module."
          )
  
      if isinstance(model, (DataParallel, DistributedDataParallel)):
          model = model.module
  
      return model
  
imports: import collections
  import dataclasses
  import functools
  import warnings
  import logging
  from typing import Optional, Sequence, Union, Dict, List, Any, Iterable, Callable
  import numpy
  import torch
  from torch import nn, Tensor
  from torch.utils.data import Dataset, ConcatDataset
  from torch.utils.data.dataloader import default_collate
  from .support import pytorch_toolbelt_deprecated
label_desc: Use image node_id 27 for calling a global function with example usage: get_non_wrapped_model(model) and returns: model