text: import torch
  import torch.nn as nn
  import torch.autograd as autograd 
  import torch.nn.functional as F
  from torch.distributions import Categorical
  
  class ActorCnn(nn.Module):
      def __init__(self, input_shape, num_actions):
          super(ActorCnn, self).__init__()
          self.input_shape = input_shape
          self.num_actions = num_actions
          
          self.features = nn.Sequential(
              nn.Conv2d(input_shape[0], 32, kernel_size=8, stride=4),
              nn.ReLU(),
              nn.Conv2d(32, 64, kernel_size=4, stride=2),
              nn.ReLU(),
              nn.Conv2d(64, 64, kernel_size=3, stride=1),
              nn.ReLU()
          )
          
          self.fc = nn.Sequential(
              nn.Linear(self.feature_size(), 512),
              nn.ReLU(),
              nn.Linear(512, self.num_actions),
              nn.Softmax(dim=1)
          )
          
      def forward(self, x):
          x = self.features(x)
          x = x.view(x.size(0), -1)
          x = self.fc(x)
          dist = Categorical(x)
          return dist
      
      def feature_size(self):
          return self.features(autograd.Variable(torch.zeros(1, *self.input_shape))).view(1, -1).size(1)
  
  class CriticCnn(nn.Module):
      def __init__(self, input_shape):
          super(CriticCnn, self).__init__()
          self.input_shape = input_shape
          
          self.features = nn.Sequential(
              nn.Conv2d(input_shape[0], 32, kernel_size=8, stride=4),
              nn.ReLU(),
              nn.Conv2d(32, 64, kernel_size=4, stride=2),
              nn.ReLU(),
              nn.Conv2d(64, 64, kernel_size=3, stride=1),
              nn.ReLU()
          )
          
          self.fc = nn.Sequential(
              nn.Linear(self.feature_size(), 512),
              nn.ReLU(),
              nn.Linear(512, 1)
          )
          
      def forward(self, x):
          x = self.features(x)
          x = x.view(x.size(0), -1)
          x = self.fc(x)
          return x
      
      def feature_size(self):
          return self.features(autograd.Variable(torch.zeros(1, *self.input_shape))).view(1, -1).size(1)