code: def TransformedLoader(
      loader,
      func,
      transforms,
      workers=None,
      batch_size=None,
      do_tqdm=False,
      augment=False,
      fraction=1.0,
      shuffle=True,
  ):
      """
      This is a function that allows one to apply any given (fixed)
      transformation to the output from the loader *once*.
  
      For instance, you could use for applications such as assigning
      random labels to all the images (before training).
  
      The TransformedLoader also supports the application of addiotional
      transformations (such as standard data augmentation) after the fixed
      function.
  
      For more information see :ref:`our detailed walkthrough <using-custom-loaders>`
  
      Args:
          loader (PyTorch dataloader) : loader for dataset
          func (function) : fixed transformation to be applied once. It takes
          in (images, labels) and returns (images, labels) with the same shape
          in every dimension except for the first, i.e., batch dimension
          (which can be any length).
          transforms (torchvision.transforms) : transforms to apply
              to the training images from the dataset (after func) (*required*).
          workers (int) : number of workers for data fetching (*required*).
          batch_size (int) : batch size for the data loaders (*required*).
          do_tqdm (bool) : if True, show a tqdm progress bar for the attack.
          augment (bool) : if True,  the output loader contains both the original
              (untransformed), and new transformed image-label pairs.
          fraction (float): fraction of image-label pairs in the output loader
              which are transformed. The remainder is just original image-label
              pairs from loader.
          shuffle (bool) : whether or not the resulting loader should shuffle every
              epoch (defaults to True)
  
      Returns:
          A loader and validation loader according to the
          parameters given. These are standard PyTorch data loaders, and
          thus can just be used via:
  
          >>> output_loader = ds.make_loaders(loader,
                                              assign_random_labels,
                                              workers=8,
                                              batch_size=128)
          >>> for im, lab in output_loader:
          >>>     # Do stuff...
      """
  
      new_ims = []
      new_targs = []
      total_len = len(loader)
      enum_loader = enumerate(loader)
  
      it = (
          enum_loader
          if not do_tqdm
          else tqdm(enum_loader, total=total_len)
      )
      for i, (im, targ) in it:
          new_im, new_targ = func(im, targ)
          if augment or (i / float(total_len) > fraction):
              new_ims.append(im.cpu())
              new_targs.append(targ.cpu())
          if i / float(total_len) <= fraction:
              new_ims.append(new_im.cpu())
              new_targs.append(new_targ.cpu())
  
      dataset = folder.TensorDataset(
          ch.cat(new_ims, 0), ch.cat(new_targs, 0), transform=transforms
      )
      return ch.utils.data.DataLoader(
          dataset,
          num_workers=workers,
          batch_size=batch_size,
          shuffle=shuffle,
      )
  
imports: import argparse
  from .None import cifar_models
  from .tools import folder
  import os
  import shutil
  import time
  import numpy
  import torch
  import torch.utils.data
  from torch.utils.data import DataLoader
  from torch.utils.data import Subset
  import torchvision.transforms
  from torch.utils.data import DataLoader
  from .None import imagenet_models
label_desc: Use image node_id 2 for calling a global function with example usage: TransformedLoader(loader, func, transforms, workers, batch_size, do_tqdm, augment, fraction, shuffle) and returns: ch