<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def random_sample(obj, n_samples, seed=None):
 """Create a random array by sampling a ROOT function or histogram. Parameters obj : TH[1|2|3] or TF[1|2|3] The ROOT function or histogram to sample. n_samples : positive int The number of random samples to generate. seed : None, positive int or 0, optional (default=None) The random seed, set via ROOT.gRandom.SetSeed(seed):
 http://root.cern.ch/root/html/TRandom3.html#TRandom3:SetSeed If 0, the seed will be random. If None (the default), ROOT.gRandom will not be touched and the current seed will be used. Returns ------- array : a numpy array A numpy array with a shape corresponding to the dimensionality of the function or histogram. A flat array is returned when sampling TF1 or TH1. An array with shape [n_samples, n_dimensions] is returned when sampling TF2, TF3, TH2, or TH3. Examples -------- 0.53895257, 0.57576984]) array([[ 0.93425084, 0.39990616], [ 0.00819315, 0.73108525], [ 0.00307176, 0.00427081], [ 0.66931215, 0.0421913 ], [ 0.06469985, 0.10253632], [ 0.31059832, 0.75892702]]) array([[ 0.03323949, 0.95734415, 0.39775191], [ 0.07093748, 0.01007775, 0.03330135], [ 0.80786963, 0.13641129, 0.14655269], [ 0.96223632, 0.43916482, 0.05542078], [ 0.06631163, 0.0015063 , 0.46550416], [ 0.88154752, 0.24332142, 0.66746564]]) """

    import ROOT
    if n_samples <= 0:
        raise ValueError("n_samples must be greater than 0")
    if seed is not None:
        if seed < 0:
            raise ValueError("seed must be positive or 0")
        ROOT.gRandom.SetSeed(seed)
    # functions
    if isinstance(obj, ROOT.TF1):
        if isinstance(obj, ROOT.TF3):
            return _librootnumpy.sample_f3(
                ROOT.AsCObject(obj), n_samples)
        elif isinstance(obj, ROOT.TF2):
            return _librootnumpy.sample_f2(
                ROOT.AsCObject(obj), n_samples)
        return _librootnumpy.sample_f1(ROOT.AsCObject(obj), n_samples)
    # histograms
    elif isinstance(obj, ROOT.TH1):
        if isinstance(obj, ROOT.TH3):
            return _librootnumpy.sample_h3(
                ROOT.AsCObject(obj), n_samples)
        elif isinstance(obj, ROOT.TH2):
            return _librootnumpy.sample_h2(
                ROOT.AsCObject(obj), n_samples)
        return _librootnumpy.sample_h1(ROOT.AsCObject(obj), n_samples)
    raise TypeError(
        "obj must be a ROOT function or histogram")