code: def parse_small_norb_format(raw_content):
      """
      The format is described in https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/.
      Here are the parts that we exploit in this function:
  
          The header is best described by a C structure:
  
          struct header {
              int magic; // 4 bytes
              int ndim; // 4 bytes, little endian
              int dim[3];
          };
  
          When the matrix has more than 3 dimensions, the header will be followed by further dimension size information.
  
          The magic number encodes the element type of the matrix:
          - 0x1E3D4C51 for a single precision matrix
          - 0x1E3D4C53 for a double precision matrix
          - 0x1E3D4C54 for an integer matrix
          - 0x1E3D4C55 for a byte matrix
          - 0x1E3D4C56 for a short matrix
  
          The files [..] use the little-endian scheme to encode the 4-byte integers.
          Pay attention when you read the files on machines that use big-endian.
      """
      _DATA_TYPES = {
          0x1E3D4C51: "<f4",
          0x1E3D4C53: "<f8",
          0x1E3D4C54: "<i4",
          0x1E3D4C55: "<u1",
          0x1E3D4C56: "<i2",
      }
  
      dtype_code = np.frombuffer(raw_content, dtype="<i4", count=1)[0]
      shape_size = np.frombuffer(
          raw_content, dtype="<i4", count=1, offset=4
      )[0]
      shape = tuple(
          np.frombuffer(
              raw_content, dtype="<i4", count=shape_size, offset=8
          )
      )
      data_offset = max(5, 2 + shape_size) * 4
      data = np.frombuffer(
          raw_content, dtype=_DATA_TYPES[dtype_code], offset=data_offset
      )
      return np.reshape(data, shape)
  
file_path: vissl/extra_scripts/datasets/create_small_norb_elevation_data_files.py
imports: import argparse
  import os
  import numpy
  from PIL import Image
  from tqdm import tqdm
  from vissl.utils.download import download_and_extract_archive
label_desc: Use image node_id 3 for calling a global function with example usage: parse_small_norb_format(raw_content) and returns: np