class_docstr: TaskSampler where the environment can sample "task objects".
  
  This is used for environments that implement `sample_tasks` and `set_task`.
  For example, :py:class:`~HalfCheetahVelEnv`, as implemented in Garage.
  
  Args:
      env_constructor (type): Type of the environment.
      env (garage.Environment or None): Instance of env_constructor to sample
          from (will be constructed if not provided).
      wrapper (Callable[garage.Environment, garage.Environment] or None):
          Wrapper function to apply to environment.
class_docstr_tok: ["TaskSampler","where","the","environment","can","sample","``","task","objects","''",".","This","is","used","for","environments","that","implement","`","sample_tasks","`","and","`","set_task","`",".","For","example",",",":","py",":","class",":","`","~HalfCheetahVelEnv","`",",","as","implemented","in","Garage",".","Args",":","env_constructor","(","type",")",":","Type","of","the","environment",".","env","(","garage.Environment","or","None",")",":","Instance","of","env_constructor","to","sample","from","(","will","be","constructed","if","not","provided",")",".","wrapper","(","Callable","[","garage.Environment",",","garage.Environment","]","or","None",")",":","Wrapper","function","to","apply","to","environment","."]
docstr: int or None: The number of tasks if known and finite.
docstr_tok: ["int","or","None",":","The","number","of","tasks","if","known","and","finite","."]
code: def n_tasks(self):
      """int or None: The number of tasks if known and finite."""
      return getattr(self._env, "num_tasks", None)
  
imports: import abc
  import copy
  import math
  import numpy
  from garage.envs import GymEnv, TaskNameWrapper, TaskOnehotWrapper
  from garage.sampler.env_update import ExistingEnvUpdate, NewEnvUpdate, SetTaskUpdate
label_desc: Use image node_id 2 for calling the SetTaskSampler obj's underlying member method code with example usage: obj.n_tasks() and returns: getattr