code: def _get_default_criterion(
      self, class_weights, use_sample_weights=False
  ):
      reduction = "none" if use_sample_weights else "mean"
      if self.multi_label or self.num_classes == 2:
          loss = BCEWithLogitsLoss(
              pos_weight=class_weights, reduction=reduction
          )
          if use_sample_weights:
              loss = _LossAdapter2DTo1D(loss)
          return loss
      else:
          return CrossEntropyLoss(
              weight=class_weights, reduction=reduction
          )
  
imports: import logging
  import warnings
  from abc import abstractmethod
  from functools import partial
  from pathlib import Path
  from small_text.classifiers.classification import Classifier
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.training.early_stopping import EarlyStopping, NoopEarlyStopping, EarlyStoppingOrCondition
  from small_text.training.metrics import Metric
  from small_text.training.model_selection import ModelSelection, NoopModelSelection
  from small_text.utils.classification import empty_result, prediction_result
label_desc: Use image node_id 7 for calling the PytorchClassifier obj's underlying member method code with example usage: obj._get_default_criterion(class_weights, use_sample_weights) and returns: loss, CrossEntropyLoss