docstr: Generalizable method for fitting a PyTorch estimator to a training
  set.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Training vector, where n_samples is the number of samples and
      n_features is the number of features.
  y : array-like of shape (n_samples,)
      Target vector relative to X.
  
  Returns
  -------
  self
      Fitted estimator.
docstr_tok: ["Generalizable","method","for","fitting","a","PyTorch","estimator","to","a","training","set",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Training","vector",",","where","n_samples","is","the","number","of","samples","and","n_features","is","the","number","of","features",".","y",":","array-like","of","shape","(","n_samples",",",")","Target","vector","relative","to","X",".","Returns","--","--","--","-","self","Fitted","estimator","."]
code: def fit(self, X, y):
      """Generalizable method for fitting a PyTorch estimator to a training
      set.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Training vector, where n_samples is the number of samples and
          n_features is the number of features.
      y : array-like of shape (n_samples,)
          Target vector relative to X.
  
      Returns
      -------
      self
          Fitted estimator.
      """
      # pylint: disable=no-member
  
      self._init_model(X, y)
  
      assert _pytorch_model_is_fully_initialized(self)
  
      for epoch in range(self.num_epochs):
          for i, (samples, labels) in enumerate(self.data_loader):
              samples = samples.to(self.device)
              labels = labels.to(self.device)
  
              self.optimizer.zero_grad()
              outputs = self.network(samples)
  
              loss = self.loss_function(outputs, labels)
              loss.backward()
              self.optimizer.step()
  
              if self.verbose and ((i + 1) % 100 == 0):
                  print(
                      "Epoch: [%d/%d], Step: [%d/%d], Loss: %.4f"
                      % (
                          epoch + 1,
                          self.num_epochs,
                          i + 1,
                          self.train_dset_len // self.batch_size,
                          loss.item(),
                      )
                  )
  
      # pylint: disable=attribute-defined-outside-init
      self.is_fitted_ = True
      return self
  
imports: from abc import abstractmethod
  import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils.validation import check_X_y, assert_all_finite, check_array, check_is_fitted
  from sklearn.utils.multiclass import type_of_target
label_desc: Use image node_id 2 for calling the PytorchClassifier obj's underlying member method code with example usage: obj.fit(X, y) and returns: self