code: def pack(header, s):
      
      header = IRHeader(*header)
      if isinstance(header.label, numbers.Number):
          header = header._replace(flag=0)
      else:
          label = np.asarray(header.label, dtype=np.float32)
          header = header._replace(flag=label.size, label=0)
          s = label.tostring() + s
      s = struct.pack(_IR_FORMAT, *header) + s
      return s
docs: Pack a string into MXImageRecord.
  
      Parameters
      ----------
      header : IRHeader
          Header of the image record.
          ``header.label`` can be a number or an array. See more detail in ``IRHeader``.
      s : str
          Raw image string to be packed.
  
      Returns
      -------
      s : str
          The packed string.
  
      Examples
      --------
      >>> label = 4 # label can also be a 1-D array, for example: label = [1,2,3]
      >>> id = 2574
      >>> header = mx.recordio.IRHeader(0, label, id, 0)
      >>> with open(path, 'r') as file:
      ...     s = file.read()
      >>> packed_s = mx.recordio.pack(header, s)