class_docstr: Create a mini-batch from a list of dicts
  
  >>> batch = [('utt1',
  ...           dict(input=[dict(feat='some.ark:123',
  ...                            filetype='mat',
  ...                            name='input1',
  ...                            shape=[100, 80])],
  ...                output=[dict(tokenid='1 2 3 4',
  ...                             name='target1',
  ...                             shape=[4, 31])]]))
  >>> l = LoadInputsAndTargets()
  >>> feat, target = l(batch)
  
  :param: str mode: Specify the task mode, "asr" or "tts"
  :param: str preprocess_conf: The path of a json file for pre-processing
  :param: bool load_input: If False, not to load the input data
  :param: bool load_output: If False, not to load the output data
  :param: bool sort_in_input_length: Sort the mini-batch in descending order
      of the input length
  :param: bool use_speaker_embedding: Used for tts mode only
  :param: bool use_second_target: Used for tts mode only
  :param: dict preprocess_args: Set some optional arguments for preprocessing
  :param: Optional[dict] preprocess_args: Used for tts mode only
class_docstr_tok: ["Create","a","mini-batch","from","a","list","of","dicts",">",">",">","batch","=","[","(","'utt1","'",",","...","dict","(","input=","[","dict","(","feat='some.ark:123","'",",","...","filetype='mat","'",",","...","name='input1","'",",","...","shape=","[","100",",","80","]",")","]",",","...","output=","[","dict","(","tokenid=","'","1","2","3","4","'",",","...","name='target1","'",",","...","shape=","[","4",",","31","]",")","]","]",")",")",">",">",">","l","=","LoadInputsAndTargets","(",")",">",">",">","feat",",","target","=","l","(","batch",")",":","param",":","str","mode",":","Specify","the","task","mode",",","``","asr","''","or","``","tts","''",":","param",":","str","preprocess_conf",":","The","path","of","a","json","file","for","pre-processing",":","param",":","bool","load_input",":","If","False",",","not","to","load","the","input","data",":","param",":","bool","load_output",":","If","False",",","not","to","load","the","output","data",":","param",":","bool","sort_in_input_length",":","Sort","the","mini-batch","in","descending","order","of","the","input","length",":","param",":","bool","use_speaker_embedding",":","Used","for","tts","mode","only",":","param",":","bool","use_second_target",":","Used","for","tts","mode","only",":","param",":","dict","preprocess_args",":","Set","some","optional","arguments","for","preprocessing",":","param",":","Optional","[","dict","]","preprocess_args",":","Used","for","tts","mode","only"]
docstr: Return ndarray
  
  In order to make the fds to be opened only at the first referring,
  the loader are stored in self._loaders
  
  >>> ndarray = loader.get_from_loader(
  ...     'some/path.h5:F01_050C0101_PED_REAL', filetype='hdf5')
  
  :param: str filepath:
  :param: str filetype:
  :return:
  :rtype: np.ndarray
docstr_tok: ["Return","ndarray","In","order","to","make","the","fds","to","be","opened","only","at","the","first","referring",",","the","loader","are","stored","in","self._loaders",">",">",">","ndarray","=","loader.get_from_loader","(","...","'some\/path.h5",":","F01_050C0101_PED_REAL","'",",","filetype='hdf5","'",")",":","param",":","str","filepath",":",":","param",":","str","filetype",":",":","return",":",":","rtype",":","np.ndarray"]
code: def _get_from_loader(self, filepath, filetype):
      """Return ndarray
  
      In order to make the fds to be opened only at the first referring,
      the loader are stored in self._loaders
  
      >>> ndarray = loader.get_from_loader(
      ...     'some/path.h5:F01_050C0101_PED_REAL', filetype='hdf5')
  
      :param: str filepath:
      :param: str filetype:
      :return:
      :rtype: np.ndarray
      """
      if filetype == "hdf5":
          # e.g.
          #    {"input": [{"feat": "some/path.h5:F01_050C0101_PED_REAL",
          #                "filetype": "hdf5",
          # -> filepath = "some/path.h5", key = "F01_050C0101_PED_REAL"
          filepath, key = filepath.split(":", 1)
  
          loader = self._loaders.get(filepath)
          if loader is None:
              # To avoid disk access, create loader only for the first time
              loader = h5py.File(filepath, "r")
              self._loaders[filepath] = loader
          return loader[key][()]
      elif filetype == "sound.hdf5":
          # e.g.
          #    {"input": [{"feat": "some/path.h5:F01_050C0101_PED_REAL",
          #                "filetype": "sound.hdf5",
          # -> filepath = "some/path.h5", key = "F01_050C0101_PED_REAL"
          filepath, key = filepath.split(":", 1)
  
          loader = self._loaders.get(filepath)
          if loader is None:
              # To avoid disk access, create loader only for the first time
              loader = SoundHDF5File(filepath, "r", dtype="int16")
              self._loaders[filepath] = loader
          array, rate = loader[key]
          return array
      elif filetype == "sound":
          # e.g.
          #    {"input": [{"feat": "some/path.wav",
          #                "filetype": "sound"},
          # Assume PCM16
          if not self.keep_all_data_on_mem:
              array, _ = soundfile.read(filepath, dtype="int16")
              return array
          if filepath not in self._loaders:
              array, _ = soundfile.read(filepath, dtype="int16")
              self._loaders[filepath] = array
          return self._loaders[filepath]
      elif filetype == "npz":
          # e.g.
          #    {"input": [{"feat": "some/path.npz:F01_050C0101_PED_REAL",
          #                "filetype": "npz",
          filepath, key = filepath.split(":", 1)
  
          loader = self._loaders.get(filepath)
          if loader is None:
              # To avoid disk access, create loader only for the first time
              loader = np.load(filepath)
              self._loaders[filepath] = loader
          return loader[key]
      elif filetype == "npy":
          # e.g.
          #    {"input": [{"feat": "some/path.npy",
          #                "filetype": "npy"},
          if not self.keep_all_data_on_mem:
              return np.load(filepath)
          if filepath not in self._loaders:
              self._loaders[filepath] = np.load(filepath)
          return self._loaders[filepath]
      elif filetype in ["mat", "vec"]:
          # e.g.
          #    {"input": [{"feat": "some/path.ark:123",
          #                "filetype": "mat"}]},
          # In this case, "123" indicates the starting points of the matrix
          # load_mat can load both matrix and vector
          if not self.keep_all_data_on_mem:
              return kaldiio.load_mat(filepath)
          if filepath not in self._loaders:
              self._loaders[filepath] = kaldiio.load_mat(filepath)
          return self._loaders[filepath]
      elif filetype == "scp":
          # e.g.
          #    {"input": [{"feat": "some/path.scp:F01_050C0101_PED_REAL",
          #                "filetype": "scp",
          filepath, key = filepath.split(":", 1)
          loader = self._loaders.get(filepath)
          if loader is None:
              # To avoid disk access, create loader only for the first time
              loader = kaldiio.load_scp(filepath)
              self._loaders[filepath] = loader
          return loader[key]
      else:
          raise NotImplementedError(
              "Not supported: loader_type={}".format(filetype)
          )
  
imports: import io
  import logging
  import os
  from collections import OrderedDict
  import h5py
  import kaldiio
  import numpy
  import soundfile
  from espnet.transform.transformation import Transformation
label_desc: Use image node_id 7 for calling the LoadInputsAndTargets obj's underlying member method code with example usage: obj._get_from_loader(filepath, filetype) and returns: loader, array, self, array, loader, self, np, self, kaldiio, loader