code: def _get_train_sampler(self) -> Optional[torch.utils.data.Sampler]:
      if isinstance(
          self.train_dataset, torch.utils.data.IterableDataset
      ):
          return None
      elif is_torch_tpu_available():
          return get_tpu_sampler(self.train_dataset)
      else:
          if self.args.sortish_sampler:
              self.train_dataset.make_sortish_sampler(
                  self.args.per_device_train_batch_size,
                  distributed=(
                      self.args.parallel_mode
                      == ParallelMode.DISTRIBUTED
                  ),
              )
  
          return (
              RandomSampler(self.train_dataset)
              if self.args.local_rank == -1
              else DistributedSampler(self.train_dataset)
          )
  
file_path: transformers/examples/legacy/seq2seq/seq2seq_trainer.py
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.utils.data import DistributedSampler, RandomSampler
  from transformers import PreTrainedModel, Trainer, logging
  from transformers.models.fsmt.configuration_fsmt import FSMTConfig
  from transformers.optimization import Adafactor, AdamW, get_constant_schedule, get_constant_schedule_with_warmup, get_cosine_schedule_with_warmup, get_cosine_with_hard_restarts_schedule_with_warmup, get_linear_schedule_with_warmup, get_polynomial_decay_schedule_with_warmup
  from transformers.trainer_pt_utils import get_tpu_sampler
  from transformers.training_args import ParallelMode
  from transformers.utils import is_torch_tpu_available
label_desc: Use image node_id 4 for calling the Seq2SeqTrainer obj's underlying member method code with example usage: obj._get_train_sampler() and returns: None, get_tpu_sampler, unknown