class_docstr: Matchzoo :class:`DataPack` data structure, store dataframe and context.
  
  `DataPack` is a MatchZoo native data structure that most MatchZoo data
  handling processes build upon. A `DataPack` consists of three parts:
  `left`, `right` and `relation`, each one of is a `pandas.DataFrame`.
  
  :param relation: Store the relation between left document
      and right document use ids.
  :param left: Store the content or features for id_left.
  :param right: Store the content or features for
      id_right.
  
  Example:
      >>> left = [
      ...     ['qid1', 'query 1'],
      ...     ['qid2', 'query 2']
      ... ]
      >>> right = [
      ...     ['did1', 'document 1'],
      ...     ['did2', 'document 2']
      ... ]
      >>> relation = [['qid1', 'did1', 1], ['qid2', 'did2', 1]]
      >>> relation_df = pd.DataFrame(relation)
      >>> left = pd.DataFrame(left)
      >>> right = pd.DataFrame(right)
      >>> dp = DataPack(
      ...     relation=relation_df,
      ...     left=left,
      ...     right=right,
      ... )
      >>> len(dp)
      2
class_docstr_tok: ["Matchzoo",":","class",":","`","DataPack","`","data","structure",",","store","dataframe","and","context",".","`","DataPack","`","is","a","MatchZoo","native","data","structure","that","most","MatchZoo","data","handling","processes","build","upon",".","A","`","DataPack","`","consists","of","three","parts",":","`","left","`",",","`","right","`","and","`","relation","`",",","each","one","of","is","a","`","pandas.DataFrame","`",".",":","param","relation",":","Store","the","relation","between","left","document","and","right","document","use","ids",".",":","param","left",":","Store","the","content","or","features","for","id_left",".",":","param","right",":","Store","the","content","or","features","for","id_right",".","Example",":",">",">",">","left","=","[","...","[","'qid1","'",",","'query","1","'","]",",","...","[","'qid2","'",",","'query","2","'","]","...","]",">",">",">","right","=","[","...","[","'did1","'",",","'document","1","'","]",",","...","[","'did2","'",",","'document","2","'","]","...","]",">",">",">","relation","=","[","[","'qid1","'",",","'did1","'",",","1","]",",","[","'qid2","'",",","'did2","'",",","1","]","]",">",">",">","relation_df","=","pd.DataFrame","(","relation",")",">",">",">","left","=","pd.DataFrame","(","left",")",">",">",">","right","=","pd.DataFrame","(","right",")",">",">",">","dp","=","DataPack","(","...","relation=relation_df",",","...","left=left",",","...","right=right",",","...",")",">",">",">","len","(","dp",")","2"]
docstr: Unpack the data for training.
  
  The return value can be directly feed to `model.fit` or
  `model.fit_generator`.
  
  :return: A tuple of (X, y). `y` is `None` if `self` has no label.
  
  Example:
      >>> import matchzoo as mz
      >>> data_pack = mz.datasets.toy.load_data()
      >>> X, y = data_pack.unpack()
      >>> type(X)
      <class 'dict'>
      >>> sorted(X.keys())
      ['id_left', 'id_right', 'text_left', 'text_right']
      >>> type(y)
      <class 'numpy.ndarray'>
      >>> X, y = data_pack.drop_label().unpack()
      >>> type(y)
      <class 'NoneType'>
docstr_tok: ["Unpack","the","data","for","training",".","The","return","value","can","be","directly","feed","to","`","model.fit","`","or","`","model.fit_generator","`",".",":","return",":","A","tuple","of","(","X",",","y",")",".","`","y","`","is","`","None","`","if","`","self","`","has","no","label",".","Example",":",">",">",">","import","matchzoo","as","mz",">",">",">","data_pack","=","mz.datasets.toy.load_data","(",")",">",">",">","X",",","y","=","data_pack.unpack","(",")",">",">",">","type","(","X",")","<","class","'dict","'",">",">",">",">","sorted","(","X.keys","(",")",")","[","'id_left","'",",","'id_right","'",",","'text_left","'",",","'text_right","'","]",">",">",">","type","(","y",")","<","class","'numpy.ndarray","'",">",">",">",">","X",",","y","=","data_pack.drop_label","(",")",".unpack","(",")",">",">",">","type","(","y",")","<","class","'NoneType","'",">"]
code: def unpack(
      self,
  ) -> typing.Tuple[
      typing.Dict[str, np.array], typing.Optional[np.array]
  ]:
      """
      Unpack the data for training.
  
      The return value can be directly feed to `model.fit` or
      `model.fit_generator`.
  
      :return: A tuple of (X, y). `y` is `None` if `self` has no label.
  
      Example:
          >>> import matchzoo as mz
          >>> data_pack = mz.datasets.toy.load_data()
          >>> X, y = data_pack.unpack()
          >>> type(X)
          <class 'dict'>
          >>> sorted(X.keys())
          ['id_left', 'id_right', 'text_left', 'text_right']
          >>> type(y)
          <class 'numpy.ndarray'>
          >>> X, y = data_pack.drop_label().unpack()
          >>> type(y)
          <class 'NoneType'>
  
      """
      frame = self.frame()
  
      columns = list(frame.columns)
      if self.has_label:
          columns.remove("label")
          y = np.vstack(np.asarray(frame["label"]))
      else:
          y = None
  
      x = frame[columns].to_dict(orient="list")
      for key, val in x.items():
          x[key] = np.array(val)
  
      return x, y
  
imports: import typing
  import inspect
  from pathlib import Path
  import functools
  import dill
  from tqdm import tqdm
  import numpy
  import pandas
  import matchzoo
label_desc: Use image node_id 5 for calling the DataPack obj's underlying member method code with example usage: obj.unpack() and returns: x,  y