class_docstr: Helper class to generate a DynChunkTrainConfig at runtime depending on the current
  stage.
  
  Example
  -------
  >>> from speechbrain.core import Stage
  >>> from speechbrain.utils.dynamic_chunk_training import DynChunkTrainConfig
  >>> from speechbrain.utils.dynamic_chunk_training import DynChunkTrainConfigRandomSampler
  >>> # for the purpose of this example, we test a scenario with a 100%
  >>> # chance of the (24, None) scenario to occur
  >>> sampler = DynChunkTrainConfigRandomSampler(
  ...     chunkwise_prob=1.0,
  ...     chunk_size_min=24,
  ...     chunk_size_max=24,
  ...     limited_left_context_prob=0.0,
  ...     left_context_chunks_min=16,
  ...     left_context_chunks_max=16,
  ...     test_config=DynChunkTrainConfig(32, 16),
  ...     valid_config=None
  ... )
  >>> one_train_config = sampler(Stage.TRAIN)
  >>> one_train_config
  DynChunkTrainConfig(chunk_size=24, left_context_size=None)
  >>> one_train_config.is_infinite_left_context()
  True
  >>> sampler(Stage.TEST)
  DynChunkTrainConfig(chunk_size=32, left_context_size=16)
docstr: In training stage, samples a random DynChunkTrain configuration.
  During validation or testing, returns the relevant configuration.
  
  Arguments
  ---------
  stage : speechbrain.core.Stage
      Current stage of training or evaluation.
      In training mode, a random DynChunkTrainConfig will be sampled
      according to the specified probabilities and ranges.
      During evaluation, the relevant DynChunkTrainConfig attribute will
      be picked.
docstr_tok: ["In","training","stage",",","samples","a","random","DynChunkTrain","configuration",".","During","validation","or","testing",",","returns","the","relevant","configuration",".","Arguments","--","--","--","--","-","stage",":","speechbrain.core.Stage","Current","stage","of","training","or","evaluation",".","In","training","mode",",","a","random","DynChunkTrainConfig","will","be","sampled","according","to","the","specified","probabilities","and","ranges",".","During","evaluation",",","the","relevant","DynChunkTrainConfig","attribute","will","be","picked","."]
code: def __call__(self, stage: "sb.core.Stage") -> DynChunkTrainConfig:
      """In training stage, samples a random DynChunkTrain configuration.
      During validation or testing, returns the relevant configuration.
  
      Arguments
      ---------
      stage : speechbrain.core.Stage
          Current stage of training or evaluation.
          In training mode, a random DynChunkTrainConfig will be sampled
          according to the specified probabilities and ranges.
          During evaluation, the relevant DynChunkTrainConfig attribute will
          be picked.
      """
      if stage == sb.core.Stage.TRAIN:
          # When training for streaming, for each batch, we have a
          # `dynamic_chunk_prob` probability of sampling a chunk size
          # between `dynamic_chunk_min` and `_max`, otherwise output
          # frames can see anywhere in the future.
          if self._sample_bool(self.chunkwise_prob):
              chunk_size = torch.randint(
                  self.chunk_size_min,
                  self.chunk_size_max + 1,
                  (1,),
              ).item()
  
              if self._sample_bool(self.limited_left_context_prob):
                  left_context_chunks = torch.randint(
                      self.left_context_chunks_min,
                      self.left_context_chunks_max + 1,
                      (1,),
                  ).item()
              else:
                  left_context_chunks = None
  
              return DynChunkTrainConfig(
                  chunk_size, left_context_chunks
              )
          return None
      elif stage == sb.core.Stage.TEST:
          return self.test_config
      elif stage == sb.core.Stage.VALID:
          return self.valid_config
      else:
          raise AttributeError(f"Unsupported stage found {stage}")
  
file_path: speechbrain/speechbrain/utils/dynamic_chunk_training.py
imports: import speechbrain
  from dataclasses import dataclass
  from typing import Optional
  import torch
label_desc: Use image node_id 2 for calling the DynChunkTrainConfigRandomSampler obj's underlying member method code with example usage: obj.__call__(stage) and returns: None, DynChunkTrainConfig, self, self