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: Create a OrderedDict for the mini-batch
  
  :param OrderedDict x_feats_dict:
      e.g. {"input1": [ndarray, ndarray, ...],
            "input2": [ndarray, ndarray, ...]}
  :param OrderedDict y_feats_dict:
      e.g. {"target1": [ndarray, ndarray, ...],
            "target2": [ndarray, ndarray, ...]}
  :param: List[str] uttid_list:
  :param int eos:
  :return: batch, uttid_list
  :rtype: Tuple[OrderedDict, List[str]]
docstr_tok: ["Create","a","OrderedDict","for","the","mini-batch",":","param","OrderedDict","x_feats_dict",":","e.g",".","{","``","input1","''",":","[","ndarray",",","ndarray",",","...","]",",","``","input2","''",":","[","ndarray",",","ndarray",",","...","]","}",":","param","OrderedDict","y_feats_dict",":","e.g",".","{","``","target1","''",":","[","ndarray",",","ndarray",",","...","]",",","``","target2","''",":","[","ndarray",",","ndarray",",","...","]","}",":","param",":","List","[","str","]","uttid_list",":",":","param","int","eos",":",":","return",":","batch",",","uttid_list",":","rtype",":","Tuple","[","OrderedDict",",","List","[","str","]","]"]
code: def _create_batch_tts(
      self, x_feats_dict, y_feats_dict, uttid_list, eos
  ):
      """Create a OrderedDict for the mini-batch
  
      :param OrderedDict x_feats_dict:
          e.g. {"input1": [ndarray, ndarray, ...],
                "input2": [ndarray, ndarray, ...]}
      :param OrderedDict y_feats_dict:
          e.g. {"target1": [ndarray, ndarray, ...],
                "target2": [ndarray, ndarray, ...]}
      :param: List[str] uttid_list:
      :param int eos:
      :return: batch, uttid_list
      :rtype: Tuple[OrderedDict, List[str]]
      """
      # Use the output values as the input feats for tts mode
      xs = list(y_feats_dict.values())[0]
      # get index of non-zero length samples
      nonzero_idx = list(
          filter(lambda i: len(xs[i]) > 0, range(len(xs)))
      )
      # sort in input lengths
      if self.sort_in_input_length:
          # sort in input lengths
          nonzero_sorted_idx = sorted(
              nonzero_idx, key=lambda i: -len(xs[i])
          )
      else:
          nonzero_sorted_idx = nonzero_idx
      # remove zero-length samples
      xs = [xs[i] for i in nonzero_sorted_idx]
      uttid_list = [uttid_list[i] for i in nonzero_sorted_idx]
      # Added eos into input sequence
      xs = [np.append(x, eos) for x in xs]
  
      if self.load_input:
          ys = list(x_feats_dict.values())[0]
          assert len(xs) == len(ys), (len(xs), len(ys))
          ys = [ys[i] for i in nonzero_sorted_idx]
  
          spembs = None
          spcs = None
          spembs_name = "spembs_none"
          spcs_name = "spcs_none"
  
          if self.use_second_target:
              spcs = list(x_feats_dict.values())[1]
              spcs = [spcs[i] for i in nonzero_sorted_idx]
              spcs_name = list(x_feats_dict.keys())[1]
  
          if self.use_speaker_embedding:
              spembs = list(x_feats_dict.values())[1]
              spembs = [spembs[i] for i in nonzero_sorted_idx]
              spembs_name = list(x_feats_dict.keys())[1]
  
          x_name = list(y_feats_dict.keys())[0]
          y_name = list(x_feats_dict.keys())[0]
  
          return_batch = OrderedDict(
              [
                  (x_name, xs),
                  (y_name, ys),
                  (spembs_name, spembs),
                  (spcs_name, spcs),
              ]
          )
      elif self.use_speaker_embedding:
          if len(x_feats_dict) == 0:
              raise IndexError("No speaker embedding is provided")
          elif len(x_feats_dict) == 1:
              spembs_idx = 0
          else:
              spembs_idx = 1
  
          spembs = list(x_feats_dict.values())[spembs_idx]
          spembs = [spembs[i] for i in nonzero_sorted_idx]
  
          x_name = list(y_feats_dict.keys())[0]
          spembs_name = list(x_feats_dict.keys())[spembs_idx]
  
          return_batch = OrderedDict(
              [(x_name, xs), (spembs_name, spembs)]
          )
      else:
          x_name = list(y_feats_dict.keys())[0]
  
          return_batch = OrderedDict([(x_name, xs)])
      return return_batch, uttid_list
  
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 5 for calling the LoadInputsAndTargets obj's underlying member method code with example usage: obj._create_batch_tts(x_feats_dict, y_feats_dict, uttid_list, eos) and returns: return_batch,  uttid_list