docstr: Build noise data by using "number of images" and other "constraints" provided by the end user.
docstr_tok: ["Build","noise","data","by","using","``","number","of","images","''","and","other","``","constraints","''","provided","by","the","end","user","."]
code: def preprocess(self, requests):
      """
      Build noise data by using "number of images" and other "constraints" provided by the end user.
      """
      preprocessed_data = []
      for req in requests:
          data = (
              req.get("data")
              if req.get("data") is not None
              else req.get("body", {})
          )
  
          number_of_images = data.get(
              "number_of_images", self.default_number_of_images
          )
          labels = {
              ky: "b'{}'".format(vl)
              for ky, vl in data.items()
              if ky not in ["number_of_images"]
          }
  
          noise = self.dcgan_model.buildNoiseDataWithConstraints(
              number_of_images, labels
          )
          preprocessed_data.append(
              {"number_of_images": number_of_images, "input": noise}
          )
      return preprocessed_data
  
file_path: serve/examples/dcgan_fashiongen/dcgan_fashiongen_handler.py
imports: import os
  import zipfile
  import torch
  from io import BytesIO
  from torchvision.utils import save_image
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 3 for calling the ModelHandler obj's underlying member method code with example usage: obj.preprocess(requests) and returns: preprocessed_data