class_docstr: Classification Dense layers.
  
  Use sigmoid and binary crossentropy for binary classification and
  multi-label classification. Use softmax and categorical crossentropy for
  multi-class (more than 2) classification. Use Accuracy as metrics by
  default.
  
  The targets passing to the head would have to be tf.data.Dataset,
  np.ndarray, pd.DataFrame or pd.Series. It can be raw labels, one-hot encoded
  if more than two classes, or binary encoded for binary classification.
  
  The raw labels will be encoded to one column if two classes were found,
  or one-hot encoded if more than two classes were found.
  
  # Arguments
      num_classes: Int. Defaults to None. If None, it will be inferred from
          the data.
      multi_label: Boolean. Defaults to False.
      loss: A Keras loss function. Defaults to use `binary_crossentropy` or
          `categorical_crossentropy` based on the number of classes.
      metrics: A list of Keras metrics. Defaults to use 'accuracy'.
      dropout: Float. The dropout rate for the layers.
          If left unspecified, it will be tuned automatically.
class_docstr_tok: ["Classification","Dense","layers",".","Use","sigmoid","and","binary","crossentropy","for","binary","classification","and","multi-label","classification",".","Use","softmax","and","categorical","crossentropy","for","multi-class","(","more","than","2",")","classification",".","Use","Accuracy","as","metrics","by","default",".","The","targets","passing","to","the","head","would","have","to","be","tf.data.Dataset",",","np.ndarray",",","pd.DataFrame","or","pd.Series",".","It","can","be","raw","labels",",","one-hot","encoded","if","more","than","two","classes",",","or","binary","encoded","for","binary","classification",".","The","raw","labels","will","be","encoded","to","one","column","if","two","classes","were","found",",","or","one-hot","encoded","if","more","than","two","classes","were","found",".","#","Arguments","num_classes",":","Int",".","Defaults","to","None",".","If","None",",","it","will","be","inferred","from","the","data",".","multi_label",":","Boolean",".","Defaults","to","False",".","loss",":","A","Keras","loss","function",".","Defaults","to","use","`","binary_crossentropy","`","or","`","categorical_crossentropy","`","based","on","the","number","of","classes",".","metrics",":","A","list","of","Keras","metrics",".","Defaults","to","use","'accuracy","'",".","dropout",":","Float",".","The","dropout","rate","for","the","layers",".","If","left","unspecified",",","it","will","be","tuned","automatically","."]
code: def infer_loss(self):
      if not self.num_classes:
          return None
      if self.num_classes == 2 or self.multi_label:
          return losses.BinaryCrossentropy()
      return losses.CategoricalCrossentropy()
  
imports: from typing import Optional
  import tensorflow
  from tensorflow import keras
  from tensorflow import nest
  from tensorflow.keras import activations
  from tensorflow.keras import layers
  from tensorflow.keras import losses
  from autokeras import adapters
  from autokeras import analysers
  from autokeras import hyper_preprocessors
  from autokeras import preprocessors
  from autokeras.blocks import reduction
  from autokeras.engine import head
  from autokeras.utils import types
  from autokeras.utils import utils
label_desc: Use image node_id 2 for calling the ClassificationHead obj's underlying member method code with example usage: obj.infer_loss() and returns: losses, None, losses