code: def linear_regression(opytimizer):
      # Instanciating the model
      model = torch.nn.Sequential()
  
      # Adding linear layer
      model.add_module("linear", torch.nn.Linear(1, 1, bias=False))
  
      # Input variables
      batch_size = 10
      epochs = 100
  
      # Gathers parameters from Opytimizer
      # Pay extremely attention to their order when declaring due to their bounds
      learning_rate = opytimizer[0][0]
      momentum = opytimizer[1][0]
  
      # Declares the loss function
      loss = torch.nn.MSELoss(reduction="mean")
  
      # Declares the optimization algorithm
      opt = optim.SGD(
          model.parameters(), lr=learning_rate, momentum=momentum
      )
  
      # Performs training loop
      for _ in range(epochs):
          # Initial cost as 0.0
          cost = 0.0
  
          # Calculates the number of batches
          num_batches = len(X) // batch_size
  
          # For every batch
          for k in range(num_batches):
              # Declares initial and ending for each batch
              start, end = k * batch_size, (k + 1) * batch_size
  
              # Cost will be the loss accumulated from model's fitting
              cost += fit(model, loss, opt, X[start:end], Y[start:end])
  
      # Calculates final cost
      final_cost = cost / num_batches
  
      return final_cost
  
file_path: opytimizer/examples/integrations/pytorch/linear_regression.py
imports: import numpy
  import torch
  from torch import optim
  from torch.autograd import Variable
  from opytimizer import Opytimizer
  from opytimizer.core import Function
  from opytimizer.optimizers.swarm import PSO
  from opytimizer.spaces import SearchSpace
label_desc: Use image node_id 2 for calling a global function with example usage: linear_regression(opytimizer) and returns: final_cost