class_docstr: Instrumented function which plays the agent using an environment runner
class_docstr_tok: ["Instrumented","function","which","plays","the","agent","using","an","environment","runner"]
code: def __init__(
      self,
      agent: TorchAgent,
      env_runner: base.EnvironmentRunner,
      reward_postprocessing: tp.Callable[[float], float] = operator.neg,
  ) -> None:
      assert isinstance(env_runner.env, gym.Env)
      self.agent = agent.copy()
      self.runner = env_runner.copy()
      self.reward_postprocessing = reward_postprocessing
      super().__init__(
          self.compute, self.agent.instrumentation.copy().set_name("")
      )
      self.parametrization.function.deterministic = False
      self.add_descriptors(
          num_repetitions=self.runner.num_repetitions,
          archi=self.agent.module.__class__.__name__,
      )
  
imports: import warnings
  import operator
  import copy
  import typing
  import gym
  import numpy
  from nevergrad.common.tools import pytorch_import_fix
  from nevergrad.parametrization import parameter
  from ..base import ExperimentFunction
  from .None import base
  from .None import envs
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.utils.data import WeightedRandomSampler
label_desc: Use image node_id 1 to create a new TorchAgentFunction object from inherited base classes: ExperimentFunction with example: obj = TorchAgentFunction(agent, env_runner, reward_postprocessing)