def unpack(batch):
        """Convert back the output of a :class:`~ffcv.fields.JSONField` field produced by :class:`~ffcv.Loader` into an actual JSON.
        
        It works both on an entire batch and will return an array of python dicts or a single sample and will simply return a dict.
        """
        if isinstance(batch, ch.Tensor):
            batch = batch.numpy()

        single_instance = len(batch.shape) == 1
        if single_instance:
            batch = [batch]

        result = []
        for b in batch:
            sep_location = np.where(b == ord(SEPARATOR))[0][0]
            b = b[:sep_location]
            string = b.tobytes().decode(ENCODING)
            result.append(json.loads(string))

        if single_instance:
            result = result[0]

        return result
Convert back the output of a :class:`~ffcv.fields.JSONField` field produced by :class:`~ffcv.Loader` into an actual JSON.
        
        It works both on an entire batch and will return an array of python dicts or a single sample and will simply return a dict.
        
ffcv/fields/json.py