class_docstr: Data Loader Class for DeepGLO
class_docstr_tok: ["Data","Loader","Class","for","DeepGLO"]
docstr: Returns:
  data is returned as pytorch tensor of shape nd*cd*td where nd is vbsize,
  hb is hsize and cd is the number os channels (depends on covariates)
  inp: input batch
  out: one shifted output batch
  vindex: strating vertical index of input batch
  hindex: starting horizontal index of input batch
docstr_tok: ["Returns",":","data","is","returned","as","pytorch","tensor","of","shape","nd","*","cd","*","td","where","nd","is","vbsize",",","hb","is","hsize","and","cd","is","the","number","os","channels","(","depends","on","covariates",")","inp",":","input","batch","out",":","one","shifted","output","batch","vindex",":","strating","vertical","index","of","input","batch","hindex",":","starting","horizontal","index","of","input","batch"]
code: def next_batch(self):
      """
      Returns:
      data is returned as pytorch tensor of shape nd*cd*td where nd is vbsize,
      hb is hsize and cd is the number os channels (depends on covariates)
      inp: input batch
      out: one shifted output batch
      vindex: strating vertical index of input batch
      hindex: starting horizontal index of input batch
      """
      n, T = self.Ymat.shape
      if self.hindex + self.hbsize + 1 >= self.end_index:
          pr_hindex = self.hindex
          self.hindex = 0
          if self.vindex + self.vbsize >= n:
              pr_vindex = self.vindex
              self.vindex = 0
              self.epoch = self.epoch + 1
              if self.shuffle:
                  I = np.random.choice(n, n, replace=False)
                  self.I = I
                  self.Ymat = self.Ymat[self.I, :]
          else:
              pr_vindex = self.vindex
              self.vindex = self.vindex + self.vbsize
      else:
          pr_hindex = self.hindex
          self.hindex = self.hindex + self.hbsize
          pr_vindex = self.vindex
  
      data = self.Ymat[
          int(pr_vindex) : int(pr_vindex + self.vbsize),
          int(pr_hindex) : int(
              min(self.end_index, pr_hindex + self.hbsize)
          ),
      ]
      out_data = self.Ymat[
          int(pr_vindex) : int(pr_vindex + self.vbsize),
          int(pr_hindex + 1) : int(
              min(self.end_index, pr_hindex + self.hbsize) + 1
          ),
      ]
      nd, Td = data.shape
      if self.covariates is not None:
          covs = self.covariates[
              :,
              int(pr_hindex) : int(
                  min(self.end_index, pr_hindex + self.hbsize)
              ),
          ]
          rcovs = np.repeat(
              covs.reshape(1, covs.shape[0], covs.shape[1]),
              repeats=nd,
              axis=0,
          )
  
      if self.Ycov is not None:
          ycovs = self.Ycov[
              int(pr_vindex) : int(pr_vindex + self.vbsize),
              :,
              int(pr_hindex) : int(
                  min(self.end_index, pr_hindex + self.hbsize)
              ),
          ]
      inp = torch.from_numpy(data).view(1, nd, Td)
      out = torch.from_numpy(out_data).view(1, nd, Td)
      if self.covariates is not None:
          rcovs = torch.from_numpy(rcovs).float()
      if self.Ycov is not None:
          ycovs = torch.from_numpy(ycovs).float()
      inp = inp.transpose(0, 1).float()
      if self.covariates is not None:
          inp = torch.cat((inp, rcovs), 1)
      if self.Ycov is not None:
          inp = torch.cat((inp, ycovs), 1)
      out = out.transpose(0, 1).float()
  
      inp[torch.isnan(inp)] = 0
      out[torch.isnan(out)] = 0
  
      return inp, out, self.vindex, self.hindex
  
imports: import numpy
  import torch
label_desc: Use image node_id 2 for calling the TCMFDataLoader obj's underlying member method code with example usage: obj.next_batch() and returns: inp,  out,  self,  self