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: Function to load inputs and targets from list of dicts
  
  :param List[Tuple[str, dict]] batch: list of dict which is subset of
      loaded data.json
  :param bool return_uttid: return utterance ID information for visualization
  :return: list of input token id sequences [(L_1), (L_2), ..., (L_B)]
  :return: list of input feature sequences
      [(T_1, D), (T_2, D), ..., (T_B, D)]
  :rtype: list of float ndarray
  :return: list of target token id sequences [(L_1), (L_2), ..., (L_B)]
  :rtype: list of int ndarray
docstr_tok: ["Function","to","load","inputs","and","targets","from","list","of","dicts",":","param","List","[","Tuple","[","str",",","dict","]","]","batch",":","list","of","dict","which","is","subset","of","loaded","data.json",":","param","bool","return_uttid",":","return","utterance","ID","information","for","visualization",":","return",":","list","of","input","token","id","sequences","[","(","L_1",")",",","(","L_2",")",",","...",",","(","L_B",")","]",":","return",":","list","of","input","feature","sequences","[","(","T_1",",","D",")",",","(","T_2",",","D",")",",","...",",","(","T_B",",","D",")","]",":","rtype",":","list","of","float","ndarray",":","return",":","list","of","target","token","id","sequences","[","(","L_1",")",",","(","L_2",")",",","...",",","(","L_B",")","]",":","rtype",":","list","of","int","ndarray"]
code: def __call__(self, batch, return_uttid=False):
      """Function to load inputs and targets from list of dicts
  
      :param List[Tuple[str, dict]] batch: list of dict which is subset of
          loaded data.json
      :param bool return_uttid: return utterance ID information for visualization
      :return: list of input token id sequences [(L_1), (L_2), ..., (L_B)]
      :return: list of input feature sequences
          [(T_1, D), (T_2, D), ..., (T_B, D)]
      :rtype: list of float ndarray
      :return: list of target token id sequences [(L_1), (L_2), ..., (L_B)]
      :rtype: list of int ndarray
  
      """
      x_feats_dict = OrderedDict()  # OrderedDict[str, List[np.ndarray]]
      y_feats_dict = OrderedDict()  # OrderedDict[str, List[np.ndarray]]
      uttid_list = []  # List[str]
  
      for uttid, info in batch:
          uttid_list.append(uttid)
  
          if self.load_input:
              # Note(kamo): This for-loop is for multiple inputs
              for idx, inp in enumerate(info["input"]):
                  # {"input":
                  #  [{"feat": "some/path.h5:F01_050C0101_PED_REAL",
                  #    "filetype": "hdf5",
                  #    "name": "input1", ...}], ...}
                  x = self._get_from_loader(
                      filepath=inp["feat"],
                      filetype=inp.get("filetype", "mat"),
                  )
                  x_feats_dict.setdefault(inp["name"], []).append(x)
          # FIXME(kamo): Dirty way to load only speaker_embedding
          elif self.mode == "tts" and self.use_speaker_embedding:
              for idx, inp in enumerate(info["input"]):
                  if idx != 1 and len(info["input"]) > 1:
                      x = None
                  else:
                      x = self._get_from_loader(
                          filepath=inp["feat"],
                          filetype=inp.get("filetype", "mat"),
                      )
                  x_feats_dict.setdefault(inp["name"], []).append(x)
  
          if self.load_output:
              if self.mode == "mt":
                  x = np.fromiter(
                      map(int, info["output"][1]["tokenid"].split()),
                      dtype=np.int64,
                  )
                  x_feats_dict.setdefault(
                      info["output"][1]["name"], []
                  ).append(x)
  
              for idx, inp in enumerate(info["output"]):
                  if "tokenid" in inp:
                      # ======= Legacy format for output =======
                      # {"output": [{"tokenid": "1 2 3 4"}])
                      x = np.fromiter(
                          map(int, inp["tokenid"].split()),
                          dtype=np.int64,
                      )
                  else:
                      # ======= New format =======
                      # {"input":
                      #  [{"feat": "some/path.h5:F01_050C0101_PED_REAL",
                      #    "filetype": "hdf5",
                      #    "name": "target1", ...}], ...}
                      x = self._get_from_loader(
                          filepath=inp["feat"],
                          filetype=inp.get("filetype", "mat"),
                      )
  
                  y_feats_dict.setdefault(inp["name"], []).append(x)
  
      if self.mode == "asr":
          return_batch, uttid_list = self._create_batch_asr(
              x_feats_dict, y_feats_dict, uttid_list
          )
      elif self.mode == "tts":
          _, info = batch[0]
          eos = int(info["output"][0]["shape"][1]) - 1
          return_batch, uttid_list = self._create_batch_tts(
              x_feats_dict, y_feats_dict, uttid_list, eos
          )
      elif self.mode == "mt":
          return_batch, uttid_list = self._create_batch_mt(
              x_feats_dict, y_feats_dict, uttid_list
          )
      elif self.mode == "vc":
          return_batch, uttid_list = self._create_batch_vc(
              x_feats_dict, y_feats_dict, uttid_list
          )
      else:
          raise NotImplementedError(self.mode)
  
      if self.preprocessing is not None:
          # Apply pre-processing all input features
          for x_name in return_batch.keys():
              if x_name.startswith("input"):
                  return_batch[x_name] = self.preprocessing(
                      return_batch[x_name],
                      uttid_list,
                      **self.preprocess_args,
                  )
  
      if return_uttid:
          return tuple(return_batch.values()), uttid_list
  
      # Doesn't return the names now.
      return tuple(return_batch.values())
  
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 2 for calling the LoadInputsAndTargets obj's underlying member method code with example usage: obj.__call__(batch, return_uttid) and returns: tuple, tuple,  uttid_list