docstr: Given a list of Dataset objects, cast them to the specified
  datatype (by default the format matching the current interface)
  with the given cast_type (if specified).
docstr_tok: ["Given","a","list","of","Dataset","objects",",","cast","them","to","the","specified","datatype","(","by","default","the","format","matching","the","current","interface",")","with","the","given","cast_type","(","if","specified",")","."]
code: def cast(cls, datasets, datatype=None, cast_type=None):
      """
      Given a list of Dataset objects, cast them to the specified
      datatype (by default the format matching the current interface)
      with the given cast_type (if specified).
      """
      datatype = datatype or cls.datatype
      cast = []
      for ds in datasets:
          if cast_type is not None or ds.interface.datatype != datatype:
              ds = ds.clone(ds, datatype=[datatype], new_type=cast_type)
          cast.append(ds)
      return cast
  
imports: import sys
  import warnings
  import numpy
  import param
  from ..None import util
  from ..element import Element
  from ..ndmapping import NdMapping
  from .util import finite_range
label_desc: Use image node_id 4 for calling the Interface obj's underlying member method code with example usage: obj.cast(cls, datasets, datatype, cast_type) and returns: cast