docstr: Utility function to concatenate an NdMapping of Dataset objects.
docstr_tok: ["Utility","function","to","concatenate","an","NdMapping","of","Dataset","objects","."]
code: def concatenate(cls, datasets, datatype=None, new_type=None):
      """
      Utility function to concatenate an NdMapping of Dataset objects.
      """
      from . import Dataset, default_datatype
  
      new_type = new_type or Dataset
      if isinstance(datasets, NdMapping):
          dimensions = datasets.kdims
          keys, datasets = zip(*datasets.data.items())
      elif isinstance(datasets, list) and all(
          not isinstance(v, tuple) for v in datasets
      ):
          # Allow concatenating list of datasets (by declaring no dimensions and keys)
          dimensions, keys = [], [()] * len(datasets)
      else:
          raise DataError(
              "Concatenation only supported for NdMappings "
              "and lists of Datasets, found %s."
              % type(datasets).__name__
          )
  
      template = datasets[0]
      datatype = datatype or template.interface.datatype
  
      # Handle non-general datatypes by casting to general type
      if datatype == "array":
          datatype = default_datatype
      elif datatype == "image":
          datatype = "grid"
  
      if (
          len(datasets) > 1
          and not dimensions
          and cls.interfaces[datatype].gridded
      ):
          raise DataError(
              "Datasets with %s datatype cannot be concatenated "
              "without defining the dimensions to concatenate along. "
              "Ensure you pass in a NdMapping (e.g. a HoloMap) "
              "of Dataset types, not a list." % datatype
          )
  
      datasets = template.interface.cast(datasets, datatype)
      template = datasets[0]
      data = list(zip(keys, datasets)) if keys else datasets
      concat_data = template.interface.concat(
          data, dimensions, vdims=template.vdims
      )
      return template.clone(
          concat_data,
          kdims=dimensions + template.kdims,
          new_type=new_type,
      )
  
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 18 for calling the Interface obj's underlying member method code with example usage: obj.concatenate(cls, datasets, datatype, new_type) and returns: template