code: def anim(self, duration, offset=0, timestep=1,
               label=None, unit=None,
               time_fn=param.Dynamic.time_fn):
          
          frames = (duration // timestep) + 1
          if duration % timestep != 0:
              raise ValueError("The duration value must be an exact multiple of the timestep.")
  
          if label is None:
              label = time_fn.label if hasattr(time_fn, 'label') else 'Time'
  
          unit = time_fn.unit if (not unit and hasattr(time_fn, 'unit')) else unit
          vmap = HoloMap(kdims=[Dimension(label, unit=unit if unit else '')])
  
          self.state_push()
          with time_fn as t:
              t(offset)
              for i in range(frames):
                  vmap[t()] = self[:]
                  t += timestep
          self.state_pop()
          return vmap
docs: duration: The temporal duration to animate in the units
          defined on the global time function.
  
          offset: The temporal offset from which the animation is
          generated given the supplied pattern
  
          timestep: The time interval between successive frames. The
          duration must be an exact multiple of the timestep.
  
          label: A label string to override the label of the global time
          function (if not None).
  
          unit: The unit string to override the unit value of the global
          time function (if not None).
  
          time_fn: The global time function object that is shared across
          the time-varying objects that are being sampled.
  
          Note that the offset, timestep and time_fn only affect
          patterns parameterized by time-dependent number
          generators. Otherwise, the frames are generated by successive
          call to the pattern which may or may not be varying (e.g to
          view the patterns contained within a Selector).