docstr: Given an input batch it computes the binary probability.
docstr_tok: ["Given","an","input","batch","it","computes","the","binary","probability","."]
code: def compute_forward(self, batch, stage):
      "Given an input batch it computes the binary probability."
      batch = batch.to(self.device)
      lens = batch.duration
  
      if stage == sb.Stage.TRAIN:
          self.ids_list.append(batch.id)
          if self.hparams.sorting == "ascending":
              # ignore last; non-evenly divisible data; 99 items -> last batch: 19 -> 20 items (thus, nearby sort)
              if not all(
                  [x == y for x, y in zip(lens[:-1], sorted(lens[:-1]))]
              ):  # ":-1" is specific to dummy data
                  print(lens)
                  assert False
          elif self.hparams.sorting == "descending":
              if not all(
                  [
                      x == y
                      for x, y in zip(
                          lens[:-1], sorted(lens[:-1], reverse=True)
                      )
                  ]
              ):
                  print(lens)
                  assert False
          elif self.hparams.sorting == "random":
              assert not all(
                  [x == y for x, y in zip(lens[:-1], sorted(lens[:-1]))]
              )
          else:
              raise NotImplementedError(
                  "sorting must be random, ascending or descending"
              )
  
      return lens
  
file_path: speechbrain/tests/integration/sampling/example_sorting.py
imports: import os
  import torch
  import pickle
  import pathlib
  import itertools
  import speechbrain
  import torch.multiprocessing
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 1 for calling the SamplingBrain obj's underlying member method code with example usage: obj.compute_forward(batch, stage) and returns: lens