docstr: Class fit ar model on data.
  
  Implementation uses the idea of teacher forcing. That means model learns
  to predict data when horizon != 1. It uses real values or previous model output
  to predict next value. self.teacher_forcing param is used to control probability
  of using real y values.
  
  :param train_data: data with features, target and ids to process
docstr_tok: ["Class","fit","ar","model","on","data",".","Implementation","uses","the","idea","of","teacher","forcing",".","That","means","model","learns","to","predict","data","when","horizon","!","=","1",".","It","uses","real","values","or","previous","model","output","to","predict","next","value",".","self.teacher_forcing","param","is","used","to","control","probability","of","using","real","y","values",".",":","param","train_data",":","data","with","features",",","target","and","ids","to","process"]
code: def fit(self, train_data: InputData):
      """Class fit ar model on data.
  
      Implementation uses the idea of teacher forcing. That means model learns
      to predict data when horizon != 1. It uses real values or previous model output
      to predict next value. self.teacher_forcing param is used to control probability
      of using real y values.
  
      :param train_data: data with features, target and ids to process
      """
      if self.seed is not None:
          torch.manual_seed(self.seed)
          self.model.seed = self.seed
      self.model.init_linear(
          train_data.task.task_params.forecast_length
      )
      self.model = self.model.to(self.device)
      data_loader = self._create_dataloader(train_data)
  
      self.model.train()
      for epoch in range(self.params.get("num_epochs")):
          for x, y in data_loader:
              self.optimizer.zero_grad()
              x = x.to(self.device)
              y = y.to(self.device)
              y_pred = self.forward(x)
              loss = self.criterion(y_pred, y)
              loss.backward()
              self.optimizer.step()
      return self.model
  
imports: import numpy
  from golem.utilities.requirements_notificator import warn_requirement
  from fedot.core.data.data import InputData
  from fedot.core.operations.evaluation.operation_implementations.implementation_interfaces import ModelImplementation
  from fedot.core.operations.operation_parameters import OperationParameters
  from fedot.core.repository.dataset_types import DataTypesEnum
label_desc: Use image node_id 3 for calling the CGRUImplementation obj's underlying member method code with example usage: obj.fit(train_data) and returns: self